1

I am using pd4ml to create pdf documents, however I don't want the user to be able to edit those documents using ms word 2013. here is what I have tried so far

pd4ml = new PD4ML();
pd4ml.setPageSize(PD4Constants.A4);
pd4ml.setPageInsetsMM(new Insets(TOPVALUE, LEFTVALUE, BOTTOMVALUE, RIGHTVALUE));
pd4ml.setHtmlWidth(USERSPACEWIDTH);
pd4ml.enableImgSplit(false);
pd4ml.disableHyperlinks();
//some more code 
pd4ml.render(arrayOfURLs, byteArrayOutputStream);
//some more code

then I read the PD4ML API documentation and added this line of code pd4ml.generatePdfa(true); I thought the problem was solved when I opened the document in adobe reader and saw this message " this file claims compliance with the pdf/a standard and has been opened read-only", but of course it was still editable; so any suggestions on how this is done in pd4ml, or any reference to an api I can use to add this restriction to the generated pdf will be more than welcomed.

QuakeCore
  • 1,886
  • 2
  • 15
  • 33
  • 1
    something is really weird in this community, the contribution of some people is only to give vote downs they never bother explaining why, if something isn't clear all you have to do is to ask, though I am sure I described the problem with precision! – QuakeCore Jul 30 '15 at 08:22
  • ".. edit those documents using ms word 2013" – is that even an option then? (Note that the "editing permissions" as defined by Adobe only work if the end user happens to use a tool that actually respects those permissions.) – Jongware Jul 30 '15 at 09:14
  • @Jongware so your basically saying that even if my generated PDF correctly defined the permissions, a tool can still violate those permissions ? – QuakeCore Jul 30 '15 at 09:38
  • [Well yeah](http://superuser.com/questions/216616/does-pdftk-respect-pdf-security-flags). This [Acrobat thread](https://answers.acrobatusers.com/linux-appears-ignore-pdf-usage-restrictions-q241707.aspx) suggests to "[c]omplain to the makers of the tools that ignore these settings". At least one toolchain I know of defaults to respecting the permissions but has a boolean flag to enable it anyways. – Jongware Jul 30 '15 at 10:34
  • ... found it. Read [this iText answer](http://stackoverflow.com/a/27876840/2564301) - it contains lots of additional useful information. – Jongware Jul 30 '15 at 12:29

1 Answers1

0

Tried this? This if from the documentation by the way:

AllowModify

public static final int AllowModify

    Document access permission (bit 4, value = 8).
    Modify the contents of the document by operations other than those controlled by bits 6, 9, and 11.

    See Also:
        PD4ML.setPermissions(String, int, boolean), Constant Field Values

Also you may want to do:

pd4ml.setPermissions("", 0xffffffff ^ PD4Constants.AllowModify, false);

to disable the modification.

More information here: http://pd4ml.com/cookbook/pd4ml_pdf_security.htm

ap0calypt1c
  • 481
  • 4
  • 10
  • `PD4ML.setPermissions("a",PD4Constants.AllowModify , false);`, that's how I used it, but I am not sure if the usage was right, – QuakeCore Jul 30 '15 at 08:43
  • 2
    Look at this maybe: http://pd4ml.com/cookbook/pd4ml_pdf_security.htm What you have done seems the opposite of what you want. Basically you enabled it for edit ;) – ap0calypt1c Jul 30 '15 at 08:48
  • very useful link bro, thanks, but the documents are still editable :( – QuakeCore Jul 30 '15 at 09:15