I'm using PowerBuilder9 and need help to protect pdf file, my code is using this:
.......
i_ole_pdf = create oleobject
i_ole_pdf.ConnectToNewObject( "cdintfEx.cdintfEx" )
i_ole_pdf.PDFDriverInit( "Amyuni PDF Converter" )
....
in the btn_convert_event....
adw_dw_1.Modify( 'Datawindow.Printer="Amyuni PDF Converter"' )
ls_modify = "DataWindow.Print.FileName=~'" + as_filename + "~'"
adw_dw_1.Modify( ls_modify )
....
i_ole_pdf.DefaultFileName = as_filename
i_ole_pdf.FileNameOptions = 1 + 2 + 100
...
TRY
i_ole_pdf.GetVersionInformation( ref ll_CDIntfMajor, ref ll_CDIntfMinor, ref ll_PrinterDriverMajor, ref ll_PrinterDriverMinor )
CATCH ...
END TRY
...
IF ll_CDIntfMajor >= 3 THEN
i_ole_pdf.EnablePrinter( "owner name", "registernumber" )
...
then trying to protect...
in the next sentence, give me an error: Name not found calling external object function... setlicensekey...
HERE GIVE ME AN ERROR...
i_ole_pdf.object.SetLicenseKey( "owner name", "registernumber" )
i_ole_pdf.EncryptPDFDocument( as_filename, '', 'userpass', -64 + 4 )
Please, anyone can help me writing the correct code example??
I need to resolve this matter urgently!!!
Thnks;
How to protect PDF file from updates
Re: How to protect PDF file from updates
Hello Fernando,
SetLicenseKey is not a method of the CDIntfEx object, it is a method of the Document object of CDIntf.
You need to create a Document object that calls SetLicenseKey
i_ole_pdfdoc = create oleobject
i_ole_pdfdoc.ConnectToNewObject( "cdintfEx.document" )
Then in your code you call:
i_ole_pdfdoc.object.SetLicenseKey( "owner name", "registernumber" )
i_ole_pdfdoc.object.OpenEx( as_filename)
i_ole_pdfdoc.EncryptPDFDocument( as_filename, '', 'userpass', -64 + 4 )
Please note that in you can encrypt a pdf file either while generating it or after it is gernerated. In the code you provided you are using the method that encrypts the file after it is generated and therefore you need to make sure that the pdf file is fully written to disc before trying to open it and encrypt it.
Hope this helps.
SetLicenseKey is not a method of the CDIntfEx object, it is a method of the Document object of CDIntf.
You need to create a Document object that calls SetLicenseKey
i_ole_pdfdoc = create oleobject
i_ole_pdfdoc.ConnectToNewObject( "cdintfEx.document" )
Then in your code you call:
i_ole_pdfdoc.object.SetLicenseKey( "owner name", "registernumber" )
i_ole_pdfdoc.object.OpenEx( as_filename)
i_ole_pdfdoc.EncryptPDFDocument( as_filename, '', 'userpass', -64 + 4 )
Please note that in you can encrypt a pdf file either while generating it or after it is gernerated. In the code you provided you are using the method that encrypts the file after it is generated and therefore you need to make sure that the pdf file is fully written to disc before trying to open it and encrypt it.
Hope this helps.
Custom Brand the Amyuni PDF Printer Driver http://www.amyuni.com/en/developer/branding/index.html
Amyuni PDF Converter tested for true PDF performance. View results - http://www.amyuni.com/benchmark
Amyuni PDF Converter tested for true PDF performance. View results - http://www.amyuni.com/benchmark
-
- Posts: 5
- Joined: Tue Jan 20 2009
Re: How to protect PDF file from updates
Tanks, still give me an error...
I use your suggestion code, and it partially works
only after this...
i_ole_pdfdoc.EncryptPDFDocument( as_filename, '', 'userpass', -64 + 4 )
give me an error again
Name not found calling external object function encryptpdfdocument
Please could you give me new orientation???
I use your suggestion code, and it partially works
only after this...
i_ole_pdfdoc.EncryptPDFDocument( as_filename, '', 'userpass', -64 + 4 )
give me an error again
Name not found calling external object function encryptpdfdocument
Please could you give me new orientation???
Re: How to protect PDF file from updates
Hello,
The owner password is mandatory you can not call the Encrypt function with an empty owner password.
The owner password is mandatory you can not call the Encrypt function with an empty owner password.
Custom Brand the Amyuni PDF Printer Driver http://www.amyuni.com/en/developer/branding/index.html
Amyuni PDF Converter tested for true PDF performance. View results - http://www.amyuni.com/benchmark
Amyuni PDF Converter tested for true PDF performance. View results - http://www.amyuni.com/benchmark
-
- Posts: 5
- Joined: Tue Jan 20 2009
Re: How to protect PDF file from updates +
Thanks, now It seems that is ok, but when I call the PDF document with Adobe reader and look after his properties I can see that the document is still without any protection;
I just debug my app, and seems like everything is ok!
using after writing the document:
i_ole_pdfdoc.SetLicenseKey( "Evaluation Version Developer Pro", "07EFCDAB0...." )
i_ole_pdfdoc.OpenEx( as_filename, '' )
i_ole_pdfdoc.Encrypt( 'fhhl53', 'fhhl', -64 )
and properties are:
Printing: Allowed
Document Assembly: Not Allowed
Content Copying or Extraction: Allowed
Content Extraction for Accessibility: Allowed
Comenting: Not Allowed
Filling of form fields: Allowed
Signing: Not Allowed
Creation of Template Pages: Not Allowed
Submitting Forms: Not Allowed
like any other PDF document
Please, can you tell me what can I do to fix this problem?
I just debug my app, and seems like everything is ok!
using after writing the document:
i_ole_pdfdoc.SetLicenseKey( "Evaluation Version Developer Pro", "07EFCDAB0...." )
i_ole_pdfdoc.OpenEx( as_filename, '' )
i_ole_pdfdoc.Encrypt( 'fhhl53', 'fhhl', -64 )
and properties are:
Printing: Allowed
Document Assembly: Not Allowed
Content Copying or Extraction: Allowed
Content Extraction for Accessibility: Allowed
Comenting: Not Allowed
Filling of form fields: Allowed
Signing: Not Allowed
Creation of Template Pages: Not Allowed
Submitting Forms: Not Allowed
like any other PDF document
Please, can you tell me what can I do to fix this problem?
Re: How to protect PDF file from updates
From what i see in your code, you are allowing printing this is why printing is allowed in what you sent.
From what you extracted from Adobe I can't tell if the file is encrypted or not.
If you open the PDF and click on File -> Document Properties -> Security, the "Security Model" should be set to 'password security'.
Please note that you can choose between 40bits and 128bits encryption algorithm.
If this doesn't help please send a sample document along with your sample code to support@amyuni.com out Technical Engineers will help you.
From what you extracted from Adobe I can't tell if the file is encrypted or not.
If you open the PDF and click on File -> Document Properties -> Security, the "Security Model" should be set to 'password security'.
Please note that you can choose between 40bits and 128bits encryption algorithm.
If this doesn't help please send a sample document along with your sample code to support@amyuni.com out Technical Engineers will help you.
Custom Brand the Amyuni PDF Printer Driver http://www.amyuni.com/en/developer/branding/index.html
Amyuni PDF Converter tested for true PDF performance. View results - http://www.amyuni.com/benchmark
Amyuni PDF Converter tested for true PDF performance. View results - http://www.amyuni.com/benchmark
Re: How to protect PDF file from updates
On a side note, how does Encryption relate to PDF/A creation?
From what I've read it looks like PDF/A documents don't have to use encryption to be valid, and my tests go in that same direction. That sounded new to me, but if the standards state it, there's no way to avoid it..
Can you confirm that when we use any kind of "restriction" (such as not allowing printing) we don't have to use the PDF/A options?
Thank you in advance!
From what I've read it looks like PDF/A documents don't have to use encryption to be valid, and my tests go in that same direction. That sounded new to me, but if the standards state it, there's no way to avoid it..
Can you confirm that when we use any kind of "restriction" (such as not allowing printing) we don't have to use the PDF/A options?
Thank you in advance!
Re: How to protect PDF file from updates
Hello
Encryption is not allowed when using PDF/A, if a document is encrypted, it cannot be PDF/A and vice versa. All “restrictions” such as printing, modifying, … require encryption, so a PDF/A document cannot be restricted.
Hope that helps?
David
Encryption is not allowed when using PDF/A, if a document is encrypted, it cannot be PDF/A and vice versa. All “restrictions” such as printing, modifying, … require encryption, so a PDF/A document cannot be restricted.
Hope that helps?
David