We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

PDF Book mark not pointing from the start of the page

My requirement is I have to convert office docs to pdf and merge the pdf then I have to create book mark with the document name.Everything going good except the one that is bookmark that I have created is not exactly pointing to starting page of the document.It is somewhere going in the middle of the page rather than pointing to start of the page.How to fix this??your help will be much appreciated.Thank you.

Could you please update on this issue…


Hi
Anand,


Thanks for contacting support.

I am working over this query and will get back to you soon. We are sorry for this delay and inconvenience.

Hi Anand,


I have tested the scenario where I have tried adding some Bookmarks in PDF document and as per my observations, when I have selected either of the Bookmarks, the start of the document page is displayed. I have used Adobe Reader 10.1.4 to view the PDF files. However I have observed that if you scroll to the middle of pages other than first and then select any Bookmark, the start of the page is not displayed. As per my understanding, its a behavior of PDF viewing application.

Nevertheless, can you please share which version of Aspose.Pdf.Kit for Java you are using ? (I have used Aspose.Pdf.Kit for Java 4.3.0 for testing). Also please share the source (Merged PDF file before adding BookMarks), the resultant PDF after adding BookMarks and the code snippet which you have been using.

We are sorry for your inconvenience.

Thank you for you reply…yeah for me too bookmark works fine if I am in the start of the page.But it when I scroll down some where to the middle of the page and if i click the book mark again then it is not going to start of the page!!Is that behavior of pdf viewing application??Is it possible to adjust the display default to ‘Zoom - Page Fit’ rather than ‘Zoom page-width’???

Hi I don’t think that it is fault of pdf viewing application.If I am in middle of page and click the book mark then it should go to the start of the page of that book mark right??Please help to fix this…

Please refer the below pdf book mark.I have downloaded and changed the property to zoom fit width.But the bookmarks works fine it seems…


http://www.sitextools.com/samples/eBooks/eBook.pdf

Hi Anand,


Thanks for sharing the details.

I have gone through the description and as per my understanding, the requested feature is currently not supported. However for the sake of implementation, I have
logged this requirement in our issue tracking system under New Features list as
<span style=“font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:
“Arial”,“sans-serif”;mso-fareast-font-family:SimSun;mso-fareast-language:ZH-CN”>PDFKITJAVA-33224
. We will investigate this issue in details
and will keep you updated on the status of a correction.

We are sorry for your inconvenience.

<span style=“font-size:10.0pt;font-family:“Arial”,“sans-serif”;mso-fareast-font-family:
SimSun;mso-fareast-language:ZH-CN”>
<o:p></o:p>

Hi.Thank you for your help on this issue.I just wanted to know one more thing whether it is possible to set the Zoom to page level instead of Zoom to Fit Width in the generated PDF??

Hi Anand,


We have a class named PdfPageEditor present in Aspose.Pdf for .NET which supports the feature to set the Zoom factor on pages of existing PDF files, change page size, change Page Alignment and many other features but I am afraid this class is not present in Aspose.Pdf.Kit for Java. Nevertheless the requirement to support this class has been logged in our issue tracking system as PDFKITJAVA-32957 and our development team is working on implementing this class. As soon as we have some updates, we would be more than happy to update you with the status of correction. Please be patient and spare us little time. We are sorry for your inconvenience.

Hi,

Could you please update on this issue?

We have a release this week using ASPOSE tool .It would be better if you fix this issue soon.The book mark should work as expected.Our release is getting delayed due to this.Please fix this issue ASAP.

Thank you.

--Anand

Hi Anand,

Thanks for your patience.

Our development team is further investigating this problem but I am afraid its not yet completely resolved. In fact the team has been busy resolving other priority issues and this problem will be fixed on its schedule. Nevertheless, if you wish to get this problem resolved earlier, you may consider subscribing for Enterprise or Priority Support. Please note that the issues logged under ES/PS support have high precedence in terms of resolution as compare to issues logged with normal priority. Please visit the following link for further details on various Support Services models.

Besides this, I have also inquired the current ETA from development team (without ES/PS priority). We are sorry for this delay and inconvenience.

Hi Anand,


Thanks for your patience.

We have further investigated the requirement of “Bookmark pointing to the start of page” and as per our observations, in document PdfViewerPreference_Changed.pdf bookmark position is already set by default. So we have added the ability to edit destination property for existing bookmarks. In order to accomplish this requirement, please try using the following code snippet.

[Java]

String path = “D:\Temp\”;<o:p></o:p>

com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document(path + "PdfViewerPreference_Changed_out.pdf");

//Editing existing bookmark

OutlineItemCollection pdfOutline = pdfDocument.getOutlines().get_Item(1);

pdfOutline.setDestination(

// 1st variant

// new FitVExplicitDestination(pdfDocument.getPages().get_Item(1),0)

// 2nd variant. You can tweak using the bookmark links using different parameters of ExplicitDestinationType

ExplicitDestination.createDestination(pdfDocument.getPages().get_Item(1),

ExplicitDestinationType.FitH,

new double[] {

pdfDocument.getPages().get_Item(1).getMediaBox().getHeight() }));

pdfDocument.save();


also please note that while creating a new bookmark, it is able to set the destination page number and specific position on the page:

[Java]

String path = "D:\\Temp\\";

com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document(path + "PdfViewerPreference_Changed_out.pdf");

OutlineItemCollection pdfOutline_new = new OutlineItemCollection(pdfDocument.getOutlines());

pdfOutline_new.setTitle("Test bookmark");

pdfOutline_new.setItalic(true);

pdfOutline_new.setBold(true);

//set the destination page number and position

pdfOutline_new.setAction(new com.aspose.pdf.GoToAction(new FitVExplicitDestination(pdfDocument.getPages().get_Item(2), 0)));

//add bookmark in the document's outline collection.

pdfDocument.getOutlines().add(pdfOutline_new);

pdfDocument.save();


You can also set specific ViewerPreference in this way:

[Java]

com.aspose.pdf.facades.PdfContentEditor editor = new com.aspose.pdf.facades.PdfContentEditor();

editor.bindPdf(path + "test.pdf");

editor.changeViewerPreference(ViewerPreference.PAGE_LAYOUT_SINGLE_PAGE);

editor.save(path + "test_out.pdf");


You may consider taking a look over details extracted from Adobe Portable Document Format Version 1.3

Destination syntax
[page /XYZ left top zoom]
 Display the page designated by page, with the coordinates (left, top)
 positioned at the upper-left corner of the window and the contents of
 the page magnified by the factor zoom. A null value for any of the
 parameters left, top, or zoom specifies that the current value of that
 parameter shall be retained unchanged. A zoom value of 0 has the
 same meaning as a null value.
[page /Fit]
 Display the page designated by page, with its contents magnified just
 enough to fit the entire page within the window both horizontally and
 vertically. If the required horizontal and vertical magnification factors
 are different, use the smaller of the two, centering the page within the
 window in the other dimension.
[page /FitH top]
 Display the page designated by page, with the vertical coordinate top
 positioned at the top edge of the window and the contents of the page
 magnified just enough to fit the entire width of the page within the
 window. A null value for top specifies that the current value of that
 parameter shall be retained unchanged.
[page /FitV left]
 Display the page designated by page, with the horizontal coordinate
 left positioned at the left edge of the window and the contents of the
 page magnified just enough to fit the entire height of the page within
 the window. A null value for left specifies that the current value of that
 parameter shall be retained unchanged.
[page /FitR left bottom right top]
 Display the page designated by page, with its contents magnified just
 enough to fit the rectangle specified by the coordinates left, bottom,
 right, and top entirely within the window both horizontally and vertically.
 If the required horizontal and vertical magnification factors are
 different, use the smaller of the two, centering the rectangle within the
 window in the other dimension.
[page /FitB]
 (PDF 1.1) Display the page designated by page, with its contents
 magnified just enough to fit its bounding box entirely within the window
 both horizontally and vertically. If the required horizontal and vertical
 magnification factors are different, use the smaller of the two,
 centering the bounding box within the window in the other dimension.
[page /FitBH top]
 (PDF 1.1) Display the page designated by page, with the vertical
 coordinate top positioned at the top edge of the window and the
 contents of the page magnified just enough to fit the entire width of its
 bounding box within the window. A null value for top specifies that the
 current value of that parameter shall be retained unchanged.
[page /FitBV left]
 (PDF 1.1) Display the page designated by page, with the horizontal
 coordinate left positioned at the left edge of the window and the
 contents of the page magnified just enough to fit the entire height of its
 bounding box within the window. A null value for left specifies that the
 current value of that parameter shall be retained unchanged.