Information for Developers of Tax Document Software — Intelligent Tax Documents®
PDF versions of annual tax documents may "electronically deliver" tax data by embedding FDX JSON in the PDF "custom properties".
Such PDF files are referred to as intelligent tax documents®.
As seen below, the tax document information in FDX-standard JSON format is included internally in the PDF file.
How to add FDX JSON to your PDF tax documents
Example Java code
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDDocumentInformation;
import java.io.File;
import java.io.IOException;
public class PdfFdxJsonInjector {
public void inject(
String pdfInFilePath,
String pdfOutFilePath,
String fdxVersion,
String fdxSoftwareId,
String fdxJson
) throws IOException {
try (
PDDocument document = PDDocument.load( new File( pdfInFilePath ) );
) {
// Inject custom properties
PDDocumentInformation documentInformation = new PDDocumentInformation( );
documentInformation.setCustomMetadataValue( "fdxJson", fdxJson );
documentInformation.setCustomMetadataValue( "fdxVersion", fdxVersion );
documentInformation.setCustomMetadataValue( "fdxSoftwareId", fdxSoftwareId );
document.setDocumentInformation( documentInformation );
document.save( new File( pdfOutFilePath ) );
} catch ( Exception e ) {
System.out.println( e.getMessage( ) );
}
}
}