Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Greetings. Superb module and I'm using it to generate PDF with the mPDF library. I know it's possible to secure a document with a password with that library, but is there any way in the print module itself (UI or code) that allows this to be set?
Comment | File | Size | Author |
---|---|---|---|
#2 | adding-password-facility-to-mpdf-2351497-2.patch | 5.21 KB | zealfire |
Comments
Comment #1
zealfire CreditAttribution: zealfire commentedComment #2
zealfire CreditAttribution: zealfire commentedI am attaching a patch which allows users who are using mPDF as third party tool to create a password protected pdf and is also configurable.Please give your suggestions if you have any related to this.Please review
Thank you.
Comment #3
zealfire CreditAttribution: zealfire commentedChanging status.
Comment #4
Sutharsan CreditAttribution: Sutharsan commentedYou add a collapsed fieldset around a single field. This cluttering the form needlessly. On top of that you collapse the fieldset. What is there to hide? Don't use a fieldset here.
The variable does not use the module namespace. Only use 'print_pdf_* variable names.
Why use
isset()
and!= NULL
? Just give the variable a default value of an empty string and useif($pwd)
Is
$pwd
a good descriptive variable name?$password
is more explanatory.Don't include HTML inside t() unless unless there is no alternative. Place it outside the t(). It confuses translators.
I'm not fond of the "****". "Password is already set." is clear enough.
Just remove the password? Perhaps also give the user the opportunity to enter a new password.
Try to write positive sentences. For example: "Enter a password to protect the pdf document. Users will need to enter this password before they can read it's content."
Second sentence is not proper English.
My not use the default form validation function name?
I don't think you need to check for value
== '1'
.If the default is really NULL (see above), you can use
variable_del()
.Always end a file with an empty line. See https://www.drupal.org/coding-standards#indenting
This may not be in coding standards, but be consistent in empty lines. I always use one between functions.
It feels like this code is squeezed in. Use an empty line to separate parts of code that do different things. See it a the separations between paragraphs of text.
Start the 'paragraph' of code with explanation instead of short sentences in between.
You make assumptions about the use of the password (print and copy). Should this not be in the settings form?
Remove empty line?
Lines should have no trailing whitespace at the end. https://www.drupal.org/coding-standards#indenting