Question

I am using pdflib library to generate pdf in php. I am able to create the pdf with this library but yet not able to generate custom meta tags for pdf.

can any one help me out from this, so that I'm able to generate meta tags for my pdf.

Thanks!

Was it helpful?

Solution 2

Try to use PDFlib PLOP can be found on

http://www.pdflib.com/products/plop/

With the help of this you can set your meta tags for your pdf.

Thanks!

OTHER TIPS

Standard document information tags are Subject, Title, Creator, Author, Keywords, Trapped.

You use them this way (at least in pdflib 7):

PDF_set_parameter($p, "hypertextencoding", "unicode");
PDF_set_parameter($p, "hypertextformat", "utf8");
PDF_set_parameter($p, "usehypertextencoding", "false");
PDF_set_parameter($p, "textformat", "utf8");
PDF_set_info($p, "Creator", $Creator);
PDF_set_info($p, "Author", $Author);
PDF_set_info($p, "Title", $Title);
PDF_set_info($p, "Subject", $Subject);
PDF_set_info($p, "Keywords", $Keywords);

And to define userdefined tags, use:

PDF_set_info($p, "MyCustoMKey", $MyCustomValue);

User defined tags cannot be: CreationDate, Producer, ModDate, GTS_PDFXVersion, GTS_PDFXConformance, ISO_PDFEVersion.

This is enough to get custom tags into pdf. But if you literally want them as xmp, you can autopopulate your custom info to xmp using option autoxmp=true when calling PDF_begin_document():

if (PDF_begin_document($p, $pdf_output_file, "autoxmp=true") == 0) {
  die("Error: " . PDF_get_errmsg($p));
}

I have tested the above in real code and can confirm that it works.

Alternative (and a little more complex) way is this.

This example uses utf8, which is preferable nowadays due to globalisation. So convert your php-file to use utf8 as mime-encoding using your file editor (UltraEdit, Textmate etc.) or by using command line tool iconv.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top