Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a password-protected PDF file frm VFP 2

Status
Not open for further replies.

torturedmind

Programmer
Jan 31, 2002
1,052
0
0
PH
One of our clients need to have a copy of a very simple report in PDF format. The report contains sensitive information so it needs to be password-protected. In reference to faq184-7355, how can I automate the process of adding a password to the PDF version of the report?

TIA

kilroy [knight]
philippines

"Once a king, always a king. But being a knight is more than enough."
 
I strongly recommend the free FoxyPreviewer (don't be fooled by its name, it's extremely powerful) to create PDF reports. You only need to add one line of code, and change one or two lines in your old code.

 
Hello Kilroy,

I recently had exactly the same requirement. I tried a few different solutions, and eventually settled on XFRX, from Eqeus ( It's very easy for creating PDFs, and no problem in password-protecting them.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
If you are using XFRX - which is also my favourite, you can follow the info on their website to password protect
the PDF output

PDF documents can be encrypted. To set the encryption on, call setPasswords method:
loSession.setPasswords(tcOwnerPassword, tcUserPassword)

The user password can be empty. If the owner password is empty, a random string will be generated as the password.
The owner can do anything with the document. The user permissions can be set using the setPermission method:
loSession.setPermissions(tlPrintDocument, tlModifyDocument, tlCopyTextAndGraphics, tlAddOrModifyAnnotations,;
tlFillFormFields, tlExtractTextAndGraphics, tlAssembleDocument, tlPrintDocumentInLow)

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Thank you all for the great suggestions. I'm also eyeing some freeware tools that I could use. CutePDF requires hacking the registry and thus needs admin rights to do so, which is not good for a client-end app. The other one is PDFtk (PDF Tool Kit) Server which is a command line utility. But I haven't tried it yet. I'll look into XFRX also and compare it with PDFtk and see how it go.

Again, thank you all. [orientalbow]

kilroy [knight]
philippines

"Once a king, always a king. But being a knight is more than enough."
 
FoxyPreviewer is also freeware. This is from the documentation on how to password protect a PDF report :

[URL unfurl="true" said:
https://foxypreviewer.codeplex.com/documentation[/URL]]
How to set a password to my PDF document?

You need to setup at least 3 properties: 'lPDFEncryptDocument = .T.' , 'cPdfMasterPassword = "YourPwd1", 'cPDFUserPassword = "YourPwd2" . To encrypt a document, you ALWAYS need to setup 2 different passwords! One for the "Master", and the other for the "User" passwords. Check the related properties in the documentation for more details.


DO FoxyPreviewer.app
_Screen.oFoxyPreviewer.lPDFEncryptDocument = .T.
_Screen.oFoxyPreviewer.cPDFUserPassword = "pwdmaster"
_Screen.oFoxyPreviewer.cPDFMasterPassword = "pwduser"
REPORT FORM (ADDBS(_Samples) + "SOLUTION\REPORTS\PERCENT.FRX") OBJECT TYPE 10 TO FILE "c:\Test1.pdf" PREVIEW
 
Let us know how you get on with your research, Kilroy.

XFRX isn't free, but you might well find it a good investment. As well as PDFs, it can do Word docs, Excel workbooks, and quite a lot more. I bought a copy several years ago, and have successfully used it on a number of different projects.

That said, XFRX isn't the only possibility. I've nothing against FoxyPreviewer. But keep in mind that both XFRX and FoxyPreviewer are VFP-specific, which might be an advantage or it might not. The likes of CutePDF are more general purpose.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
*!* To run this program you have to have "Winzip" and "Winzip command line add on" install on the computer
*!* Install in c:\winzip dir both

*!* I am getting ENCRYPTION.Key_code from database you can use any key want.

WAIT WINDOW "The Zip program requires three parameters" + CHR(13)+ "filename,filepath,dDate" TIMEOUT 60

cZipFile =(filepath+cZipfilename)

zipfile = "c:\winzip\wzzip E:\Apps\Chino\ARCHIVE\PF_"+DTOS(dDate)+".zip "+;
cZipFile +" -s"+ALLTRIM(ENCRYPTION.Key_code)+" -ycAES128 -m" && Production
RUN &zipfile


I hope this helps
 
ChinoKhan,

Welcome to the forum.

Your code shows how to create a ZIP file with a password. But what Kilroy wanted was to create a PDF with a password - quite a different animal. But perhaps someone else might find your solution useful.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
I've presented my superior three 3rd party software - FoxyPreviewer, PDFtk, and XFRX. It seems we're going to use FoxyPreviewer as he really liked it coming from the VFP community, besides being a freeware.

Again, thank you all for the help. [orientalbow]

kilroy [knight]
philippines

"Once a king, always a king. But being a knight is more than enough."
 
Hello all.

Using FoxyPreviewer, I've already made a sample program that sends a PDF file encrypted with password. The original purpose of this project is to make an unattended sending of different versions of a report to different key persons. My question is, is there a way to supress the "Email was sent." confirmation message? I can't seem to find it in the documentation.

Again, TIA.

kilroy [knight]
philippines

"Once a king, always a king. But being a knight is more than enough."
 
Hello all.

Well, I just had to make this happen myself. What I did is I modified the "SendEmailUsingCDO" procedure by making an additional parameter "lConfirmOff" which receives a logical value of .T. (silent) or .F. (with confirmation message). See the very small modifications below in blue font:

Code:
PROCEDURE SendEmailUsingCDO
	LPARAMETERS tcFile, [b][COLOR=blue]lConfirmOff[/color][/b]
	LOCAL loMail AS cdo2000
	m.loMail = CREATEOBJECT("Cdo2000")

	LOCAL loFP1
	loFP1 = This && _Screen.oFoxyPreviewer 
	loFP1.lQuietMode = .F.
	[b][COLOR=blue]loFP1.lSilent = IIF(VARTYPE(lConfirmOff) = "U", .F., lConfirmOff)[/color][/b]
	:
	[i]<other codes here>[/i]
	:
	RETURN loFP1.lEmailed
ENDPROC

Then I call the procedure like so:

Code:
WITH _SCREEN.oFoxyPreviewer
	:
	:
	[i]<other codes here>[/i]
	.SendEmailUsingCDO(attfile, [b][COLOR=blue].T.[/color][/b])	[i][COLOR=green]&& Silent (no confirmation message)[/color][/i]
ENDWITH

Works for me. I sure hope this will help others, too.

kilroy [knight]
philippines

"Once a king, always a king. But being a knight is more than enough."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top