←Select platform

HeightPixels Property

Summary
Gets the height of the page in pixels
Syntax
C#
C++/CLI
Java
Python
public int HeightPixels { get; } 
public int getHeightPixels(); 
public: 
property int HeightPixels { 
   int get(); 
} 
HeightPixels # get  (PDFDocumentPage) 

Property Value

The height of the page in pixels. The default value is 0.

Remarks

This value is read-only. The WidthPixels and HeightPixels are properties are populated automatically when the PDFDocument is created by using the Width and Height values in PDF units read from the file and the current resolution set in the owner PDFDocument.Resolution.

This value is the height of crop box of this page stored in CropBox, For more information, refer to PDF Coordinate System.

PDF units are in 1/72 of an inch, so a page size (Width and Height) of 612 by 792 at a resolution of 300 corresponds to 2550 by 3300 pixels ("612 * 300"/72 by "792 * 300"/72).

You can also use the WidthInches and HeightInches to get the size of the page in inches.

The PDFDocumentPage object also contains the ConvertPoint and ConvertRect helper methods that can be used to convert a point or a rect from and to page/object to pixel/inch coordinates.

This property returns the height of the PDF crop box. For more information, refer to PDF Coordinate System.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Pdf; 
using Leadtools.WinForms; 
 
 
public void PDFDocumentPageExample() 
{ 
   string pdfFileName = Path.Combine(LEAD_VARS.ImagesDir, @"Leadtools.pdf"); 
   string txtFileName = Path.Combine(LEAD_VARS.ImagesDir, @"LEAD_pdf.txt"); 
 
   // Open the document 
   using (PDFDocument document = new PDFDocument(pdfFileName)) 
   { 
      // Parse everything and for all pages 
      PDFParsePagesOptions options = PDFParsePagesOptions.All; 
      document.ParsePages(options, 1, -1); 
 
      // Save the results to the text file for examining 
      using (StreamWriter writer = File.CreateText(txtFileName)) 
      { 
         foreach (PDFDocumentPage page in document.Pages) 
         { 
            writer.WriteLine("Page {0}", page.PageNumber); 
 
            IList<PDFObject> objects = page.Objects; 
            writer.WriteLine("Objects: {0}", objects.Count); 
            foreach (PDFObject obj in objects) 
            { 
               writer.WriteLine("  ObjectType: {0}", obj.ObjectType.ToString()); 
               writer.WriteLine("  Bounds: {0}, {1}, {2}, {3}", obj.Bounds.Left, obj.Bounds.Top, obj.Bounds.Right, obj.Bounds.Bottom); 
               WriteTextProperties(writer, obj.TextProperties); 
               writer.WriteLine("  Code: {0}", obj.Code); 
               writer.WriteLine("------"); 
            } 
            writer.WriteLine("---------------------"); 
 
            IList<PDFHyperlink> hyperlinks = page.Hyperlinks; 
            writer.WriteLine("Hyperlinks: {0}", hyperlinks.Count); 
            foreach (PDFHyperlink hyperlink in hyperlinks) 
            { 
               writer.WriteLine("  Hyperlink: {0}", hyperlink.Hyperlink); 
               writer.WriteLine("  Bounds: {0}, {1}, {2}, {3}", hyperlink.Bounds.Left, hyperlink.Bounds.Top, hyperlink.Bounds.Right, hyperlink.Bounds.Bottom); 
               WriteTextProperties(writer, hyperlink.TextProperties); 
            } 
            writer.WriteLine("---------------------"); 
         } 
      } 
   } 
} 
 
private static void WriteTextProperties(StreamWriter writer, PDFTextProperties textProperties) 
{ 
   writer.WriteLine("  TextProperties.FontHeight: {0}", textProperties.FontHeight.ToString()); 
   writer.WriteLine("  TextProperties.FontWidth: {0}", textProperties.FontWidth.ToString()); 
   writer.WriteLine("  TextProperties.FontIndex: {0}", textProperties.FontIndex.ToString()); 
   writer.WriteLine("  TextProperties.IsEndOfWord: {0}", textProperties.IsEndOfWord.ToString()); 
   writer.WriteLine("  TextProperties.IsEndOfLine: {0}", textProperties.IsEndOfLine.ToString()); 
   writer.WriteLine("  TextProperties.Color: {0}", textProperties.Color.ToString()); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; 
} 
Requirements

Target Platforms

Help Version 22.0.2023.7.10
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Pdf Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.