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.

Ooker
  • 1,969
  • 4
  • 28
  • 58
DivineDesert
  • 6,924
  • 1
  • 29
  • 61

2 Answers2

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.

iPDFdev
  • 5,229
  • 2
  • 17
  • 18
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.

Cymbals
  • 1,164
  • 1
  • 13
  • 26
  • 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 it – DivineDesert Dec 01 '11 at 04:12
  • http://www.pdflabs.com/docs/install-pdftk/ I use PDFTK on a server. I pass it the things it needs, and it produces the pdf. – Cymbals Dec 01 '11 at 15:37
  • 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. – Cymbals Dec 01 '11 at 15:50
  • 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. – Cymbals Dec 01 '11 at 17:08
  • 1
    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++?? – DivineDesert Dec 02 '11 at 04:14
  • Download the source at http://www.pdflabs.com/docs/build-pdftk/ there are .cc files in there... – Cymbals Dec 06 '11 at 17:54