Password Protecting a PDF

This Forum is for the use of Clarion For Windows - Software Developers requiring help and assistance for Tracker Software's PDF-Tools SDK of Library DLL functions(only) - Please use the PDF-XChange Drivers API SDK Forum for assistance with all PDF Print Driver related topics.

Moderators: Tracker Support, TrackerSupp-Daniel, Chris - Tracker Supp, Vasyl-Tracker Dev Team, Sean - Tracker, Tracker - Clarion Support, John - Tracker Supp, Tracker Supp-Stefan, Ivan - Tracker Software, Support Staff, moderators

Post Reply
Posts: 15
Joined: Fri Nov 18, 2005 4:57 pm

Password Protecting a PDF

Post by mrknowles » Thu Nov 07, 2013 10:17 pm

I've been using PDF-Tools for a long time, but never created a PDF with password protection. I need to password protect a paycheck voucher to be emailed to an employee. I have an unprotected PDF sitting on the disk, so I want to make a password protected copy of it. Here is my code:

PDF1 &= NEW(PDFManagerClass)
PDF1.ReadDocument(CLIP(AppDataFolder)&'\ASystems\Voucher #'&CLIP(GLT:CheckNo)&'TEMP'&'.pdf')
!Create a pdf just like it, but with a password.
PDF2 &= NEW(PDFManagerClass)
PDF2.Merge(PDF1, -1, 1, 1)
PDF2.WriteDocument(CLIP(AppDataFolder)&'\ASystems\Voucher #'&CLIP(GLT:CheckNo)&'.pdf')
REMOVE(CLIP(AppDataFolder)&'\ASystems\Voucher #'&CLIP(GLT:CheckNo)&'TEMP'&'.pdf')

When I compile, it creates the new PDF properly, but I can double-click on it in Windows Explorer and it opens without asking for a password. What am I doing wrong?

Mark Knowles

Tracker - Clarion Support
Site Admin
Posts: 1412
Joined: Wed Jun 30, 2004 4:45 pm
Location: Maryland, USA

Re: Password Protecting a PDF

Post by Tracker - Clarion Support » Thu Nov 07, 2013 11:12 pm

Hi Mark!

You only need the PDF1 class instance. Read "Document A.pdf," make changes, and then write to "Document B.pdf" if you want to preserve the original PDF.

You don't need an owner password at all. You can restrict access (such as printing, saving a copy et al.) using only a user password.

If you want to guard against tampering with the contents of the PDF you can also apply a digital signature. After the digisig is aplied, any changing of the PDF contents will invalidate the digisig and you Viewer should report that when it opens the tampered file.
Craig Ransom
Tracker Software - Clarion Support

Post Reply

Return to “PDF-Tools SDK (DLL Libraries Only) - Clarion For Windows Developers Only Please”