1

我有一个 pdf pdf 确实有 XFA 部分,因为标准 XFA 看起来像

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

我需要将 XML 提取到文件中;我知道文件创建方法为

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

但是,将 xml 部分放入此文件尚不清楚,我看到 XML 可以从 PDF 派生为

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();

代替这个我用

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

表单部分指定 Acrobat 字典是否存在的表单类型;请帮我在记事本中提取xml文件

4

0 回答 0