我有一个程序需要几个 pdf(甚至 1000+)并将它们合并到一个 pdf 中。
该程序运行良好,但我遇到了假脱机错误。
如果我用 Acrobat 打开合并的 pdf 并打印它,而不是向打印机发送一个包含 n 页的假脱机,它会发送与原始 pdf 数量一样多的假脱机,导致打印机处理它的速度非常慢。
这是该类的摘要
Document document = new Document ( iTextSharp.text.PageSize.A4 );
PdfWriter writer = PdfWriter.GetInstance ( document, new FileStream ( outputFilename, FileMode.Create ) );
writer.SetFullCompression();
document.Open();
PdfContentByte cb = writer.DirectContent;
foreach( var file in files ) {
PdfReader reader = new PdfReader ( file );
int n = reader.NumberOfPages;
int i = 0;
while ( i < n)
{
i++;
document.SetPageSize ( reader.GetPageSizeWithRotation ( i ) );
document.NewPage();
page = writer.GetImportedPage ( reader, i );
rotation = reader.GetPageRotation ( i );
cb.AddTemplate ( page, 1f, 0, 0, 1f, 0, 0 );
}
}
document.Close();