BookmarkGetDestinationRectangle Method (Resolution, RenderingSettings)

Apitron PDF Rasterizer help
Apitron.PDF.Rasterizer library for .NET
Gets the destination rectangle. NOTE: rectangle uses PDF coordinate system i.e Zero is located in the bottom-left corner.

Namespace:  Apitron.PDF.Rasterizer.Navigation
Assembly:  Apitron.PDF.Rasterizer (in Apitron.PDF.Rasterizer.dll) Version: (

public Rectangle GetDestinationRectangle(
	Resolution resolution,
	RenderingSettings renderingSettings


Type: Apitron.PDF.Rasterizer.ConfigurationResolution
The resolution.
Type: Apitron.PDF.Rasterizer.ConfigurationRenderingSettings
The rendering settings.

Return Value

Type: Rectangle
Destination area.

FileStream stream = new FileStream("sample.pdf", FileMode.Open, FileAccess.Read);
RenderingSettings renderingSettings = new RenderingSettings();
using (Document document = new Document(stream))
    int index = 0;
    Bookmark bookmarks = document.Bookmarks;

    foreach (Bookmark bookmark in bookmarks.Children)
        Page destinationPage = bookmark.Destination;

        // We want to have an image two times bigger than original page size.
        Resolution resolution = new Resolution( 144, 144 );

        // Renders the page on a bitmap
        Bitmap bmp = destinationPage.Render( resolution, renderingSettings, null );
        Graphics graphics = Graphics.FromImage( bmp );

        // Gets a rect for desired size
        Rectangle rectangle = bookmark.GetDestinationRectangle( resolution, renderingSettings );

        // Draws the rect and saves result.
        graphics.DrawRectangle(new Pen(Color.Yellow), (float)rectangle.Left, (float)(bmp.Height - rectangle.Top), (float)rectangle.Width, (float)rectangle.Height);
        bmp.Save(string.Format("img{0}.jpg", index++), ImageFormat.Jpeg);
See Also