Hy, I'm stuck with merging several PDF form in a single One. I've attemp to do it with PDFSharp, but it can't open a readonly pdf form. I've test with pdfsharp and his unethicalreading paramameter and it does some of the work. It merge PDF but erase the form content... (saddly I've lost my time to fill it...)
here are some parts of my code, perhaps its just a missing parameter that I don't think about...
private void MergePDFs(string outPutFilePath, params string[] filesPath)
{
List<PdfReader> readerList = new List<PdfReader>();
foreach (string filePath in filesPath)
{
PdfReader pdfReader = new PdfReader(filePath);
PdfReader.unethicalreading = true;
readerList.Add(pdfReader);
}
Document document = new Document(PageSize.A4, 0, 0, 0, 0);
PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(outPutFilePath, FileMode.Create));
document.Open();
foreach (PdfReader reader in readerList)
{
for (int i = 1; i <= reader.NumberOfPages; i++)
{
PdfImportedPage page = writer.GetImportedPage(reader, i);
document.Add(iTextSharp.text.Image.GetInstance(page));
}
}
document.Close();
}
So if someone has an idea about how merging "modification protected" PDF forms, I'm ready for testing it!
EDIT: After some other tests on non protected PDF forms it doesn't seems to be a protection issue. My MergePDFs doesn't use the form content.
So the Task is still "Merging several PDF forms on C#"
EDIT2: here are 2 files that I want to merge. One is modif protected, one is not. All two are filled. https://drop.infini.fr/r/XFt_Sd8gFc#7thQxyjeGdo8uIkXN6oys82KLB8VE0AHmflb0uYRkVM= https://drop.infini.fr/r/NUa2n2No0R#FaOAGyzk0SrTDtB6CiXUhF7WEKw0EHGHHM7gaKz20o4=