レポートビューアからレポートを印刷する他の方法が見つからなかったので、グーグルで調べたところitextがシャープであることがわかったので、最初にレポートを生成し、ソースファイルにPDFが作成され、次に印刷ボタンをクリックすると、ちょうどあったPDFが印刷されますクライアント マシンで pdf の印刷オプションを起動することによって作成されましたが、私が抱えている問題は、複数のユーザーがレポートを生成して pdf を印刷すると、リソースが既に使用されているというエラーが表示されることです。お知らせください。この問題の回避策、またはクライアント マシンでレポートを印刷できるその他の方法がある場合は??
印刷に使用するコード
using iTextSharp.text.pdf;
using iTextSharp.text;
Warning[] warnings;
string[] streamids;
string mimeType;
string encoding;
string extension;
byte[] bytes = ReportViewer1.LocalReport.Render("PDF", null, out mimeType,
out encoding, out extension, out streamids, out warnings);
FileStream fs = new FileStream(HttpContext.Current.Server.MapPath("output.pdf"),
FileMode.Create);
fs.Write(bytes, 0, bytes.Length);
fs.Close();
//Open existing PDF
Document document = new Document(PageSize.LETTER);
PdfReader reader = new PdfReader(HttpContext.Current.Server.MapPath("output.pdf"));
//Getting a instance of new PDF writer
PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(
HttpContext.Current.Server.MapPath("Print.pdf"), FileMode.Create));
document.Open();
PdfContentByte cb = writer.DirectContent;
int i = 0;
int p = 0;
int n = reader.NumberOfPages;
Rectangle psize = reader.GetPageSize(1);
float width = psize.Width;
float height = psize.Height;
//Add Page to new document
while (i < n)
{
document.NewPage();
p++;
i++;
PdfImportedPage page1 = writer.GetImportedPage(reader, i);
cb.AddTemplate(page1, 0, 0);
}
//Attach javascript to the document
PdfAction jAction = PdfAction.JavaScript("this.print(true);\r", writer);
writer.AddJavaScript(jAction);
document.Close();
//Attach pdf to the iframe
frmPrint.Attributes["src"] = "Print.pdf";
外部ボタンを使用して、レポート ビューアからレポートを印刷する別のより高速な方法はありますか?