Get bookmarks to open in same PDF viewer window

When I create a new bookmark object with its .Action = “GoToR” and add it into any existing PDF using PdfBookmarkEditor() it is always set to open in a new window, so that when I view the PDF (after saving with the new bookmark added) in a PDF viewer, clicking on the Bookmark opens a new instance of the Viewer rather than opening the bookmarked PDF in the same view window.

Looking at the PDF after it has bee saved bookmarks always seem to be given the tag /NewWindow true

Is there some way to specify that you want bookmarks to be opened in the same window and not a new one.

I have the same problem with using PdfContentEditor.CreatePdfDocumentLink to create links as well.

You can test this yourself using the following snippet (substitute ORIGINALPDF and NEWPDF for PDf files of your choice)

Editor = New Aspose.Pdf.Kit.PdfBookmarkEditor()

Editor.BindPdf(ORIGINALPDF)

BookMarkItem = New Aspose.Pdf.Kit.Bookmark()
'actionTypes supported by Aspose.PDF.Kit include “GoToR”|“Launch”|“GoTo”|“URI”.

BookMarkItem.Action = "GoToR"
BookMarkItem.Destination = ORIGPDF
BookMarkItem.Title = System.IO.Path.GetFileName(ORIGPDF)

Editor.CreateBookmarks(BookMarkItem)
Editor.Save(NEWPDF)

Hi Chris,

I have tested this issue at my end, however I’m afraid, I couldn’t reproduce the same problem. Could you please share the input PDF file with us as well? Also, please mention the version of the Aspose.Pdf.Kit for .NET you’re using.

We’re sorry for the inconvenience and looking forward to help you out.
Regards,

The below code is a command line app that will let you replicate the issue;

Sub Main()
MakeNewPDF(“C:\AsposePDF1.pdf”)
MakeNewPDF(“C:\AsposePDF2.pdf”)
AddBookmarkToPDF(“C:\AsposePDF1.pdf”, “C:\AsposePDF2.pdf”)
End Sub

Private Sub MakeNewPDF(ByVal pdfName As String)
Dim PDF As Aspose.Pdf.Pdf

PDF = New Aspose.Pdf.Pdf()
PDF.Save(pdfName)
End Sub

Private Sub AddBookmarkToPDF(ByVal modifyPDF As String, ByVal linkToPDF As String)
Dim Editor As Aspose.Pdf.Kit.PdfBookmarkEditor
Dim BookMarkItem As Aspose.Pdf.Kit.Bookmark

If System.IO.File.Exists(modifyPDF) Then System.IO.File.Delete(modifyPDF)
Editor = New Aspose.Pdf.Kit.PdfBookmarkEditor()

Editor.BindPdf(linkToPDF)
BookMarkItem = New Aspose.Pdf.Kit.Bookmark()

'actionTypes supported by Aspose.PDF.Kit include “GoToR”|“Launch”|“GoTo”|“URI”.
BookMarkItem.Action = “GoToR”
BookMarkItem.Destination = linkToPDF

BookMarkItem.Title = System.IO.Path.GetFileName(linkToPDF)
Editor.CreateBookmarks(BookMarkItem)

Editor.Save(modifyPDF)
End Sub

For this I am using Aspose.Pdf.Kit for .NET 4.8.0.0 using the dlls for .Net 2.0 (In the aboce code I create a new PDF with Aspose.PDF but the same thing happens regardless of the source PDF)

If you look at the PDF file (via a text editor) you will find an object constructed like this;

<</F 20 0 R
/NewWindow true
/D (C:\AsposePDF2.pdf)
/S /GoToR
>>

As you will see, the /NewWindow flag is set to true, this means that unless a user specifically sets the ‘Show each document in its own window’ setting in Adobe Reader it will always pop up in a new window, whereas if you are able to set it to false then by default the link will open in the same window.

This is the same issue i get when inserting a link using PDFContentEditor.CreatePdfDocumentLink as well

Hi Chris,

I have again tested this issue at my end using your specified scenario and the code snippet, but I’m having a different problem. When I click on the bookmark, I see the following error message: “There was an error while performing an action. Invalid action object”.

I have tested this issue using versions 4.8.0 and 4.9.0, but noticed the same message. Also, I couldn’t see the object you mentioned, in the PDF file while viewing in text editor. Can you please download the latest version (4.9.0) and try with that? I just wanted to confirm that which error/issue you face with the latest version, so I could log the issue accordingly for our development team to further investigate it.

We’re sorry for the inconvenience and looking forward to help you out.
Regards,

Hi,

My apologies you also need the line BookMarkItem.RemoteFile = linkToPDF.

I have attached the VS2008 solution so you can open and run that rather than create your own - To keep the size down, i did not include a copy of Aspose.Pdf.dll or Aspose.Pdf.Kit.dll so you will need to copy them into the project directory 'TestAsposeLinkMaking’

I have used the latest Aspose.Pdf.Kit 4.9.0 .net 2.0 dll (and the latest aspose.Pdf 4.6.0 .net 2.0 dll).

I have tested this application and it produces valid PDF files with a bookmark and link.

This application demonstrates that both BookmarkEditor and ContentEditor do the same thing with /NewWindow true

Hi Chris,

Thank you very much for sharing the sample application with us. I have reproduced the issue at my end and logged it as PDFKITNET-20566 in our issue tracking system. Our team will investigate it in detail and you’ll be updated via this forum thread once it is resolved.

We’re sorry for the inconvenience.
Regards,

Hi,

Any update on this?

Hi Chris,

I’m sorry to inform you that this issue is not yet resolved. However, I have asked our development team to share the ETA. You’ll be updated with the status the earliest possible.

We’re sorry for the inconvenience.
Regards,

Hi Chris,

Our team has further investigated this issue and I would like to share with you that the fix for this issue will be available in Q2’2011. You’ll be notified via this forum thread once it is resolved.

We’re sorry for the inconvenience.
Regards,