我有一个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部分放入此文件并不清楚,我看到了可以从PDF派生XML的位置
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文件