Copy Table of Contents from one PDF to another
Asked Answered
A

2

12

You might find it as duplicate of Create a table of contents from a pdf file, but I didn't get any solution there. My scenario is like I am creating a PDF from existing PDF with some edits. That all works fine. My question is I want to add metadata, table of contents, bookmarks, what ever you call that is in metadata of PDF to the newly created PDF. I am not able to understand XMP format as suggested in How to add the metadata to a pdf in Objective C?. Is there any way I can directly add TOC to new PDF?

I am using following function but it is not working at all.

CGPDFContextAddDocumentMetadata(pdfContext, contdata);

Can anyone suggest me the direction to dig in? Any 3rd party tool will also do. I tried podofo but I'm not getting any way for porting it in iOS.

Ammons answered 14/11, 2011 at 13:17 Comment(0)
C
3

The XMP metadata and TOC/bookmarks are 2 different things. While the TOC in a PDF file can be read using the CGPDF* functions, it cannot be duplicated in another PDF file because the CGPDF* API does not let you create PDF objects and insert them in a PDF file.

Crosslegged answered 25/11, 2011 at 14:20 Comment(1)
Thanks for your response.. Is there any way around though which I can accomplish this??Ammons
A
1

I recently did a lot of merging pdf's together and also populating form data. I would check out PDF Toolkit as it really helped me out. You can execute it from within your code.

Alcalde answered 30/11, 2011 at 19:45 Comment(6)
How to integrate it in iphone sdk. I m not getting any way to do this. If you have done these in iphone, can u suggest me what to do? and how to do. I have previously integrated a C++ library in iphone sdk, but for this I m not getting how to use itAmmons
pdflabs.com/docs/install-pdftk I use PDFTK on a server. I pass it the things it needs, and it produces the pdf.Alcalde
btw: there is an install for Mac OS X to run locally, but I'd go with the server solution instead of worrying about it locally.Alcalde
After setting it up on a server, you could ajax the file(s) via base64 encoded strings in POST, process the virtual file and echo out a base65 encoded string back, and decode it into a pdf.Alcalde
This loop from the server will be a costly effort. I can see only sys commands that are executed in this toolkit, how to execute it in c++??Ammons
Download the source at pdflabs.com/docs/build-pdftk there are .cc files in there...Alcalde

© 2022 - 2024 — McMap. All rights reserved.