Showing posts with label PDF. Show all posts
Showing posts with label PDF. Show all posts

Wednesday, November 8, 2017

Shrink PDF Files in OS X and Control Image Quality

This guide is using information from here and providing clearer instructions and a Automator script to compress many at once.
  • Go here and click the green Clone or download button, then select Download ZIP.
  • Go to Downloads on your computer and rename the downloaded folder to Filters.
  • Make a new Finder window (Command+n) and then hold Option while clicking Go -> Library in the menu.
  • Drag the Filters folder with he files you downloaded into this new Library folder.
  • Download this program to your Applications folder or Desktop.
  • Now you can just all your PDF's files at once and drop them onto the application and it will compress them and save the compressed versions to your desktop.

Monday, February 8, 2010

Creating Acrobat Digital Signatures with a Root CA for Validation

Recently I was looking into using Adobe PDF Signing. This feature requires that each user have a digital certificate for each user. The problem is that creating the default signatures in Acrobat then every certificate to be imported on every other computer. That is to set up 10 users to all properly authenticate signatures you would have to import 10 signatures onto 10 computers witch becomes prohibitively complex.

There is another option. If the users certificates are all signed with a single CA(Certificate Authority) then only the CA needs to get imported to get all the certificate validation working. This is the approach I used but it is not internally supported by Acrobat and requires a Linux box to create the certificates. This guide will show you how to create a CA and signed digital certificates for your users. Then you simply import the single CA into each computer along with the actual users certificate.

Requirements:
  • OpenSSL is required to do most of the work.
  • Acrobat Reader is all that is required on the user computers.
  • One copy of Acrobat Standard is needed to enable digital Digital Rights management on PDF files.

Creating the Certificate Authority:
Run the following command to generate new CA under the current directory. You need to make sure this is in a secure path.
/usr/share/ssl/misc/CA.pl -newca
The password prompt is the CA password and is needed by the administrator when signing new certificates. The rest of the prompts create the CA identification and signature and can not be changed once set. Once finished the demoCA directory can be moved and renamed as necessary.

Once done you need to edit the /etc/ssl/openssl.cnf configuration file and update the CA_default.dir variable.
[ CA_default ]
dir = /root/keys/CompanyCA

Create an acrobat.cnf configuration for creating user certificates.
echo keyUsage=digitalSignature, dataEncipherment > acrobat.cnf
echo 1.2.840.113583.1.1.10=DER:05:00 >> acrobat.cnf

Next you probably want to extend the CA expiration date beyond one year. The following command will extend it to ten years.
openssl x509 -in cacert.pem -days 3650 -signkey ./private/cakey.pem -out cacert.pem

Finally the cacert.pem to a shared location and rename it to end with a .cer file extension so that the clients can import it. This is the public CA certificate used for validating certificates.


Create a Users Digital Certificate:
Create the new users certificate. You will be prompted to enter the end users password that they will type to sign documents.
/usr/share/ssl/misc/CA.pl -newcert

Now run the next command to sign the generated certificate with the CA. You will be prompted for the CA password.
openssl x509 -in newcert.pem -CA cacert.pem -CAkey private/cakey.pem -CAcreateserial -out newcert.pem -days 3650 -clrext -extfile acrobat.cnf

Finally run the following command to export this certificate as a PKCS12 package witch Acrobat can import.
cat newkey.pem newcert.pem  | openssl pkcs12 -export > username.pfx

You can now copy this file out to the same shared location at the CA. It is password protected and the certificates can be extracted from it in the future so a backup of the generated new*.pem files is not needed.

To extract the certificate and keys you can run the flowing commands.
openssl pkcs12 -in username.pfx -nokeys -out newcert.pem
openssl pkcs12 -in username.pfx -nocert -out newkey.pem


Import the Certificate Authority and Users Digital Certificate:
On any computers that need to be able to validate signatures all you need to do is import the CA file. To do so simply open up Acrobat and go to Document->Manage Trust Identities. Then browse for the *.cer CA file and import it. After importing you need to select the certificate, select Trust, and check the Use this Certificate as a Trusted Root option.

To enable a user to sign documents on a computers you need to do the following steps. Open up Acrobat and go to Document->Security Settings. Then click Add ID and browse for the proper users *.pfx file. You will need to enter the users password once to install the certificate but users will still need to enter the password when signing documents. These certificates are still password protected so multiple signatures can be loaded onto the same computer without issue.

Friday, January 29, 2010

Print to PDF from the Linux Terminal

A while back I had to set up a system for printing reports to PDF files automatically. IE: I needed a script to do the conversion, retrieve the new file, fix the orientation, and return the new filename. Here is the script and the details and the requirements.

Prerequisites:
  • CUPS-PDF: This package provides a PDF printer that we can print to using lp.
  • TexLive: This is a large project with many tools and has a large footprint but it is necessary for possessing landscape jobs. The exact problem is that jobs printed in landscape will be miss oriented when viewed and this allows us to correct that problem.
  • pdfjam: The project listed but does not need to be installed, rather a custom version of the pdf90 script included in this project is needed. Specifically the script is customized to rotate the page counter-clockwise.
Files:
  • printpdf: This is the main script and can be called from any external tools.
  • pdf90minus: This is the modified version of pdf90 from pdfjam that rotates the pages of a PDF counter-clockwise.
  • texlive.profile: This is a installer configuration for TexLive with just the necessary components selected.
Configuration:

Install CUPS-PDF and configure a printer for it. To configure the printer you can use the CUPS web interface or add the following lines manually.
/etc/cups/printers.conf
<printer pdf="">
Info PDF Writer for CUPS
Location PDF Backend /usr/lib64/cups/backend/pdf-writer
DeviceURI pdf-writer:/tmp/
State Idle
Accepting Yes
JobSheets none none
QuotaPeriod 0
PageLimit 0
KLimit 0
</printer>

Install TexLive. To install the minimal required components should download the installer and the profile and extract them to the same location. then run the following command from that folder.
sudo ./install-tl −profile texlive.profile

Save the pdf90minus and pdfprint scripts to the same location. You may wish to customize the working path /tmp but it must be the same in the printer configuration and printpdf script.

Usage:

You can now test the PDF printing, the job will print and the PDF will be generated at the same path with the same name as teh original file only suffixed with .pdf.
./printpdf myfile.txt [--rotate|-r] [--save|-s]

The --rotate option causes the job to be printed in landscape mode and then the PDF pages to be reoriented to display properly.
The --save option causes the source file to be left behind and not deleted once successful printed.
The script will block execution until the print job has finished and will then return passing the new filename to STDOUT.