How to change the version number of the PDF document
Estimated Reading Time: 2 MinutesWith APDFL's C/C++ interface, a document can be saved with a different version number by specifying the major and minor parameters in the PDDocSaveParams struct passed in to the PDDocSaveWithParams() function. Alternatively, the application can call the PDDocSetMinorVersion() or PDDocSetAdobePDFVersion() functions. The sample code below demonstrates:
{ PDDocSaveParamsRec saveParamsRec; memset(&saveParamsRec, 0, sizeof(PDDocSaveParamsRec)); saveParamsRec.size = sizeof(PDDocSaveParamsRec); saveParamsRec.newPath = ASPathFromPlatformPath(OUT_FILENAME); saveParamsRec.saveFlags = PDSaveFull; saveParamsRec.major = 1; saveParamsRec.minor = 4; PDDocSaveWithParams(pdDoc, &saveParamsRec); ASFileSysReleasePath(NULL, saveParamsRec.newPath); }
Note that the major value must be set, too; if it's left at zero, the minor value setting will be ignored.
Note that changing a file's version to an earlier version will not necessarily modify the file's content to conform to the capabilities associated with that PDF version. For example, to make a conforming PDF v1.4 document from a PDF that uses PDF v1.7 features can be a fairly involved process. Conversely, turning a PDF v1.3 into a PDF v2.0 document can be be done by just changing the version number, but should only be done for documents that do not use PDF v2.0 deprecated features.
Also, while a PDF version is stored in the PDF's file header (the first line of every PDF document is a file header with the characters “%PDF-“ followed by a version number, shown as “1.n,” where “n” would be a digit from 0 to 7 (e.g. %PDF-1.7). As of PDF v1.4, this header version can be overridden by the Version entry in the root catalog, which allows a PDF processor to update the version using an incremental update.
.NET and Java
.NET: The Document class has MajorVersion and MinorVersion properties that can be set.
Java: The Document.setMajorVersion() and Document.setMinorVersion() methods can be used to set the PDF's version number.