Change PDF Version in Java

Spire.PDF supports the PDF versions from 1.0 to 1.7. You can convert PDF file between different versions for compatibility purpose. The following code snippets demonstrate the same.

package com.spire.pdf;

public class ChangePdfVersion {

    public static void main(String[] args) {

        //create a PdfDocument object
        PdfDocument document = new PdfDocument();
        
        //load a sample PDF file
        document.loadFromFile("C:\\Users\\Administrator\\Desktop\\sample.pdf");

        //change the PDF version 
        document.getFileInfo().setVersion(PdfVersion.Version_1_6);
	
        //save to file 
        document.saveToFile("PdfVersion.pdf", FileFormat.PDF);
        document.close();
    }

Output:

Change PDF Version in Java