1

PDF/A 1a を作成する XFA PDF を埋めてフラット化するために iText を使用する場合、読み取り順序を維持するにはどうすればよいですか?

事前にフラット化された PDF の読み取り順序は and 要素に格納されますが、この情報はフラット化されたタグ付き PDF/A 1a ドキュメントでは表現されません。

具体的には、フラット化する前に JAWS によって適切に読み取られる私の 2 列フォームは、1 列を下に読み込んでから、 2 番目の列。

iText Java コードは次のようになります。

public void manipulatePdf(String src, String xml, File dest)
        throws IOException, DocumentException, InterruptedException {

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PdfReader reader = new PdfReader(src);
    PdfStamper stamper = new PdfStamper(reader, baos);
    AcroFields form = stamper.getAcroFields();

    XfaForm xfa = form.getXfa();
    stamper.close();

    Document document = new Document();
    PdfAWriter writer = PdfAWriter.getInstance(document,
            new FileOutputStream(dest), PdfAConformanceLevel.PDF_A_1A);

    writer.setTagged();
    document.addLanguage("en-us");
    document.open();

    ICC_Profile iccProfile = ICC_Profile.getInstance(new FileInputStream(
            colorProfile));
    writer.setOutputIntents("Custom", "", "http://www.color.org",
            "sRGB IEC61966-2.1", iccProfile);
    PdfICCBased iccBased = new PdfICCBased(iccProfile);
    iccBased.remove(PdfName.ALTERNATE);
    PdfDictionary outputIntent = new PdfDictionary(PdfName.OUTPUTINTENT);
    outputIntent.put(PdfName.OUTPUTCONDITIONIDENTIFIER, new PdfString(
            "sRGB IEC61966-2.1"));
    outputIntent.put(PdfName.INFO, new PdfString("sRGB IEC61966-2.1"));
    outputIntent.put(PdfName.S, PdfName.GTS_PDFA1);
    outputIntent.put(PdfName.DESTOUTPUTPROFILE, writer.addToBody(iccBased)
            .getIndirectReference());
    writer.getExtraCatalog().put(PdfName.OUTPUTINTENTS,
            new PdfArray(outputIntent));

    PdfDictionary markInfo = new PdfDictionary(PdfName.MARKINFO);
    markInfo.put(PdfName.MARKED, new PdfBoolean(true));
    writer.getExtraCatalog().put(PdfName.MARKINFO, markInfo);

    XFAFlattener xfaf = new XFAFlattener(document, writer);
    xfaf.flatten(new PdfReader(baos.toByteArray()), false);
    document.close();

    System.out.println("The form is flattened");
}
4

0 に答える 0