Apitron.PDF.Rasterizer library for .NET
Assembly: Apitron.PDF.Rasterizer (in Apitron.PDF.Rasterizer.dll) Version: 3.0.154.0 (3.0.154.0)
Destination area.
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: 3.0.154.0 (3.0.154.0)
Syntax
public Rectangle GetDestinationRectangle( int desiredWidth, int desiredHeight, RenderingSettings renderingSettings )
Parameters
- desiredWidth
- Type: SystemInt32
Width of the desired. - desiredHeight
- Type: SystemInt32
Height of the desired. - renderingSettings
- Type: Apitron.PDF.Rasterizer.ConfigurationRenderingSettings
The rendering settings.
Return Value
Type: RectangleDestination area.
Examples
C#
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. int desiredWidth = (int)(destinationPage.Width * 2); int desiredHeight = (int)(destinationPage.Height * 2); // Renders the page on a bitmap Bitmap bmp = destinationPage.Render(desiredWidth, desiredHeight, renderingSettings, null); Graphics graphics = Graphics.FromImage(bmp); // Gets a rect for desired size Rectangle rectangle = bookmark.GetDestinationRectangle(desiredWidth, desiredHeight, renderingSettings); // Draws the rect and saves result. graphics.DrawRectangle(new Pen(Color.Yellow), (float)rectangle.Left, (float)(desiredHeight - rectangle.Top), (float)rectangle.Width, (float)rectangle.Height); bmp.Save(string.Format("img{0}.jpg", index++), ImageFormat.Jpeg); } }
See Also