Core Api open document  SOLVED

A forum for questions or concerns related to the PDF-XChange Core API SDK

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Sean - Tracker, Chris - Tracker Supp, Tracker Supp-Stefan

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
Post Reply
edvschu
User
Posts: 122
Joined: Fri Jun 25, 2010 6:54 am

Core Api open document

Post by edvschu » Tue Sep 29, 2015 12:49 pm

Hello,

i try open a pdf with core api in .NET, but i get it not. How to instantiate DocAuthCallback? Online Help not help further.

I get following error: Error [Pdf Structure Library]: Unknown/unsupported security handler.

Code: Select all

Dim sFile As String = "C:\sample.pdf"
Dim pAuthCallback As LIBNAME.IPXC_DocAuthCallback = Nothing

Try
     pdfInst.OpenDocumentFromFile(sFile, pAuthCallback)
Catch ex As Exception
      Dim hr As Integer = Marshal.GetHRForException(ex)
       ShowErrMsg(hr)
End Try
Best Regards,
edvschu

User avatar
Sasha - Tracker Dev Team
User
Posts: 4326
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Core Api open document

Post by Sasha - Tracker Dev Team » Tue Sep 29, 2015 12:53 pm

Hi, edvschu

Please take a look here:
http://www.tracker-software.com/forum3/ ... 678#p94678

HTH
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

edvschu
User
Posts: 122
Joined: Fri Jun 25, 2010 6:54 am

Re: Core Api open document

Post by edvschu » Tue Sep 29, 2015 1:05 pm

Thanks Sasha. But how i implement it in vb.net?

User avatar
Sasha - Tracker Dev Team
User
Posts: 4326
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Core Api open document

Post by Sasha - Tracker Dev Team » Tue Sep 29, 2015 1:33 pm

We don't use vb.net as our primary writing language but we'll try to translate it.
You need pAuthCallback for the documents with passwords - it's not needed by default.
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

edvschu
User
Posts: 122
Joined: Fri Jun 25, 2010 6:54 am

Re: Core Api open document

Post by edvschu » Wed Sep 30, 2015 11:28 am

Sample in CSharp like in Editor SDK would me help, too :D.

User avatar
Tracker Supp-Stefan
Site Admin
Posts: 13559
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Core Api open document

Post by Tracker Supp-Stefan » Wed Sep 30, 2015 11:30 am

:)

User avatar
Sasha - Tracker Dev Team
User
Posts: 4326
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Core Api open document

Post by Sasha - Tracker Dev Team » Wed Sep 30, 2015 11:31 am

OK, that would be easier for us. We are working on this so stay tuned :wink:
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

User avatar
Sasha - Tracker Dev Team
User
Posts: 4326
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Core Api open document

Post by Sasha - Tracker Dev Team » Wed Sep 30, 2015 12:08 pm

OK so this is the first simple sample for document without password:

Code: Select all

private void OpenDocumentFromFileSample(string sFilePath, LIBNAME.IPXC_Inst pInst)
{
	LIBNAME.IPXC_Document pDoc = pInst.OpenDocumentFromFile(sFilePath, null, null, 0, 0);
}
We will post the version with the security handling later in this post.


HTH
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

edvschu
User
Posts: 122
Joined: Fri Jun 25, 2010 6:54 am

Re: Core Api open document

Post by edvschu » Wed Sep 30, 2015 12:31 pm

Thanks for quick reply.

My Sample.pdf has no password. Try your code, i get same error message "Error [Pdf Structure Library]: ...".

User avatar
Sasha - Tracker Dev Team
User
Posts: 4326
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Core Api open document

Post by Sasha - Tracker Dev Team » Wed Sep 30, 2015 12:42 pm

Please send us the code of the error in 0xXXXXXXXX format so we can tell what is the problem.

Thanks,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

edvschu
User
Posts: 122
Joined: Fri Jun 25, 2010 6:54 am

Re: Core Api open document

Post by edvschu » Wed Sep 30, 2015 12:45 pm

Here the error code: 0x8214100F

User avatar
Sasha - Tracker Dev Team
User
Posts: 4326
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Core Api open document

Post by Sasha - Tracker Dev Team » Wed Sep 30, 2015 12:52 pm

We suspect that that document has security - do double check that please. Btw, security and passwords on the documents are two different things.
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

User avatar
Sasha - Tracker Dev Team
User
Posts: 4326
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Core Api open document  SOLVED

Post by Sasha - Tracker Dev Team » Wed Sep 30, 2015 12:55 pm

Here's the code for the password handling of the documents. But you must specify your correct password for each document.

Code: Select all

class CDocAuthCallback : LIBNAME.IPXC_DocAuthCallback
{
	public LIBNAME.IPXS_Inst m_pxsInst = null;
	public void AuthDoc(LIBNAME.IPXC_Document pDoc, uint nFlags)
	{
		if ((pDoc == null) || (m_pxsInst == null))
		{
			return;//throw new COMException("", VSConstants.E_INVALIDARG);
		}
		//Checking whether the document has any security
		UInt32 nNameAtom = pDoc.GetSecurityHandlerType(false);
		if (nNameAtom == 0)
		{
			//No security so successfully opened doc
			//...
			return;//throw new COMException("", VSConstants.S_OK);
		}
		//Else we must provide a password
		UInt32 nStandard = m_pxsInst.StrToAtom("Standard");
		LIBNAME.PXC_PermStatus status = LIBNAME.PXC_PermStatus.Perm_ReqGranted;
		//Comparing whether the security handler type is Standard
		if (nStandard != nNameAtom)
		{
			//We do not support this one
			return;//throw new COMException("", VSConstants.E_INVALIDARG);
		}
		status = pDoc.AuthorizeWithPassword("YourPasswordHere");
		if (status != LIBNAME.PXC_PermStatus.Perm_ReqGranted)
		{
			//We don't have permission to open doc
			return;//throw new COMException("", VSConstants.E_NOTIMPL);
		}
	}
}

private void OpenDocumentFromFileSample(string sFilePath, LIBNAME.IPXC_Inst pInst)
{
			
	//Getting IPXS_Inst if you don't have it
	LIBNAME.IPXS_Inst pSInt = (LIBNAME.IPXS_Inst)pInst.GetExtension("PXS");

	CDocAuthCallback clbk = new CDocAuthCallback();
	clbk.m_pxsInst = pSInt;

	LIBNAME.IPXC_Document pDoc = pInst.OpenDocumentFromFile(sFilePath, clbk, null, 0, 0);
}
Btw, you can attach that sample to your message and we'll try to open it here.

HTH.
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

edvschu
User
Posts: 122
Joined: Fri Jun 25, 2010 6:54 am

Re: Core Api open document

Post by edvschu » Wed Sep 30, 2015 2:05 pm

Arrrgh !!! Find my error. With IPXC_Inst.Init it works. Thanks Sasha for your help :D .

User avatar
Tracker Supp-Stefan
Site Admin
Posts: 13559
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Core Api open document

Post by Tracker Supp-Stefan » Wed Sep 30, 2015 2:05 pm

:)

User avatar
Sasha - Tracker Dev Team
User
Posts: 4326
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Core Api open document

Post by Sasha - Tracker Dev Team » Wed Sep 30, 2015 2:06 pm

Glad to hear that, edvschu. :wink:
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

Post Reply