[cairo] API to set PDF meta data (author, creator, etc)

Adib Taraben taraben.a at st-innovation.com
Wed Sep 19 14:48:08 PDT 2007


Hello Cairo team,

attached there is a patch for the pdf surface to support custom info 
dictionary in order to set author, creator, etc.

The new API is as follow:
/**
  * cairo_pdf_info_dict_t
  *
  * #cairo_pdf_info_dict_t is used to enumerate the info keys in the 
document information dictionary
  * see chapter 10.2.1. of the pdf reference, version 1.6.
  */
typedef enum _cairo_pdf_info_dict {
     CAIRO_PDF_INFO_TITLE,
     CAIRO_PDF_INFO_AUTHOR,
     CAIRO_PDF_INFO_SUBJECT,
     CAIRO_PDF_INFO_KEYWORDS,
     CAIRO_PDF_INFO_CREATOR,
     CAIRO_PDF_INFO_PRODUCER,
     CAIRO_PDF_INFO_CREATIONDATE,
     CAIRO_PDF_INFO_MODDATE,
     CAIRO_PDF_INFO_TRAPPED
} cairo_pdf_info_dict_t;

cairo_public void
cairo_pdf_get_info_dicts (cairo_pdf_info_dict_t const	**info_dicts,
                         int                      *num_info_dicts);

cairo_public const char *
cairo_pdf_info_dict_to_string (cairo_pdf_info_dict_t info_dict);

cairo_public const char *
cairo_pdf_get_info_dict (cairo_surface_t 	*abstract_surface,
                          cairo_pdf_info_dict_t          info_dict);

cairo_public cairo_status_t
cairo_pdf_set_info_dict (cairo_surface_t 	*abstract_surface,
                          cairo_pdf_info_dict_t          info_dict,
                          char *                        info_dict_value);

This API sets a limited number of keywords as defined in the PDF spec. 
However there can be as many as possible in the pdf but those supported 
have a special meaning to the viewer applications.

The implementation sets a default creator that can be superset but the 
producer is fixed to the current string.

a simple example here:
     surface = cairo_pdf_surface_create("C97.pdf", A4_WIDTH, A4_HEIGHT);
     cr = cairo_create(surface);
     cairo_surface_destroy(surface);
     cairo_pdf_set_info_dict (surface, CAIRO_PDF_INFO_AUTHOR, "Adib 
Taraben");


Hope that this will usefully.

Adib.
----
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cairo_pdf_info_dict.patch
Type: text/x-patch
Size: 11057 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20070919/44b35491/attachment-0001.bin 


More information about the cairo mailing list