This Forum is for the use of Software Developers requiring help and assistance for Tracker Software's PDF-Tools SDK of Library DLL functions(only) - Please use the PDF-XChange Drivers API SDK Forum for assistance with all PDF Print Driver related topics or PDF-XChange Viewer SDK if appropriate.
Moderators: TrackerSupp-Daniel , Tracker Support , Vasyl-Tracker Dev Team , Chris - Tracker Supp , Sean - Tracker , Tracker Supp-Stefan
oskpm
User
Posts: 41 Joined: Tue Aug 31, 2010 8:44 am
Post
by oskpm » Tue Sep 20, 2011 1:17 pm
Hello,
signing a new created pdf file (PXC_NewDocument(...)) works fine, but how can you
sign an existing file?
some pseudocode so far...
Code: Select all
PDFDocument pdf;
HRESULT res = PXCp_Init(&pdf, "XXX","XXX");
//...
PXCp_ReadDocumentA(pdf, "c:\\1.pdf", d);
_PXCPage* page = NULL;
PXC_GetPage(&pdf, 0, &page);
// page ... OK
//Cert stuff and pCertContext... OK
hr = PXC_SignDocumentA(&pdf, pCertContext, page, &sr,
"Cause", "Loc", "ContactInfo", NULL,
Sign_GR_NoGraphics| Sign_TX_Name | Sign_TX_Date | Sign_TX_Reason | Sign_TX_DName);
if (IS_DS_FAILED(hr))
{
// this fails ... Error Message via PXC_Err_FormatSeverity() is 'Error'
}
Any hints?
Thanks in advance
Peter
Tracker Supp-Stefan
Site Admin
Posts: 17949 Joined: Mon Jan 12, 2009 8:07 am
Location: London
Post
by Tracker Supp-Stefan » Wed Sep 21, 2011 3:02 pm
Hello Peter,
The functions in the XCPRO40 LIB are aimed at manipulating existing documents, so please have a look at
PXCp_SignDocumentW and the other two Signature functions in the XCPRO library.
Best,
Stefan
oskpm
User
Posts: 41 Joined: Tue Aug 31, 2010 8:44 am
Post
by oskpm » Thu Sep 22, 2011 6:22 am
Hello Stefan,
thanks for reply.
Unfortunately also with the functions from XCPro (PXCp_...) there is no success:
My sample code:
Code: Select all
HRESULT hr ;
PDFDocument pdf;
hr = PXCp_Init(&pdf, "xxx","xxx");
ASSERT( IS_DS_SUCCESSFUL(hr) ); // OK
hr = PXCp_ReadDocumentW(pdf, L"c:\\1.pdf", 0);
ASSERT( IS_DS_SUCCESSFUL(hr) ); // OK
HCERTSTORE hCertStore = NULL;
PCCERT_CONTEXT pCertContext = NULL;
hCertStore = CertOpenSystemStore(NULL, "MY");
ASSERT(hCertStore); // OK
pCertContext = CryptUIDlgSelectCertificateFromStore(
hCertStore,
this->m_hWnd,
NULL,
NULL,
CRYPTUI_SELECT_LOCATION_COLUMN,
0,
NULL);
ASSERT( pCertContext ); //OK
PXC_RectF sr;
sr.left = I2L(1);
sr.right = I2L(4);
sr.top = I2L(3);
sr.bottom = I2L(4);
hr = PXCp_SignDocumentW(&pdf, pCertContext, 0, &sr, L"Test Reason", L"Test Location", L"Test Contact Info", NULL,
Sign_GR_Name | Sign_TX_Name | Sign_TX_Date |Sign_TX_Location | Sign_TX_Reason |
Sign_TX_DName);
///////////////////
// not successful /
///////////////////
ASSERT( IS_DS_SUCCESSFUL(hr) );
Do you have any other ideas?
Regards,
Peter
Tracker Supp-Stefan
Site Admin
Posts: 17949 Joined: Mon Jan 12, 2009 8:07 am
Location: London
Post
by Tracker Supp-Stefan » Thu Sep 22, 2011 1:37 pm
Hello Peter,
Checking with the guys in our dev team now. I hope to have some more ideas for you shortly.
Best,
Stefan
Ivan - Tracker Software
Site Admin
Posts: 3550 Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada
Post
by Ivan - Tracker Software » Thu Sep 22, 2011 2:05 pm
Code: Select all
...
///////////////////
// not successful /
///////////////////
ASSERT( IS_DS_SUCCESSFUL(hr) );
Can you say the value or hr when code fails?
Tracker Software (Project Director)
When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
oskpm
User
Posts: 41 Joined: Tue Aug 31, 2010 8:44 am
Post
by oskpm » Fri Sep 23, 2011 6:02 am
Hello Ivan,
the value of hr is -2113394928
PXC_Err_FormatErrorCode() gives 'Error' as error message
Regards,
Peter
Lzcat - Tracker Supp
Site Admin
Posts: 677 Joined: Thu Jun 28, 2007 8:42 am
Post
by Lzcat - Tracker Supp » Fri Sep 23, 2011 10:29 am
hr = PXCp_SignDocumentW(& pdf, pCertContext, 0, &sr, L"Test Reason", L"Test Location", L"Test Contact Info", NULL,
Sign_GR_Name | Sign_TX_Name | Sign_TX_Date |Sign_TX_Location | Sign_TX_Reason |
Sign_TX_DName);
In your code signt '&' (ampersand) marked as red shold be removed. You are lucky that you did not got crash.
Victor
Tracker Software
Project manager
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
oskpm
User
Posts: 41 Joined: Tue Aug 31, 2010 8:44 am
Post
by oskpm » Mon Sep 26, 2011 5:54 am
In your code signt '&' (ampersand) marked as red shold be removed. You are lucky that you did not got crash.
That's it, thanks a lot!
Regards,
Peter
Tracker Supp-Stefan
Site Admin
Posts: 17949 Joined: Mon Jan 12, 2009 8:07 am
Location: London
Post
by Tracker Supp-Stefan » Mon Sep 26, 2011 11:32 am
Glad to hear it's working now Peter!
Cheers,
Stefan