PDF Bookbinder Processor Oracle Fusion Middleware Online Documentation Library

7-28 Developers Guide for Oracle Business Intelligence Publisher -tmp directory is the temporary directory for better memory management. This is optional, if not specified, the system environment variable java.io.tmpdir will be used. -log file sets the output log file optional, default is System.out. -debug true or false turns debugging off or on.

7.8.4 API Method Call

The following is an example of an API method call: Example 7–29 Sample API Method Call String xmlInputPath = c:\\tmp\\toc.xml; String pdfOutputPath = c:\\tmp\\final_book.pdf; PDFBookBinder bookBinder = new PDFBookBinderxmlInputPath, pdfOutputPath; bookBinder.setConfignew Properties; bookBinder.process;

7.9 PDF Digital Signature Engine

This section discusses how to use the PDF Digital Signature Engine, and includes the following topics: ■ Section 7.9.1, Overview of the PDF Digital Signature Engine ■ Section 7.9.2, Signing PDF Documents ■ Section 7.9.3, Delivering Signed PDF Documents. ■ Section 7.9.4, Verifying Signed PDF Documents

7.9.1 Overview of the PDF Digital Signature Engine

The PDF Digital Signature Engine creates signed PDF documents by processing unsigned PDF documents with a signature field name and a password-protected Personal Information Exchange PFX file. PFX files adhere to the Public Key Cryptography Standards 12 PCKS-12 format and contain a digital certificate and a corresponding private key. To create signed PDF documents, see Section 7.9.2, Signing PDF Documents. To distribute or deliver signed PDF documents, use the Schedule Service. See Chapter 3, ScheduleService. To verify signed PDF documents, see Section 7.9.4, Verifying Signed PDF Documents.

7.9.2 Signing PDF Documents

Signing a PDF document requires the following items: ■ A digital certificate. To obtain a digital certificate, see Implementing Digital Signatures in Oracle Fusion Middleware Developers Guide for Oracle Business Intelligence Publisher. ■ A PFX file that contains your digital certificate.To create a PFX file, see Implementing Digital Signatures in Oracle Fusion Middleware Developers Guide for Oracle Business Intelligence Publisher. Using the BI Publisher Java APIs 7-29 ■ A PDF file with a signature field. If your PDF file does not contain a signature field, you can add one using the addSignatureField method. Example 7–30 provides sample code for adding a signature field to a PDF file. This method saves the signature field in the PKCS-1 Secure Hash Algorithm 1 SHA-1 format. After you obtain or create the items listed above, you are ready to sign a PDF document. To sign a PDF document, process your PDF file with your PFX file using the PDFSignature Java API that Oracle BI Publisher provides. Example 7–30 provides sample code for this purpose. Example 7–30 Sample Code for Creating Signed PDF Documents String workDir = C:projects; String inPDF = workDir + VerySimpleContent.pdf; String outPDF = workDir + VerySimpleContent_signed.pdf; String pkcs12File = workDir + YourName.pfx; try { PDFSignature pdfSignature = new PDFSignatureinPDF, outPDF; pdfSignature.initpassword123, pkcs12File; If your PDF document does not have a signature field, uncomment the following line of code, which adds a signature field with the name Signature1. pdfSignature.addSignatureField1, PDFSignature.PDF_SIGNFIELD_UPPER_RIGHT, Signature1“, -1, -1; pdfSignature.signSignature1, “Reason to Sign; pdfSignature.cleanup; } catchThrowable t { t.printStackTrace; }

7.9.3 Delivering Signed PDF Documents

To distribute or deliver signed PDF documents, use the Schedule Service. See Chapter 3, ScheduleService.

7.9.4 Verifying Signed PDF Documents

You can verify signed PDF documents by processing them with your digital certificate. Example 7–31 provides sample code for this purpose. Example 7–31 Sample Code for Verifying Signed PDF Documents String workDir = C:projects; String inPDF = workDir + VerySimpleContent_signedWithAcrobat.pdf; String trustedRootCert = workDir + VerisignFreeCertificate.cer; File trustedRootCertFile = new FiletrustedRootCert; Vector trustedCerts = new Vector; trustedCerts.addElementtrustedRootCertFile; try { PDFSignature pdfSignature = new PDFSignatureinPDF; pdfSignature.init; 7-30 Developers Guide for Oracle Business Intelligence Publisher SignatureFields signFields = pdfSignature.getSignatureFields; Vector signedFieldNames = signFields.getSignatureFieldNames; int size = signedFieldNames.size; forint i = 0 ; i size ; i++ { String signFieldName = StringsignedFieldNames.elementAti; SignatureField signField = signFields.getSignatureFieldsignFieldName; boolean isValid = signField.verifyDocument; System.out.printlnValid? : + isValid; boolean isCertValid = signField.verifyCertificatestrustedCerts, null; System.out.printlnTrusted? : + isCertValid; } } catchThrowable t { t.printStackTrace; }

7.10 eText Processor

The eText Processor enables you to convert RTF eText templates to XSL, and merge the XSL with XML to produce text output for EDI and EFT transmissions.

7.10.1 Converting RTF eText Templates to XSL

The following is an example of an API method call that converts an RTF eText template to XSL: Example 7–32 Sample Code for Converting RTF eText Templates to XSL String rtf = test.rtf; etext template filename String xsl = out.xsl; xsl-fo filename Properties prop = new Properties; try { EFTProcessor p = new EFTProcessor; p.setTemplatertf; p.setConfigprop; p.setOutputxsl; p.process; } catch Exception e { e.printStackTrace; }

7.10.2 Producing Text Output for EDI and EFT Transmissions

The following is an example of an API method call that merges XSL with XML to produce eText output: Example 7–33 Sample Code for Producing Text Output for EDI and EFT Transmissions String rtf = test.rtf; etext template filename String xml = “data.xml”; xml data filename String etext = “etext.txt”; etext output filename Properties prop = new Properties;