Setting a different user password for each pdf

The Amyuni PDF Converter is our Printer Driver that enables you to convert any documents to PDF format. If you have any questions about installing and using the Amyuni PDF Converter please post them here.
Post Reply
justintime
Posts: 6
Joined: Wed Apr 27 2011

Setting a different user password for each pdf

Post by justintime »

I want to loop through a list of invoices, printing each separately to pdf and encrypt each one with a unique password for each vendor. Speed and efficiency are a concern as there are several hundred and I want to know the best way to accomplish this. It appears I need to repeatedly call SetUserPassword, SetOwnerPassword, SetPermissions and then SetDefaultConfigEx. I question why I am setting default Config each time with user password as it doesn't seem efficient to me. Is there a better way? I am printing each pdf doc and then sending via SendSmtpMailEx(). Thanks for your response in advance. :?
justintime
Posts: 6
Joined: Wed Apr 27 2011

Re: Setting a different user password for each pdf

Post by justintime »

I would like to add to this saying that how I intended this to work failed. All pdf's that were emailed out had the same user password assigned in the first one. Calling SetDefaultConfig or SetDefaultConfigEx after modifying the user password never changed them from the first time it was called in the loop. Each pdf document is destroyed after it is printed and sent out prior to the next one being created so I have no idea what went wrong with setting a new password with each pdf.
Devteam
Posts: 119
Joined: Fri Oct 14 2005
Location: Montreal
Contact:

Re: Setting a different user password for each pdf

Post by Devteam »

You are not specifying from which application the invoices are being printed. If you have full control over the application, mainly creating your own Device context (DC), you do not need to call SetDefaultConfigEx, instead use the CDICreateDC supplied by our SDK after changing the passwords. If you do not have control over the printing, you can generate the unencrypted PDF first, then call the Encrypt, Encrypt128 or Encrypt256 methods to encrypt the PDF before emailing it.

A quick note about SetDefaultConfigEx and why it is not working for you:
SetDefaultConfigEx changes the default configuration but does not notify running applications that the configuration has changed. So running applications will still have the previous configuration (DEVMODE) cached. To notify running applications, use SetDefaultConfig instead. But this is not recommended if you are printing a large number of documents because the call to SetDefaultConfig is time consuming.
Amyuni Development Team

Efficient and accurate conversion to PDF, XPS, PDF/A and more. Free trials at - https://www.amyuni.com
Post Reply