Obtaining the Libraries Oracle Fusion Middleware Online Documentation Library

Using the BI Publisher Java APIs 7-5 FormProcessor fProcessor = new FormProcessor; fProcessor.setTemplateargs[0]; Input File PDF name fProcessor.setDataargs[1]; Input XML data file name fProcessor.setOutputargs[2]; Output File PDF name fProcessor.process;

7.4.4 Merging XML Data with a PDF Template Using InputOutput Streams

Input: ■ PDF Template Input Stream ■ XML Data Input Stream Output: ■ PDF Output Stream Example 7–2 Sample Code for Merging XML Data with PDF Templates Using InputOutput Streams import java.io.; import oracle.xdo.template.FormProcessor; . . . FormProcessor fProcessor = new FormProcessor; FileInputStream fIs = new FileInputStreamoriginalFilePath; Input File FileInputStream fIs2 = new FileInputStreamdataFilePath; Input Data FileInputStream fIs3 = new FileInputStreammetaData; Metadata XML Data FileOutputStream fOs = new FileOutputStreamnewFilePath; Output File fProcessor.setTemplatefIs; fProcessor.setDatafIs2; Input Data fProcessor.setOutputfOs; fProcessor.process; fIs.close; fOs.close;

7.4.5 Merging an XML Data String with a PDF Template

Input: ■ Template file name String ■ XML data String Output: ■ PDF file name String Example 7–3 Sample Code for Merging XML Data Strings with PDF Templates import oracle.xdo.template.FormProcessor; . . 7-6 Developers Guide for Oracle Business Intelligence Publisher . FormProcessor fProcessor = new FormProcessor; fProcessor.setTemplateoriginalFilePath; Input File PDF name fProcessor.setDataStringxmlContents; Input XML string fProcessor.setOutputnewFilePath; Output File PDF name fProcessor.process;

7.4.6 Retrieving a List of Field Names

Use the FormProcessor.getFieldNames API to retrieve the field names from a PDF template. The API returns the field names into an Enumeration object. Input: ■ PDF Template Output: ■ Enumeration Object Example 7–4 Sample Code for Retrieving a List of Field Names import java.util.Enumeration; import oracle.xdo.template.FormProcessor; . . . FormProcessor fProcessor = new FormProcessor; fProcessor.setTemplatefilePath; Input File PDF name Enumeration enum = fProcessor.getFieldNames; whileenum.hasMoreElements { String formName = Stringenum.nextElement; System.out.printlnname : + formName + , value : + fProcessor.getFieldValueformName; }

7.4.7 Generating XFDF Data

XML Forms Data Format XFDF is a format for representing forms data and annotations in a PDF document. XFDF is the XML version of Forms Data Format FDF, a simplified version of PDF for representing forms data and annotations. Form fields in a PDF document include edit boxes, buttons, and radio buttons. Use this class to generate XFDF data. When you create an instance of this class, an internal XFDF tree is initialized. Use append methods to append a FIELD element to the XFDF tree by passing a String name-value pair. You can append data as many times as you want. This class also enables you to append XML data by calling appendXML methods. Note that you must set the appropriate XSL style sheet by calling setStyleSheet method before calling appendXML methods. You can append XML data as many times as you want. You can retrieve the internal XFDF document at any time by calling one of the following methods: toString, toReader, toInputStream, or toXMLDocument. The following is a sample of XFDF data: