Class XFAFlattener
- All Implemented Interfaces:
-
com.itextpdf.tool.xml.html.CssAppliersAware
Input for flattening can be either PDF document containing XFA forms or XDP stream (a pure XML stream containing XFA description).
To flattenXDP the form (from either PDF or XDP):
- Create
XFAFlattener
instance - Invoke
flatten
method
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
flatten
(InputStream xfaInputStream, OutputStream pdfOutputStream) Flattens XFA form from PDF For a single instance ofXFAFlattener
this method could be called only once.void
flattenXDP
(InputStream xdpStream, OutputStream pdfOutputStream) Flattens XFA form from XDP stream.void
flattenXDP
(Document xdpData, OutputStream pdfOutputStream) Flattens XFA form from XML data.com.itextpdf.tool.xml.html.CssAppliers
For internal use only.com.itextpdf.tool.xml.xtra.xfa.resolver.IHrefResolver
setAppConfig
(AppConfig appConfig) void
setCssAppliers
(com.itextpdf.tool.xml.html.CssAppliers cssAppliers) For internal use only.setDefaultLocale
(Locale defaultLocale) setExtraEventList
(List<String> extraEventList) setFlattenerProperties
(XFAFlattenerProperties flattenerProperties) setFontSettings
(XFAFontSettings fontSettings) setHostConfig
(HostConfig hostConfig) setHrefResolver
(com.itextpdf.tool.xml.xtra.xfa.resolver.IHrefResolver hrefResolver) setViewMode
(XFAFlattener.ViewMode viewMode)
-
Constructor Details
-
XFAFlattener
public XFAFlattener()
-
-
Method Details
-
flattenXDP
Flattens XFA form from XDP stream. For a single instance ofXFAFlattener
this method could be called only once. Attempt to reuse method will result in throwing aXFAFlattenerUnexpectedUsageException
. Declare anotherXFAFlattener
instance to process another XDP.Example:
XFAFlattener flattener = new XFAFlattener();
FileInputStream fin = new FileInputStream("c:/xdp_source.xml");
flattener.flattenXDP(fin, new FileOutputStream("my_flat_doc.pdf"));
fin.close();- Parameters:
-
xdpStream
- an XDP stream -
pdfOutputStream
- PDF output stream - Throws:
-
IOException
- is thrown if an error occurred while reading the XDP input stream
-
flatten
public void flatten(InputStream xfaInputStream, OutputStream pdfOutputStream) throws IOException, InterruptedException Flattens XFA form from PDF For a single instance ofXFAFlattener
this method could be called only once. Attempt to reuse method will result in throwing aXFAFlattenerUnexpectedUsageException
. Declare anotherXFAFlattener
instance to process another PDF.- Parameters:
-
xfaInputStream
- the input stream with the PDF containing XFA template -
pdfOutputStream
- the output stream where the flattened PDF will be written to - Throws:
-
IOException
- is thrown if an error occurred while reading the XFA input stream -
InterruptedException
- if the current thread is interrupted by another thread while it is waiting for flatten process, then the wait is ended and anInterruptedException
is thrown.
-
flattenXDP
Flattens XFA form from XML data. For a single instance ofXFAFlattener
this method could be called only once. Attempt to reuse method will result in throwing aXFAFlattenerUnexpectedUsageException
. Declare anotherXFAFlattener
instance to process another XML.Example:
XFAFlattener flattener = new XFAFlattener();
File xmlFile = new File("c:/xdp_source.xml");
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
org.w3c.dom.Document xmlDoc = docBuilder.parse(fXmlFile);
flattener.flattenXDP(xmlDoc, new FileOutputStream("my_flat_doc.pdf"));
- Parameters:
-
xdpData
- an XML data -
pdfOutputStream
- PDF output stream - Throws:
-
IOException
- is thrown if an error occurred while reading the XDP input stream
-
setCssAppliers
public void setCssAppliers(com.itextpdf.tool.xml.html.CssAppliers cssAppliers) For internal use only.- Specified by:
-
setCssAppliers
in interfacecom.itextpdf.tool.xml.html.CssAppliersAware
-
getCssAppliers
public com.itextpdf.tool.xml.html.CssAppliers getCssAppliers()For internal use only.- Specified by:
-
getCssAppliers
in interfacecom.itextpdf.tool.xml.html.CssAppliersAware
-
getViewMode
-
setViewMode
-
getAppConfig
-
setAppConfig
-
getHostConfig
-
setHostConfig
-
getDefaultLocale
-
setDefaultLocale
-
getExtraEventList
-
setExtraEventList
-
getHrefResolver
public com.itextpdf.tool.xml.xtra.xfa.resolver.IHrefResolver getHrefResolver() -
setHrefResolver
public XFAFlattener setHrefResolver(com.itextpdf.tool.xml.xtra.xfa.resolver.IHrefResolver hrefResolver) -
getFontSettings
-
setFontSettings
-
getFlattenerProperties
-
setFlattenerProperties
-