PDF (Portable Document Format) is a format for encapsulating all types of documents for transmission and usage electronically.
Contents
Current status
You can embed a Creative Commons license in a PDF document using XMP through, for example, Adobe Photoshop CS.
The most recent PDF standard (as of May 7, 2006), version 1.6, provides two mechanisms for the storing of metadata, such as license information, in the file. In section 10.2 of the standard, the two methods described are the document information dictionary and the metadata stream.
Document information dictionary
An example of the first, the document information dictionary, is given in section 10.2.1:
1 0 obj << /Title (PostScript Language Reference, Third Edition) /Author (Adobe Systems Incorporated) /Creator (Adobe® FrameMaker® 5.5.3 for Power Macintosh®) /Producer (Acrobat® DistillerTM 3.01 for Power Macintosh) /CreationDate (D:19970915110347-08'00') /ModDate (D:19990209153925-08'00') >> endobj
Table 10.2 in section 10.2.1 lists 9 standard keys in the dictionary. "License" is not among them, but the specification makes reference to the creation of new keys in two sentences in section 10.2.1: "New keys should be chosen with care so that they make sense to users. The value associated with any key not specifically mentioned in Table 10.2 must be a text string."
This suggests that writing a tool that added a license key to the dictionary might be a reasonable way to proceed.
Metadata stream
This is the second method by which metadata can be embedded in a PDF. XMP is an example of the metadata stream, in which a chunk of XML is embedded in the PDF file for parsing by agents that don't necessarily understand how to read a PDF, but can read XML.
Implementations
- Cross-platform Java App by Enrico
- CCInfo for Acrobat
- PDF creator with embedded CC license for Windows (GPL)
- See XMP for others.
Examples
Here's an example of using Exempi to embed license info. This code works for all file formats that Exempi supports, including PDFs.
#include <exempi/xmp.h> #include <exempi/xmpconsts.h> ... xmp_init(); XmpFilePtr f; f = xmp_files_open_new(filename, XMP_OPEN_FORUPDATE); XmpPtr xmp = xmp_files_get_new_xmp(f); if ( xmp == NULL ) { xmp = xmp_new_empty(); } if ( xmp_files_can_put_xmp(f, xmp) ) { xmp_register_namespace(NS_CC, "cc", NULL); xmp_set_property(xmp, NS_CC, "license", "http://creativecommons.org/licenses/by-sa/2.5/"); xmp_files_put_xmp(f, xmp); } else { printf("Unable to write XMP to this file.\n"); } xmp_files_close(f, XMP_CLOSE_SAFEUPDATE); xmp_free(xmp); xmp_terminate(); ...