Print Page | Close Window

Retaining OCG / Layers When Merging PDFs

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=4001
Printed Date: 19 Apr 24 at 11:19AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Retaining OCG / Layers When Merging PDFs
Posted By: fellafoo
Subject: Retaining OCG / Layers When Merging PDFs
Date Posted: 09 Feb 23 at 7:00PM
Dear Forum Members:

Do any of you know how to retain OCG / Layers while merging PDFs?

I can merge multiple PDFs with PDFLib.MergeFileList or PDFLib.MergeFileListFast but only the first page retains its layers. I've experimented with MergeDocument and MergeFiles and get the same results. I expect behind the scenes these routines do essentially the same thing.

The PDFs I'm merging are all one page each. Each one has layers and all are created using PDFLib.

Thanks,

MFM



Replies:
Posted By: Ingo
Date Posted: 12 Feb 23 at 5:14PM
perhaps you can do some experiments with MergeDocument or ExtractFilePages?
Perhaps with better results?



-------------
Cheers,
Ingo



Posted By: fellafoo
Date Posted: 12 Feb 23 at 8:04PM
I tried something like this, but the layers are gone.
if PDF_NewPDFLib(PDFLib, True) then begin
  i := 1;
  while (i <= Files2Merge.Count) do begin
    PDFLib.LoadFromFile(Files2Merge[i - 1], ''); { Load Existing File }
    PDFLib.SelectDocument(PDFLib.GetDocumentID(1)); { Select 'Blank' Document }
    PDFLib.CopyPageRanges(PDFLib.GetDocumentID(2), '1'); { Copy Page 1 from existing to 'blank' }
    PDFLib.RemoveDocument(PDFLib.GetDocumentID(2)); { Remove existing from list }
    Inc(i);
  end;
  PDFLib.DeletePages(1, 1); { Delete blank page }
  PDFLib.SaveToFile(MergeMaster);
end;


Posted By: Ingo
Date Posted: 14 Feb 23 at 7:00PM
What you can do first is count the layers.
Second step: Copy your file as layercount times (5 layers means 6 copies cause it starts with 0 i think).
Third step: Remove from each file another layer.
Fourth step: Compare each file version after layer removed.
I don't know the value of this procedures but that's all (i think) what you can do with layers (contentstreams) using QuickPDF.



-------------
Cheers,
Ingo




Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk