Hi Ian,
I think you have to create an object and set the xmp metedata as a stream.
See my example below:
PoDoFo::PdfMemDocument *doc = new PoDoFo::PdfMemDocument(argv[1]);
// read the contents of a file (argv[2]) into buf and \0 terminate it.
const char* xmpString = "raw xmpdata";
PdfObject* pObj = doc->GetObjects().CreateObject("Metadata");
pObj->GetDictionary().AddKey(PdfName("Subtype"), PdfName("XML"));
pObj->GetStream()->Set(xmpString, strlen(xmpString));
doc->GetCatalog()->GetDictionary().AddKey(PoDoFo::PdfName("Metadata"),
pObj->Reference());
doc->Write(argv[2]);
Cheers,
Dominik
Am Montag 09 August 2010 schrieb Ian Ashley:
> Dear Dominik,
>
> Thanks for the advice. I had a go and the code compiles and runs but
> produces a PDF where the metadata cannot be extracted using the GetMetadata
> method (it core dumps).
>
> Please could you have see whether I am doing the correct thing
>
> PoDoFo::PdfMemDocument *doc = new PoDoFo::PdfMemDocument(argv[1]);
>
> // read the contents of a file (argv[2]) into buf and \0 terminate it.
> The file contains XMP data.
>
> PoDoFo::PdfString xmpStr((PoDoFo::pdf_utf8 *)buf);
> doc->GetCatalog()->GetDictionary().AddKey(PoDoFo::PdfName("Metadata"),
> PoDoFo::PdfObject(xmpStr));
> doc->Write(argv[3]);
>
> Thanks in advance,
> Ian
>
>
> Ian Ashley
> Software Engineering Manager
> Development
>
>
> Open Text
> Sandridge Park, Porters Wood,
> St Albans, Herts.
> AL3 6PH
> UK
>
> Phone: +44 (0) 1727 847488
> Fax: +44 (0) 1727 840649
> Email: [email protected]
> Web site: http://www.opentext.com/
>
> Nstein is now Open Text.
> Please update your address book with my new email address.
> This email is protected by domestic and international copyright laws and
> treaties and is the property of Open Text Corporation, it may contain
> confidential and/or trade secret information of the Open Text Corporation
> and/or its subsidiaries (OTC), and may be subject to legal privilege in
> favour of OTC. This email may only be lawfully received, accessed,
> displayed on a computer screen, printed, copied, and/or used by the
> specific addressee(s) named above ("Authorized Recipient") for the purpose
> for which it was sent by OTC. All other rights and licenses to this email
> are fully reserved to OTC. If you are not an Authorized Recipient, you are
> required to immediately delete this email in its entirety without
> printing, copying, using, and/or re-transmitting this email, either in
> whole or in part. The transmission of this email by OTC is not to be
> construed as a waiver by OTC and/or the individual sending this email on
> behalf of OTC of any of their respective rights or privileges at law or
> otherwise, howsoever arising
>
>
>
>
> From: Dominik Seichter <[email protected]>
> Date: Wed, 4 Aug 2010 15:06:58 +0100
> To: Ian Ashley <[email protected]>,
> <[email protected]>
> Subject: Re: [Podofo-users] XMP Metadata
>
> Hi Ian,
>
> PoDoFo gives you direct access to any object in the PDF document.
> Therefore you can easily create a metadata object and add it to the object
> returned by PdfMemDocument::GetCatalog().
>
> Regards,
> Dom
>
> Am Freitag 30 Juli 2010 schrieben Sie:
> > Dear Sir/Madam,
> >
> > I have found the method for reading the XMP metadata
> > (PDFMemDocument::GetMetadata). I noticed that this gets a named object
> > from the catalog. Is there anyway to set/add XMP metadata to an existing
> > PDF using PoDoFo?
> >
> > Regards,
> > Ian
> >
> >
> > Ian Ashley
> > Software Engineering Manager
> > Development
> >
> >
> > Open Text
> > Sandridge Park, Porters Wood,
> > St Albans, Herts.
> > AL3 6PH
> > UK
> >
> > Phone: +44 (0) 1727 847488
> > Fax: +44 (0) 1727 840649
> > Email: [email protected]
> > Web site: http://www.opentext.com/
> >
> > Nstein is now Open Text.
> > Please update your address book with my new email address.
> > This email is protected by domestic and international copyright laws and
> > treaties and is the property of Open Text Corporation, it may contain
> > confidential and/or trade secret information of the Open Text Corporation
> > and/or its subsidiaries (OTC), and may be subject to legal privilege in
> > favour of OTC. This email may only be lawfully received, accessed,
> > displayed on a computer screen, printed, copied, and/or used by the
> > specific addressee(s) named above ("Authorized Recipient") for the
> > purpose for which it was sent by OTC. All other rights and licenses to
> > this email are fully reserved to OTC. If you are not an Authorized
> > Recipient, you are required to immediately delete this email in its
> > entirety without printing, copying, using, and/or re-transmitting this
> > email, either in whole or in part. The transmission of this email by OTC
> > is not to be construed as a waiver by OTC and/or the individual sending
> > this email on behalf of OTC of any of their respective rights or
> > privileges at law or otherwise, howsoever arising
>
--
**********************************************************************
Dominik Seichter - [email protected]
KRename - http://www.krename.net - Powerful batch renamer for KDE
KBarcode - http://www.kbarcode.net - Barcode and label printing
PoDoFo - http://podofo.sf.net - PDF generation and parsing library
SchafKopf - http://schafkopf.berlios.de - Schafkopf, a card game, for KDE
Alan - http://alan.sf.net - A Turing Machine in Java
**********************************************************************
signature.asc
Description: This is a digitally signed message part.
------------------------------------------------------------------------------ This SF.net email is sponsored by Make an app they can't live without Enter the BlackBerry Developer Challenge http://p.sf.net/sfu/RIM-dev2dev
_______________________________________________ Podofo-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/podofo-users
