Это можно сделать с помощью javascript. Скажем, ваш код html / aspx идет следующим образом:
<span>Main heading</span>
<asp:Label ID="lbl1" runat="server" Text="Contents"></asp:Label>
<asp:Label Text="Contractor Name" ID="lblCont" runat="server"></asp:Label>
<div id="forPrintPreview">
<asp:Label Text="Company Name" runat="server"></asp:Label>
<asp:GridView runat="server">
//GridView Content goes here
</asp:GridView
</div>
<input type="button" onclick="PrintPreview();" value="Print Preview" />
Здесь, нажав кнопку «Предварительный просмотр», мы откроем окно с данными для печати. Обратите внимание, что forPrintPreview является идентификатором div. Функция предварительного просмотра печати выглядит следующим образом:
function PrintPreview() {
var Contractor= $('span[id*="lblCont"]').html();
printWindow = window.open("", "", "location=1,status=1,scrollbars=1,width=650,height=600");
printWindow.document.write('<html><head>');
printWindow.document.write('<style type="text/css">@media print{.no-print, .no-print *{display: none !important;}</style>');
printWindow.document.write('</head><body>');
printWindow.document.write('<div style="width:100%;text-align:right">');
//Print and cancel button
printWindow.document.write('<input type="button" id="btnPrint" value="Print" class="no-print" style="width:100px" onclick="window.print()" />');
printWindow.document.write('<input type="button" id="btnCancel" value="Cancel" class="no-print" style="width:100px" onclick="window.close()" />');
printWindow.document.write('</div>');
//You can include any data this way.
printWindow.document.write('<table><tr><td>Contractor name:'+ Contractor +'</td></tr>you can include any info here</table');
printWindow.document.write(document.getElementById('forPrintPreview').innerHTML);
//here 'forPrintPreview' is the id of the 'div' in current page(aspx).
printWindow.document.write('</body></html>');
printWindow.document.close();
printWindow.focus();
}
Обратите внимание, что кнопки «печать» и «отмена» имеют класс «без печати» css, поэтому эти кнопки не будут отображаться в печати.
Большой объект может храниться в нескольких записях, поэтому вам придется использовать транзакцию. Все записи верны или вообще ничего.
https://www.postgresql.org/docs/current/static/largeobjects.html
Если вам не нужно хранить файлы размером более 1 ГБ, я предлагаю вам использовать bytea в качестве типа данных вместо большого объекта.
bytea - это то же самое, что и BLOB в других базах данных (например, Oracle), и его обработка намного более совместима с JDBC.