According to page size how to set the Bookmark parameter value(FitH- X-Y)?

For example: Zoom level: Fit Width,

Document OriginalPDF = new Document();
Page pdfPage = null;
.....
pdfPage = OriginalPDF.Pages[3];

pdfPage.CropBox.Height;
pdfPage.MediaBox.Height;
pdfPage.Rect.Height;
//How to choose among these?

Bookmark XML file will Import to PDF file.
<?xml version="1.0" encoding="ISO8859-1"?>
A
How to calculate the 3 FitH .. For example:Fit Width, Inherit Zoom ?

Hi Huang,


Thanks for your inquiry. Please check following code snippet to use Mediabox properties for bookmark creation. Hopefully it will help you to understand how to set different parameters for bookmark. Please share some more details if there is any difference in my understanding and your requirements.

//open document<o:p></o:p>

Document doc = new Document(myDir + "input.pdf");

//create a bookmark object

OutlineItemCollection docOutline = new OutlineItemCollection(doc.Outlines);

docOutline.Title = "Updated Outline";

docOutline.Italic = true;

docOutline.Bold = true;

Page pdfPage = doc.Pages[3];

// Parameters:

// page:

// The destination page object.

//

// left:

// Left horizontal coordinate of the upper-left corner of the window.

//

// top:

// Top vertical coordinate of the upper-left corner of the window.

//

// zoom:

// Zoom factor.

docOutline.Destination = new GoToAction(new XYZExplicitDestination(pdfPage, pdfPage.MediaBox.URX - 50, pdfPage.MediaBox.URY - 50, 1.5));

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

doc.Outlines.Add(docOutline);

//save output

doc.Save(myDir+"bookmark_output.pdf");

Please feel free to contact us for any further assistance.


Best Regards,