How to Extract Embedded JSON from a PDF File

Here is sample java code based on the Apache PDFBox library.

import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDDocumentInformation;

public class PdfFdxJsonReader {

    private String fdxJson;
    private String fdxVersion;
    private String fdxSoftwareId;

    public String getFdxJson( ) {
        return fdxJson;
    }

    public String getFdxVersion( ) {
        return fdxVersion;
    }

    public String getFdxSoftwareId( ) {
        return fdxSoftwareId;
    }

    public void read( byte[] pdfBytes ) {

        try (
            PDDocument document = PDDocument.load( pdfBytes ) );
        ) {

            PDDocumentInformation info = document.getDocumentInformation( );
            if ( info == null ) {
                return;
            }

            this.fdxJson = info.getCustomMetadataValue( "fdxJson" );
            this.fdxVersion = info.getCustomMetadataValue( "fdxVersion" );
            this.fdxSoftwareId = info.getCustomMetadataValue( "fdxSoftwareId" );

        } catch ( Exception e ) {

            System.out.println( e.getMessage( ) );

        }

    }

}