How to Convert a PDF Document to an Older or Newer Version?

To make backward and forward compatibility easier, Spire.Pdf allows you to convert existing PDF documents to another PDF version.

Full application support for all the PDF versions may not be possible. To provide support for some older applications, Spire.Pdf allows you to create PDF documents in different versions- PDF 1.3 (Adobe Acrobat 4.x), PDF 1.4 (Adobe Acrobat 5.x), PDF 1.5 (Adobe Acrobat 6.x), etc. The lowest is 1.0 and highest is 1.7. This means that you can load a PDF document then upgrade to a higher version or downgrade to a lower version - providing both backward and forward compatibility.

In this article, we will see code snippets that illustrate the ease with which you can change the PDF version of a PDF document.

The code snippet shows how to convert a PDF document from old version (e.g.1.4) to newer (e.g.1.6).

// Create a PDF document object
PDFDocument document = new PDFDocument();
// Load an old-version PDF document
document.LoadFromFile("1_4.pdf”);
// Specify PDF version for document
document.FileInfo.Version = PdfVersion.Version1_6;
// Save the document in a newer version
document.SaveToFile("newerPDF1_6.pdf");

As you can see, to change the version of a PDF document, you only need to load the document and then set the property PDFDocument.FileInfo.Version to a relevant PDFVersion enumeration value. When you call the method PDFDocument.SaveToFile(), Spire.Pdf does all the work of creating PDF content that is compatible with the version you have specified.

In the following code snippet, we convert a document from new PDF version (e.g.1.6) to older (e.g.1.4).

// Create a PDF document object
PDFDocument document = new PDFDocument();
// Load a new-version PDF document
document. LoadFromFile("1_6.pdf");
// Specify PDF version for document
document.FileInfo.Version = PdfVersion.Version1_4;
// Save the document to a newer version
document. SaveToFile("older_pdf_1_4.PDF");