PDFsharp & MigraDoc Foundation
http://forum.pdfsharp.com/

Unsupported PDF file generated from Excel 365
http://forum.pdfsharp.com/viewtopic.php?f=2&t=4429
Page 1 of 1

Author:  Mtlmonk [ Thu Apr 06, 2023 2:25 pm ]
Post subject:  Unsupported PDF file generated from Excel 365

Hi,

Using version "1.51.5185.0" of PDFSharp.

I've got a PDF file that was generated from Excel 365 that has fields to enter in it. It won't merge with other PDFs and has error: "The PDF document is protected with an encryption not supported by PDFsharp".

I was able to merge it using the latest release of "PDFsharp 6.0.0-preview-1 for .NET 6" however there was regression since some other files that would work before using version "1.51.5185.0" stopped working.

The error happens at the "PdfDocument inputDocument = PdfReader.Open(file, PdfDocumentOpenMode.Import);" statement.

Would like to attach files here but they're too big. Who should I send them to for support?

Here's the file that will NOT work in "1.51.5185.0" but works in "PDFsharp 6.0.0-preview-1 for .NET 6": INDP114_DATASHEET.PDF

Here are 2 files that works in version "1.51.5185.0" but NOT in the latest version: 5REG_DATASHEET.pdf, LUMBER_DIM_FT_DATASHEET.pdf

Here's the code in C# for my console app:

files = inputFiles.Split(',');

// Open the output document
PdfDocument outputDocument = new PdfDocument();

// Iterate files
foreach (string file in files)
{
if (System.IO.File.Exists(file))
{
// Open the document to import pages from it.
try {
PdfDocument inputDocument = PdfReader.Open(file, PdfDocumentOpenMode.Import);

// Iterate pages
int count = inputDocument.PageCount;
for (int idx = 0; idx < count; idx++)
{
// Get the page from the external document...
PdfPage page = inputDocument.Pages[idx];
// ...and add it to the output document.
outputDocument.AddPage(page);
}
}
catch (Exception e)
{
Console.WriteLine(e.Message + file.ToString());

}
}
}

// Save the document...
outputDocument.Save(outputFile);

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/