pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Roberto Nibali <rnib...@gmail.com>
Subject Injecting Javascript into a PDF with form fields
Date Tue, 18 Aug 2015 18:29:56 GMT
Hello

I'm trying to chase down a weird feature of the Acrobat Reader, which has
been puzzling me for days now: whenever I inject javascript into the
document open event, some form fields of certain PDFs I'm working with get
*renamed* automatically by Acrobat. If I do not inject the Javascript code,
the field names remain the same. Basically, the relevant code is like
follows:

@Test
public void SimpleTest() throws IOException {
    PDDocument tplDoc;
    String tplDocName = "./cctemp2.pdf";
    String outDocName = "./ccmig2.pdf";

    tplDoc = PDDocument.load(new File(tplDocName));
    String ac = "app.alert({cMsg: 'It seems we have injected some
JavaScript', cTitle: 'Information', nIcon: 3});";
    PDAction action = new PDActionJavaScript(ac);
    tplDoc.getDocumentCatalog().setOpenAction(action);
    tplDoc.save(outDocName);
    tplDoc.close();
}

*Question*: Does anybody here have a good understanding of the PDF
"standard" to explain to me under which circumstances this is happening? Or
is it a peculiarity of Acrobat? Has anybody ever encountered this before?
Strangely enough, it only happens with some PDFs, others (which are almost
identical) are left alone. How would I be able to debug this?

Best regards
Roberto

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message