Resolution, in dots per inch, of this PDF document.
public int Resolution {get; set;}
Public Property Resolution As Integer
public int getResolution()
public void setResolution(int resolution)
An System.Int32 that specifies the resolution in dots per inch of this PDF document. The default value is the value of the static PDFDocument.DefaultResolution property.
A value of 0 means, "Use the current screen resolution" (usually, 96 DPI). High resolution values will render the document with greater detail at the expense of using more system resources. Typical resolution values are 72, 96, 150, 200, 300 and 600.
PDF documents do not have a resolution. Instead, all locations and sizes are stored in PDF units which are equivalent to 1/72 of an inch. To convert a PDF unit to a physical value such as pixels you must provide an external value for the resolution.
Physical values such as pixels are typically needed when a PDF document is rendered to the screen. To convert from logical to physical units, a resolution must be provided. Resolution is the value of dots (pixels) per inch to use when converting logical to physical values. For example, if a PDF document has a page width and height of 612 by 792 units and the resolution value set in Resolution is 150, then:
The size of the page in inches is 8.5" by 11" - Obtained by dividing 612 and 792 by 72
The size of the page in pixels is 1275 by 1650 - Obtained by multiplying 8.5" and 11" by 150, the current resolution
The PDFDocumentPage.ConvertPoint and PDFDocumentPage.ConvertRect uses the value of Resolution when converting to and from pixels. Also, the GetPageImage method will also use this resolution when calculating the page size in pixels.
You can change the Resolution value at any time, based on what is needed. For example, a PDF viewer may set Resolution to a low value, (for example, 96) and call GetPageImage to render the PDF page on the screen when the image is zoomed out and not a lot of details will be viewed. When the user zooms in onto the page, a higher quality with finer details is required. The viewer can then obtain a new version of the image with a higher resolution by setting a new value into Resolution, such as 200, and calling GetPageImage again.
This example will show how changing the resolution affecta PDFDocumentPage.WidthPixels, PDFDocumentPage.HeightPixels and GetPageImage.
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.Controls
Imports Leadtools.Pdf
Imports Leadtools.Svg
Imports Leadtools.WinForms
Public Sub PDFDocumentResolutionExample()
Dim pdfFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Leadtools.pdf")
Dim outFileName1 As String = Path.Combine(LEAD_VARS.ImagesDir, "PageAt150.png")
Dim outFileName2 As String = Path.Combine(LEAD_VARS.ImagesDir, "PageAt300.png")
' Create a PDF document for file
Using document As PDFDocument = New PDFDocument(pdfFileName)
' Get the first page in the document
Dim page As PDFDocumentPage = document.Pages(0)
Using codecs As RasterCodecs = New RasterCodecs()
' Use a resolution of 150
document.Resolution = 150
Console.WriteLine("Page size in pixels at {0} is {1} by {2}", document.Resolution, page.WidthPixels, page.HeightPixels)
' Save this page at this resolution
Using image As RasterImage = document.GetPageImage(codecs, 1)
codecs.Save(image, outFileName1, RasterImageFormat.Png, 32)
End Using
' Use a resolution of 300, the new size should be twice as much as the previous one
document.Resolution = 300
Console.WriteLine("Page size in pixels at {0} is {1} by {2}", document.Resolution, page.WidthPixels, page.HeightPixels)
' Save this page at this resolution
Using image As RasterImage = document.GetPageImage(codecs, 1)
codecs.Save(image, outFileName2, RasterImageFormat.Png, 32)
End Using
End Using
' Open both PNG files and notice that PageAt300.png has more details that PageAt150.png
End Using
End Sub
Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Controls;
using Leadtools.Pdf;
using Leadtools.Svg;
using Leadtools.WinForms;
public void PDFDocumentResolutionExample()
{
string pdfFileName = Path.Combine(LEAD_VARS.ImagesDir, @"Leadtools.pdf");
string outFileName1 = Path.Combine(LEAD_VARS.ImagesDir, @"PageAt150.png");
string outFileName2 = Path.Combine(LEAD_VARS.ImagesDir, @"PageAt300.png");
// Create a PDF document for file
using(PDFDocument document = new PDFDocument(pdfFileName))
{
// Get the first page in the document
PDFDocumentPage page = document.Pages[0];
using(RasterCodecs codecs = new RasterCodecs())
{
// Use a resolution of 150
document.Resolution = 150;
Console.WriteLine("Page size in pixels at {0} is {1} by {2}", document.Resolution, page.WidthPixels, page.HeightPixels);
// Save this page at this resolution
using(RasterImage image = document.GetPageImage(codecs, 1))
{
codecs.Save(image, outFileName1, RasterImageFormat.Png, 32);
}
// Use a resolution of 300, the new size should be twice as much as the previous one
document.Resolution = 300;
Console.WriteLine("Page size in pixels at {0} is {1} by {2}", document.Resolution, page.WidthPixels, page.HeightPixels);
// Save this page at this resolution
using(RasterImage image = document.GetPageImage(codecs, 1))
{
codecs.Save(image, outFileName2, RasterImageFormat.Png, 32);
}
}
// Open both PNG files and notice that PageAt300.png has more details that PageAt150.png
}
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
Products |
Support |
Feedback: Resolution Property - Leadtools.Pdf |
Introduction |
Help Version 19.0.2017.3.22
|
Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.