1

I have a pdf the pdf does have the XFA part and since the standard XFA looks like

 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
 <xdp:xdp>
 <config>...</config>
 <template>...</template>
 <xfa:datasets>

I need to extract the XML into a file ; i know the file creation method as

        StreamWriter sw;
        sw = System.IO.File.CreateText("C:\\xmlread.txt");
        sw.Close();
        System.Windows.Forms.MessageBox.Show("file created successfully");

However getting the xml part into this file is not clear i saw where an XML can be derived from a PDF as

FileOutputStream os = new FileOutputStream(dest);
PdfReader reader = new PdfReader(src);
XfaForm xfa = new XfaForm(reader);
Document doc = xfa.getDomDocument();
Transformer tf = TransformerFactory.newInstance().newTransformer();
tf.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
tf.setOutputProperty(OutputKeys.INDENT, "yes");
tf.transform(new DOMSource(doc), new StreamResult(os));
reader.close();

In place of this i used

 file = new org.pdfclown.files.File(fileName);
        org.pdfclown.documents.Document document = file.Document;
        org.pdfclown.documents.interaction.forms.Form form = document.Form;

the form part specifies the type of form whether the Acrobat dictionary is present or not ; please help me extract xml file in a notepad

user1926152
  • 235
  • 2
  • 8
  • 13

0 Answers0