1

I am using EVOPDF library to merge multiple PDF documents into one PDF document.

When the input PDF documents have owner passwords, the output document only contains blank pages.

I see the itext7 has the functionality to remove the owner password with the following line: reader.SetUnethicalReading(true);

How can this be done in EVOPDF or using a free or open source library? Because with itext7 you need to pay for commercial use and I am already paying for an EVOPDF license.

When the PDF documents does not contain owner passwords or I manually remove them, the merging works correctly

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();
MartinS
  • 105
  • 3
  • 11

1 Answers1

0

EvoPdf Merge tools has an interface to append password protected streams : http://www.evopdf.com/help/pdf_merge/html/M_EvoPdf_PdfMerge_PDFMerge_AppendPDFStream_3.htm

The function prototype is:

public void AppendPDFStream(
   Stream pdfStream,
   string password,
   int startIndex,
   int length
)
EvoPdf
  • 523
  • 3
  • 9