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


All forums · Statistics · Search ·

Two Pilots forum / For software developers / Printing does not get disabled.
Author Message
Siddharth
# Posted: 9 May 2007 00:45


Hi,

I have the following code which should disable printing, but it does not.
Can you tell me what the problem is ?
I am using the demo dll.

main()
{
//Initialization code

// start document generation
PDF->BeginDoc();

//Printer icon/option is not disabled by the following code
PDF->PutOwnerPassword ("owner");
PDF->PutProtectionEnabled (true);
PDF->PutProtectionOptions_coPrint (false);
PDF->PutProtectionOptions_coPrintHigh (false);


// finalize document generation
PDF->EndDoc();

// disconnect from library
PDF->Release();
}

Can you help me out ?

Regards,
Siddharth

Stanislav
Member
# Posted: 9 May 2007 02:45


Dear Siddharth,

Please put this code before BeginDoc():

PDF->PutProtectionEnabled (true);
PDF->PutOwnerPassword ("owner12"); // password should be at least 6 chars
PDF->PutProtectionOptions_coPrint (false);
PDF->PutProtectionOptions_coPrintHigh (false);

Best regards,
Stanislav
Two Pilots
www.colorpilot.com

Siddharth
# Posted: 9 May 2007 03:49


Hi Stanislav,

Thanks for the quick reply. But the problem still persistes. I put the code before BeginDoc and changed the owner password to more than 6 characteres but still doesnt disable printing.

During this process, I found a weird thing. If I call the function PutProtectionOptions_coPrint twice, printing gets disabled.

i.e.
PDF->PutProtectionEnabled (true);
PDF->PutOwnerPassword ("owner1234");
PDF->PutProtectionOptions_coPrint (false);
PDF->PutProtectionOptions_coPrint (false); // calling it twice works

Detailed Code:

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

// check for errors
if (FAILED(hr)) {
MessageBox(0,"OLE initialization error","error",MB_OK);
return -1;
};

// declare PDF Creator Pilot object
IPDFDocument3* PDF = NULL;
CLSID clsid;

// get inuque ID for PDF Creator Pilot
hr = CLSIDFromProgID(OLESTR("PDFCreatorPilot3.PDFDocume nt3"), &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(IPDFDocument3), (LPVOID*)&PDF);

// check for errors
if (FAILED(hr) || (PDF == NULL )) {
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 = "C:TestPDF.pdf";
PDF->AutoLaunch = true; // auto-open generated pdf document

PDF->PutProtectionEnabled (true);
PDF->PutOwnerPassword ("owner1234");
PDF->PutProtectionOptions_coPrint (false);
PDF->PutProtectionOptions_coPrintHigh (false);


// start document generation
PDF->BeginDoc();


// finalize document generation
PDF->EndDoc();

// disconnect from library
PDF->Release();

// unitialize OLE libraries
Uninit:
CoUninitialize();

return 0;
}

Regards,
Siddharth

 

 

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

 

Page top