Two Pilots™    Home  |  Navigation  |  Site Map  |  Products  |  Download  |  Prices  |  For Partners  |  Support


All forums · Statistics · Search ·

Two Pilots forum / For software developers / ReadOnly PDF File
Author Message
Anonymous
# Posted: 18 Mar 2005 10:05


Hi,

I would like to create PDF files that have a read-only property (it can't modify such as add text box and anything by using Abobe writer or another software).

Please let me know the method to do that

Thanks

Jan

Stanislav
# Posted: 18 Mar 2005 16:26


Hi,

By using ProtectionOptions_coModifyStructure property of the PDF document,
you can do this. (i assume that you are using PDF Creator Pilot library)

Thank you very much !

Best regards,
Stanislav

Anonymous
# Posted: 21 Mar 2005 04:23


Stanislav,Thank you so much

Jan

Anonymous
# Posted: 21 Mar 2005 04:38


Dear Stanislav,

I'm using Visual C++ to create DLL.
I can't find that property(ProtectionOptions_coModifyStructure) but I already import PDFCreatorPilot2.tlb.What can I do?

Thanks
Jan

Stanislav
# Posted: 21 Mar 2005 18:52


Hello,

In VC you need to import PDFCreatorPilot2.dll,
(of course, if you want to use it directly). If you are using MFC, then classwizard should add all required statements in .h file of the library definition.

Here is the sample code for using ProtectionOptions_coModifyStructure with PDFCreatorPilot2.dll import :

#import "PDFCreatorPilot2.dll"
using namespace PDFCreatorPilot2;

int _tmain(int argc, _TCHAR* argv[])
{
// initialize OLE
HRESULT hr = CoInitialize(NULL);

// check for errors
if (FAILED(hr)) {
MessageBox(0,"OLE initialization errp","error",MB_OK);
return -1;
};
// declare PDF Creator Pilot object
IpiPDFDocument2* PDF = NULL;
CLSID clsid;

// get inuque ID for PDF Creator Pilot
hr = CLSIDFromProgID(OLESTR("PDFCreatorPilot2.piPDFDocument"), &clsid);
// check for errors
if (FAILED(hr)) {
MessageBox(0,"Can't get CLSID for PDF Creator Pilot","error",MB_OK);
goto Uninit;
};
// create PDF Creator Pilot object
hr = CoCreateInstance(clsid, NULL, CLSCTX_ALL,__uuidof(IpiPDFDocument2), (LPVOID*)&PDF);
// check for errors
if (FAILED(hr)) {
MessageBox(0,"Can't create PDF Creator Pilot object","error",MB_OK);
goto Uninit;
};
// initialize PDF Engine
PDF->StartEngine("demo","demo");
// set PDF ouput filename
PDF->FileName = "HelloPDF.PDF";
PDF->AutoLaunch = true; // auto-open generated pdf document

//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
PDF->ProtectionOptions_coModifyStructure = false;
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

// start document generation
PDF->BeginDoc();
// draw "HELLO, PDF" message on the current PDF page
// set active font name, parameters, size and charset
PDF->PDFPAGE_SetActiveFont("Verdana", true, false, false, false, 14, charsetANSI_CHARSET);
// draw text
PDF->PDFPAGE_TextOut(10, 20, 0, "HELLO, PDF!");
// finalize document generation
PDF->EndDoc();
// disconnect from library
PDF->Release();
// uninitialize OLE libraries
Uninit:
CoUninitialize();

return 0;
}

Thank you very much !

Best regards,
Stanislav

Anonymous
# Posted: 22 Mar 2005 15:45


Dear Stanislav,

I try to use your code but I can still modify "HelloPDF.PDF". I can add text or hilight the text in the file and can save it too ! Please let me know.

thanks
Jan

Stanislav
# Posted: 23 Mar 2005 16:50


Dear Jan,

First of all, you need to switch ProtectionEnabled document property to "true"
You may also setup password for document owner.

Best regards,
Stanislav

Anonymous
# Posted: 24 Mar 2005 06:28


Dear Stanislav

Thank you very much for your supporting

Best regards,
Jan

NYR2000
Member
# Posted: 7 May 2008 18:26


Hello,

I am using VB.Net.
Here is my code to try to make it read-only ( no structure modifications, no form filling, no data modification, no changing check boxes, etc.

By reading messages above, I understood that the following script is required.

-------------------------------------------------- -------------------------------------
Dim PDF As PDFCreatorPilot3Lib.PDFDocument3
PDF = New PDFCreatorPilot3Lib.PDFDocument3
PDF.StartEngine("demo", "demo")
PDF.OwnerPassword = "123"

PDF.DocumentInfo_Title = "test"
PDF.FileName = "test.pdf"
PDF.ProtectionEnabled = True
PDF.ProtectionKeyLength = PDFCreatorPilot3Lib.TxCryptoKeyLength.ckl40
PDF.ProtectionOptions_coModifyStructure = True
PDF.ProtectionOptions_coModifyAnnotation = True
PDF.AutoLaunch = True

PDF.BeginDoc()

PDF.PDFPAGE_CreateControl_Checkbox("chk1", 120, 60, 180, 70)
PDF.PDFANNOTATION_Caption = "Check box 1"
PDF.PDFANNOTATION_Checked = True

PDF.EndDoc()
-------------------------------------------------- -------------------------------------

However, I am still able to modify it. When I look at page properties after opening PDF file, the only one that is set to "Not Allowed" is "Page Extraction". All other items are set to "Allowed".

Thank you for your help in advance.

NYR2000
Member
# Posted: 7 May 2008 18:29


By the way, it happens when I set both coModifyStructure and coModifyAnnotation to False as well. Not sure which one disables access yet, because in help it does not specifically mention which one does what, so I tried both True and False and it didn't work.

Vitaliy Shibaev
Member
# Posted: 11 May 2008 04:20


Hi,

In current implementation you can't create protected document without user or owner password. So you need use i.e. PDF.UserPassword = "user" for activate protection options.

Best regards,
Vitaliy Shibaev
Two Pilots

NYR2000
Member
# Posted: 12 May 2008 12:20


Vitaly, thank you, it did work.
Yan

mvf
Member
# Posted: 11 Sep 2008 03:46


Please take a look at these examples of how the PDF document can be protected.

For interface IPDFCreator4
http://www.colorpilot.com/pdfcreatorpilotmanual/IP DFDocument4/UserPassword.html

For interface IPDFCreator3
http://www.colorpilot.com/pdfcreatorpilotmanual/Pr otectionOptions_coAssembly.html

mvf
Member
# Posted: 16 Sep 2008 22:35


What version of PDF Creator Pilot do you use?
PDFCreatorPilot2.tlb means version 2.x that is not supported any more. Please download the latest version from our site, this version allows you to use old (IPDFDocument3) and new (IPDFDocument4) interfaces.

 

 

Powered by miniBB 2.0 RC7 © 2001-2004 Page creation time (sec.): 0.014

 

Page top