Problems with setting rights (SetEncryption) in pdf

We are having problems using the product. Some features in iText 5.4.3 don't seem to work well? Please, can someone tell us how to solve this?

We will change src.pdf to dest.pdf as follows:

Function CreateFlattedPdf(ByRef originalPdf As Byte()) As Byte() Dim retValue As Byte() = Nothing Dim originalPdfReader As PdfReader = New PdfReader(originalPdf) Dim pdfKopie As MemoryStream = New MemoryStream() Dim pdfKopieStamper As PdfStamper = New PdfStamper(originalPdfReader, pdfKopie) pdfKopieStamper.SetEncryption(False, userPassword, ownerPassword, _ PdfWriter.ALLOW_ASSEMBLY _ Or PdfWriter.ALLOW_COPY _ Or PdfWriter.ALLOW_DEGRADED_PRINTING _ Or PdfWriter.ALLOW_FILL_IN _ Or PdfWriter.ALLOW_MODIFY_ANNOTATIONS _ Or PdfWriter.ALLOW_MODIFY_CONTENTS _ Or PdfWriter.ALLOW_PRINTING _ Or PdfWriter.ALLOW_SCREENREADERS _ ) ' Entferne die Signaturinformationen aus dem original Pdf-Dokument pdfKopieStamper.FormFlattening = True pdfKopieStamper.Close() ' Schreibe den Inhalt der geflatteten Kopie in die Antwort retValue = pdfKopie.ToArray() ' Schließe die Bearbeitung des Dokumentes ab pdfKopie.Close() originalPdfReader.Close() Return retValue End Function 

In addition, we put all possible rights to the text i. As a result, we get a PDF file in which deleting pages (deleting pages) and arranging documents (collecting documents) is not allowed ?!

My questions:

  • Is this iText incorrect behavior, or can this parameter be altered altogether with iText? If so, how (example code)?
  • Can I set these rights without a password? So far, we have only seen features for installation permissions always combined with user and owner passwords.

Thanks for your help in advance!

Ingo

+2
source share
1 answer

Observations

The permission tab that the OP sees actually shows some missing permissions:

screen shot showing the OP's PDF viewer's permission tab for dest.pdf

Verifying the permissions of the OP result file using Adobe Acrobat, however, there is another result:

screen shot showing Adobe Acrobat's permission tab for dest.pdf

Just smoothing the OP source file (without encrypting it at all!) Gets this file , for which Adobe Acrobat even shows these permissions:

screen shot showing Adobe Acrobat's permission tab for a merely flattened file

Explanation

This is the behavior of Adobe Reader, the PDF viewer that is most likely used by the OP: the permissions tab visible by the OP not only reflects what was or was not prohibited during encryption, but also the limitations of the PDF viewer itself.

It seems that the erroneous perception of OP, using encryption and setting permission bits, can be added to the capabilities compared to unencrypted files. In fact, it's the other way around: Encryption allows you to remove permissions compared to what is allowed for an unencrypted document. By using some of the allowed ALLOW_ * bits, you remove permissions. You get the maximum number of permissions by simply not encrypting the document.

In addition to the permissions of an unencrypted document, a particular PDF viewer may require additional usage rights, which vary by viewer. Such readers in PDF format (primarily Acrobat Reader) are usually quite inexpensive or free, but they do not offer full functionality if the corresponding document does not have the appropriate usage rights.

Use rights can be added with the use rights signatures. The use of such signatures of rights of use typically requires software or services provided by the manufacturer of this PDF viewer.

To add usage rights for Adobe Reader, for example, you can use Adobe Acrobat or some Adobe Lifecycle services.

In this way,

The answers

As a result, we get a PDF file in which page deletion (page deletion) and document layout (document compilation) are not allowed

No. As you can see above, your dest.pdf only prohibits page extraction, and as soon as you stop encryption, even that is allowed.

1 - is iText behaving incorrectly, or is it possible to change this parameter altogether using iText? If so, how (example code)?

This is not a bad iText behavior, this is the behavior of Adobe Reader. Adobe Reader limits its capabilities in general and only removes restrictions on documents with usage rights. These usage rights may only apply to Adobe software.

2 Can these rights be set without a password? So far, we have only seen features for installation permissions always combined with user and owner passwords.

Using encryption is actually counterproductive because it can only be used to remove permissions, not to add them.

Resources

Additional information about the problem obtained from the parallel entry on the itext-questions mailing list :

  • sample source file illustrating src.pdf problem
  • corresponding result file generated by op dest.pdf code
  • Screenshot of the tab for allowing viewing PDF of the OP file for dest.pdf file:

screen shot showing the OP's PDF viewer's permission tab for dest.pdf

+2
source

All Articles