【问题标题】:How to merge PDF documents that contains owner passwords with C#如何使用 C# 合并包含所有者密码的 PDF 文档
【发布时间】:2020-01-29 19:58:09
【问题描述】:

我正在使用 EVOPDF 库将多个 PDF 文档合并为一个 PDF 文档。

当输入的 PDF 文档有所有者密码时,输出的文档只包含空白页。

我看到 itext7 具有删除所有者密码的功能,其中包含以下行: reader.SetUnethicalReading(true);

如何在 EVOPDF 中或使用免费或开源库来完成此操作? 因为使用 itext7 您需要为商业用途付费,而我已经为 EVOPDF 许可证付费。

当 PDF 文档不包含所有者密码或我手动删除它们时,合并工作正常

List<Byte[]> totalBytes = new List<byte[]>();
byte[] pdfBytes = null;

//Populate the totalBytes List with the PDF byte arrays

MemoryStream ms1 = new MemoryStream(totalBytes[0])
MemoryStream ms2 = new MemoryStream(totalBytes[1])

pdfMerge.AppendPDFStream(ms1);
pdfMerge.AppendPDFStream(ms2);

pdfBytes = pdfMerge.RenderMergedPDFDocument();

Response.Clear();
Response.ContentType = "application/pdf";

Response.AddHeader("content-disposition", "filename=" + savedFilename);
Response.AddHeader("Content-Length", pdfBytes.Length.ToString());

Response.BinaryWrite(pdfBytes.ToArray());
pdfBytes = null;
Response.Flush();
Response.Close();
Response.End();

【问题讨论】:

    标签: c# pdf evopdf


    【解决方案1】:

    EvoPdf 合并工具有一个附加密码保护流的接口:http://www.evopdf.com/help/pdf_merge/html/M_EvoPdf_PdfMerge_PDFMerge_AppendPDFStream_3.htm

    函数原型为:

    public void AppendPDFStream(
       Stream pdfStream,
       string password,
       int startIndex,
       int length
    )
    

    【讨论】:

      猜你喜欢
      • 2015-03-08
      • 1970-01-01
      • 1970-01-01
      • 2010-09-08
      • 1970-01-01
      • 1970-01-01
      • 2017-03-16
      • 1970-01-01
      相关资源
      最近更新 更多