PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

Keeping accessibility tags when Merging
https://forum.pdfsharp.net/viewtopic.php?f=2&t=4626
Page 1 of 1

Author:  nrse67 [ Wed Jul 10, 2024 7:37 pm ]
Post subject:  Keeping accessibility tags when Merging

Hi,
Using PDFSharp Nuget package, v 6.1.0, windows targeting .net 4.7.2

I have the code working to merge multiple PDF's together, but the accessibility tags that were present on the source PDF's no longer exist once it's merged. I noticed that when I tried pulling in a single document using PdfDocumentOpenMode.Modify, editing it individually, and then saving it off, the tags were still present in the output document, so seems specific to the merging code or Import mode.

Is there a way to merge PDF's together using either PDFSharp or MigraDoc while keeping the accessibility tags from the original documents intact?

Code:
  //Each of the source documents are loaded from a byte array
 var inFiles = new List<PdfDocument>(inputPDFs.Count);
 foreach (var sourceBytes in inputPDFs)
 {
     stream = new MemoryStream(sourceBytes);
     inFiles.Add(PdfReader.Open(stream, PdfDocumentOpenMode.Import));
 }

 // Then I loop through the source files and copy to the new doc
 var document = new PdfDocument();
 inFiles.ForEach(
           pdfDocument =>
           {
               int count = pdfDocument.PageCount;
               for (int idx = 0; idx < count; idx++)
               {
                   PdfPage page = pdfDocument.Pages[idx];
                   document.AddPage(page);
               }
           });

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