Add relative links between 2 pdf documents

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: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Vasyl - PDF-XChange, Stefan - PDF-XChange

RaduC
User
Posts: 9
Joined: Thu May 23, 2013 1:31 pm

Add relative links between 2 pdf documents

Post by RaduC »

Hi,

I am trying to create relative links between 2 pdf documents -> click on one link should open the other pdf document on a bookmark. I read that there is no way to open pdfs to specific bookmarks, but you can do that through named destinations. I would like to create named destinations from the current bookmarks and set the links to point to the new named destinations. I can do this using the PdfViewer using the menus, but I need to be able to accomplish this programatically through the PDF Tools.

I did try to use the PXCp_BMGetItemInfo method to get information about the bookmarks (mainly the PXCp_BMDestination) and to create a Named Destination from it but the method always gives me Invalid Argument Error. I am attaching my test program to demonstrate this.

So I have 3 questions:

1. How do I get the destination for a bookmark using the PDF-Tools?
2. Which is the method for creating named destinations (I only found one that removes named destinations)?
3. How can I add a link that points to a named destination in another pdf?

Thank you,
--
Radu
You do not have the required permissions to view the files attached to this post.
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19939
Joined: Mon Jan 12, 2009 8:07 am

Re: Add relative links between 2 pdf documents

Post by Stefan - PDF-XChange »

Hello Radu,

I've checked with one of the PDF Tools SDK experts and he has told me that

1) PXCp_BMGetItemInfo is not working for named destinations (at least it will not give the destination name).
and that to achieve 2) and 3) you will need to use the low lever API for which we do not provide support and you would need good understanding of the PDF format and structure and code all the features yourself.

Regards,
Stefan
RaduC
User
Posts: 9
Joined: Thu May 23, 2013 1:31 pm

Re: Add relative links between 2 pdf documents

Post by RaduC »

Hi Stefan,

Thank you for the fast reply. I was trying to get the PXCp_BMDestination for the bookmarks (not named destinations) that are already created using the PXCp_BMGetItemInfo and I am getting that error (Invalid argument). From the PXCp_BMDestination I wanted to take the Page, Zoom, Margins etc to create the named destination.

I have something like this in my code in the first post:

var currentItem = 0;
var bmItemInfo = new XCPro35_Defs.PXCp_BMInfo();
res = XCPro35_Defs.PXCp_BMGetItem(m_pdf, rootItem, XCPro35_Defs.PXCp_OutlinePos.PBM_NEXT, out currentItem);
res = XCPro35_Defs.PXCp_BMGetItemInfo(m_pdf, currentItem, ref bmItemInfo);

After the last line, res is the code for "Invalid Argument".

I'd like to know how to get the information about the bookmark destination so that I might be able to create the named items from this.

Thanks again,
--
Radu
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19939
Joined: Mon Jan 12, 2009 8:07 am

Re: Add relative links between 2 pdf documents

Post by Stefan - PDF-XChange »

Hi RaduC,

My colleague has mentioned that you should pay a bit more attention to the documentation and read it carefully.
cbSize and Mask must be filled before calling PXCp_BMGetItemInfo

Regards,
Stefan
RaduC
User
Posts: 9
Joined: Thu May 23, 2013 1:31 pm

Re: Add relative links between 2 pdf documents

Post by RaduC »

Hi Stefan,

Thanks it worked. I read the documentation, but it seems not careful enough and made some assumptions that some properties are optional.

I was missing these 2 lines:

bmItemInfo.Mask = (int)XCPro35_Defs.PXCp_BMInfoMask.BMIM_Destination;
bmItemInfo.cbSize = Marshal.SizeOf(bmItemInfo);

Thanks!

Best regards,
--
Radu
User avatar
Stefan - PDF-XChange
Site Admin
Posts: 19939
Joined: Mon Jan 12, 2009 8:07 am

Re: Add relative links between 2 pdf documents

Post by Stefan - PDF-XChange »

Glad we could help RaduC

Cheers,
Stefan