Security while printing...

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
cmorant
Posts: 10
Joined: Fri Sep 27 2002

Security while printing...

Post by cmorant » Fri Sep 27 2002

What would be really cool would be that the printer driver could support the security mechanism WHILE printing.
Even cooler would be to be able to use the security plugin architecture so that one could write a custom plugin to enable all sorts of access rights/ encryption....

Just a wish to be added to the wish list.


:P

Dany
Amyuni Team
Posts: 113
Joined: Wed Sep 11 2002
Location: Montreal.
Contact:

Security while printing...

Post by Dany » Fri Sep 27 2002

Securing the document while priting is something provided by version 2.1 of the PDF Converter which will also support 128 bits encryption. Check out for the new version somewhere in November...

For the security plugins, we will keep this on our wish-list.

8)

cmorant
Posts: 10
Joined: Fri Sep 27 2002

Post by cmorant » Mon Sep 30 2002

Cool, now all I have to do is wait for 2.1
By the way, is there (and what is exactly) an API to encrypt a file when user from VB but as a DLL ?

Thanks

cmorant
Posts: 10
Joined: Fri Sep 27 2002

Post by cmorant » Mon Sep 30 2002

No need, thanks, found it...

Declare Function EncryptPDFDocument Lib "CDIntf" (ByVal Path As String, ByVal OwnerPWD As String, ByVal UserPWD As String, ByVal Params As Long) As Long

Kiefer
Posts: 25
Joined: Mon Sep 30 2002

Handshake with driver to prevent unauthorized use

Post by Kiefer » Mon Sep 30 2002

I agree about the security. Many of the COM and OCX controls that we purchase from other control developers force us to pass a password parameter before the control will work. This prevents unauthorized use of the control. I'd like to see this functionality.

Ramberg
Posts: 9
Joined: Tue Dec 10 2002
Location: Barcelona, Spain
Contact:

Re: Security while printing...

Post by Ramberg » Tue Dec 10 2002

Dany wrote:Securing the document while priting is something provided by version 2.1 of the PDF Converter which will also support 128 bits encryption. Check out for the new version somewhere in November...
For the security plugins, we will keep this on our wish-list.
8)


Hi,
we are evaluating using PDF Converter with Excel with a reporting tool that we have made (in VBA). One of the key requirements is to apply security to the document before it lands on the disk. I've been in contact with support and they recommended to convert(save the) file, open file, set security with .Encrypt, and save the file again, which is not what I want.
Thou, seeing the "undocumented"(?) EncryptPDFDocument which I found peeking in the DLL and in this forum, it seem to be what I need, but I don't know what the 1st and 4th parameters are in this function.

Is this function unsupported until 2.1? If so, when will 2.1 be released? Is there any other solution to the action I want to perform in the meantime?
Thanks.
Kenneth Ramberg
Picis RD/Barcelona/Spain.

Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Post by Joan » Wed Dec 11 2002

Hello Ramberg,

We have released version 2.08 now, and version 2.1 will be released soon maybe in january. 128 bits encryption will be supported by version 2.1, but EncryptPDFDocument is supported in version 2.08.

Please find here a VB sample on using EncryptPDFDocument.

------------------------------- sample starts here ------------------------

Private Sub Command12_Click()

' This function adds a password to the pdf file using the function
' EncryptPDFDocument(FileName,ownerpass, userpass, rights)
' of the DLL interface of CDintf


' initialize PDF printer and set it as default
pdf1 = DriverInit(PrinterName) ' this is for the standard version
' pdf1 = pdfdriverinit("My PDF Printer") ' this adds a printer named My PDF Printer

If pdf1 = 0 Then
MsgBox "Cannot initialize PDF printer"
Exit Sub
End If

SetDefaultPrinter pdf1

SetDefaultFileName pdf1, "C:\Test.pdf"

SetFileNameOptions pdf1, 1+ 2 + 256 ' 1 for NoPrompt and 2 for UseFileName and 256 for the Encryption.

EncryptPDFDocument pdf1, "owner", "user", -64


' draw some text
Printer.CurrentX = 100
Printer.CurrentY = 200
Printer.Print "This is an ecrypted pdf"


Printer.EndDoc

DriverEnd pdf1 ' this will remove the printer if it was installed with PDFDriverInit

End Sub

---------------------------------- sample ends ------------------------------

Hope this helps.

Ramberg
Posts: 9
Joined: Tue Dec 10 2002
Location: Barcelona, Spain
Contact:

Post by Ramberg » Wed Dec 11 2002

Thanks Juan for a quick answer.

By changing the SetFileNameOprions and adding EncryptPDFDocument as explained, yield no difference to the documents. Both documents were the same, a bit comparing the files, only creationdate appear differently.

Secondly, the only available evaluation .dll is 2.06 and I have no access to the upgrade to 2.08 as we still are evaluating. Does this make any difference on this functionality?

Maybe I am as well barking up the wrong tree, as I want more correctly, to set the security of the PDF document, To password protect the ability to open the document, and/OR password protect the ability to Change the document (or make it unchangeable w/o password or No Printing etc) (ref. Standard Security in Acrobat).

Below is my code if it is to any help.
Thanks again for your prompt answer!
Kenneth

Code: Select all

 (Excel VBA)
Sub MyPDFMacro()
    pdf = DriverInit("Amyuni PDF Converter")
    If pdf = 0 Then
        MsgBox "Cannot initialize PDF printer"
        Exit Sub
    End If
    SetResolution pdf, 1200
    SetDefaultConfig pdf
    SetDefaultPrinter pdf ' set this printer as default
    SetDefaultFileName pdf, "c:\ztest" & Format(Now(), "yyyymmddhhmss") & ".pdf"
    SetFileNameOptions pdf, NoPrompt + UseFileName + ProtectPDF
    
    EncryptPDFDocument pdf, "user", "pwd", -64
    
    ActiveWorkbook.PrintOut
    DriverEnd pdf
End Sub

Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Post by Joan » Fri Dec 13 2002

Hi Remberg,

The demo version 2.08 is currently online. Please feel free to dowloand the Professional edition at: http://www.amyuni.com/en/products/pdf_c ... /demo.html

Please reboot your system after installing the new demo.

I tried the code I posted from VB 6 and it worked. Please try the new professional demo. Encryption is available in the professional edition only.

Hope this helps :)

Ramberg
Posts: 9
Joined: Tue Dec 10 2002
Location: Barcelona, Spain
Contact:

Post by Ramberg » Fri Dec 13 2002

Hi again Joan.
Downloaded, installed and rebooted...

At first, SetResolution pdf, 1200 gave me an errormessage "Cannot set page margins" (or something similar). I changed it to 600 and it gave me no errormessage. Afterwards I did a new install "AmyuniTest2" -s and printed to it and 1200 worked fine... :wink:

As code in my previous post, things works fine, file is created on disk, BUT, I get suddenly a dialogbox with errormessage "Encryption failed" (no more nor less). It appears just after all pages has been has been processed/created (ActiveWorkbook.PrintOut process all pages fine it seem). File is on disk, uncrypted (ouch).
So... What can cause this?
AND, IMHO, if you want a file crypted and it was unable to do so, last thing you want is to see it saved uncrypted, better not saved at all.

Secondly, as I am running the whole process as a service, dialogboxes are bad, as there are of course, no user nor UI to close it... It is a known problem for us, we do have a timeout to kill the process, but I would prefer that all functions give us an errornumber or log, and no UI.

Thirdly, Re: security question in the previous post. I didn't get a clear understand of how I can set the standard securitylevels (No change, no print etc) Can I use the parameters as explained in the Function .Encrypt in the Common Driver Interface document (page 24) for the EncryptPDFDocument function? (documentation shipped with 2.08 is labeled 2.06 and EncryptPDFDocument is not explained.)

Sorry for being a pain, you product seem really cool and you are * this close on a sale, but I need to have this clear.

Thanks again/Kenneth.

Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Post by Joan » Fri Dec 13 2002

Concerning the first issue, I guess the printer wasn't installed properly on the first try.

Concerning the second issue, please send a request to support@amyuni.com they will open a case and try to reproduce this. Please send them the code you are using along with detailed test case to reproduce this issue.

And concerning the Encryption, please check the manual "Common Driver Interface.pdf" the section about the Encrypt function, the same values are used with "EncryptPDFDocument". -64 will not enable the user to make any changes or print the pdf file.

Have a nice day :)

Ramberg
Posts: 9
Joined: Tue Dec 10 2002
Location: Barcelona, Spain
Contact:

Post by Ramberg » Tue Jan 14 2003

Hello again.
I am happy to tell that we decided to buy your product :D (although I wanted the upcoming v2.1, I can manage with 2.08a) and I am in process of incorporate it with our product! But I encountered some problem as what I wrote earlier in this thread:
As code in my previous post, things works fine, file is created on disk, BUT, I get suddenly a dialogbox with errormessage "Encryption failed" (no more nor less). It appears just after all pages has been has been processed/created (ActiveWorkbook.PrintOut process all pages fine it seem). File is on disk, uncrypted (ouch).
So... What can cause this?
AND, IMHO, if you want a file crypted and it was unable to do so, last thing you want is to see it saved uncrypted, better not saved at all.
Joan answered:
Concerning the second issue, please send a request to support@amyuni.com they will open a case and try to reproduce this. Please send them the code you are using along with detailed test case to reproduce this issue.

Now, I never emailed the problem, as it "disappeared" after some playing around, until I received the registered version... Then I got this dialogbox back, but before I even got to the point to email you about the details I think I have found the answer, which I would consider as a bug.

Try this:
  • Install Amyuni printer and let have default "Letter" format (don't touch it)
    Have something like EncryptPDFDocument PDF, "ownerpwd","",-64 in the code
    Create/Print your document as "A4" format
    Here the "Encryption Failed" Error dialogbox pops up
    Now change Printerdriver to be the same as your desired format
    No error message
    Change printerdriver again to letter and no problem.
    So I assume that you MUST set a default format when initializing the printer and using encryption
Which leads me into 2nd issue observed...
  • Let's use EncryptPDFDocument PDF, "OwnerPWD","UserPWD",-64+4 and create the document (Excel, ActiveWorkbook.Printout)
    I open the saved document in Acrobat 5
    I go to File | Document Security | Change Settings
    Here all checkboxes are checked.
    Then uncheck all the boxes, click OK and Close, and you can perfectly edit and save document.
    Both User and Master passwords appear empty...
    Even the Enable printing(+4) set in the code, The "No Printing" is checked.
    Either I misunderstand this functionality, or else this seem very wrong...
    The declaration I have is: Declare Function EncryptPDFDocument Lib "CDIntf" (ByVal Path As String, ByVal OwnerPWD As String, ByVal UserPWD As String, ByVal Params As Long) As Long
Please advise!
Thanks in Advance!
Kenneth.

PS.AND I still think that you should not have any(or else optional) dialogbox for errors in this Professional Developer version, as this will hang any NT service including your product as my service do not have an UI. Error-codes and error-logs are fine.

cmorant
Posts: 10
Joined: Fri Sep 27 2002

Post by cmorant » Tue Feb 11 2003

Well Kenneth, I agree with EVERYTHING you wrote.

Could you tell me what I should do to make encryption work ?

because your
Create/Print your document as "A4" format
Here the "Encryption Failed" Error dialogbox pops up
Now change Printerdriver to be the same as your desired format
stuff, well I don't see how you do this with the DLL API...

Does somebody know ?

P.S. I REALLY want to be able to trap all error messages !

Cheers,

Christian

Ramberg
Posts: 9
Joined: Tue Dec 10 2002
Location: Barcelona, Spain
Contact:

Post by Ramberg » Tue Feb 11 2003

Hi Christian.

I actually had to apply an undesired workaround.
Instead of the on-the-fly encryption I hoped to use, I;
1. Disabled all encryption coding by not using the mentioned function.
2. Stored the PDF uncrypted
3. Open the PDF as a document
4. Applied encryption, security and some titles
5. Save the document again.

Due to software processes and threads, we needed to rearrange some other code not to trigger on the first saved file.

For now, this is the way it is working, not ideal, but I already spent too much time figuring this out.

Re: my quote
I think I meant that you need manually to go to the printer and set the properties there.
This is something else that I have chosen to do, for now. Just keep the printer open, as we didn't have the time to look at the performance on create and destroy the printer on-the-fly.

Putting this aside, coding was done, and the PDFConverter performed quite fine during a 2 week test we had, ending last week. It will now go to an on-site beta testing, probably next week, and I am excited to hear the outcome.

All the best
Kenneth.

Jose
Amyuni Team
Posts: 551
Joined: Tue Oct 01 2002
Contact:

Post by Jose » Fri Feb 14 2003

Hi,

I suspect the issue encountered by Ramberg may be related to the code snippet being used. I have tested this feature using the code below and it function properly.

Private Declare Function EncryptPDFDocument Lib "CDIntf" (ByVal FileName As String, ByVal Owner As String, ByVal User As String, ByVal Permissions As Long) As Boolean

Private Sub cmdEncrypt_Click()
' This function adds a password to the PDF file using the function
' EncryptPDFDocument(FileName,ownerpass, userpass, rights)
' of the DLL interface of CDintf


' Initialize PDF printer and set it as default
pdf1 = DriverInit(PrinterName) ' this is for the standard version
' pdf1 = pdfdriverinit("My PDF Printer") ' this adds a printer named My PDF Printer

If pdf1 = 0 Then
MsgBox "Cannot initialize PDF printer"
Exit Sub
End If

SetDefaultPrinter pdf1

SetDefaultFileName pdf1, "C:\TestEncrypt.pdf"

SetFileNameOptions pdf1, 1 + 2 ' 1 for NoPrompt and 2 for UseFileName


' draw some text
Printer.CurrentX = 100
Printer.CurrentY = 200
Printer.Print "This is an encrypted pdf"


Printer.EndDoc

EncryptPDFDocument "C:\temp\TestEncrypt.pdf", "owner", "user", -64

DriverEnd pdf1 ' this will remove the printer if it was installed with
PDFDriverInit
End Sub

Hope this helps.

Post Reply