Set default image resolution in dots per inch

Namespace:  SautinSoft
Assembly:  SautinSoft.PdfFocus (in SautinSoft.PdfFocus.dll) Version: 6.6.9.7 (6.6.9.7)

Syntax

      
 C#  Visual Basic 
public int Dpi { get; set; }
Public Property Dpi As Integer

Remarks

To start the process, please download the most fresh version of PDF Focus .Net.

We recommend to use 120 dpi, but you may use any value within reasonable limits

Default value: 120



Examples

CopyHow to set custom dpi in C#
using System;
using System.IO;
using System.Collections;

namespace Sample
{
    class Sample
    {
        static void Main(string[] args)
        {

            string pdfPath = @"..\..\..\..\..\simple text.pdf";
            string imagePath = Path.ChangeExtension(pdfPath, ".png");

            SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();
            //this property is necessary only for registered version
            //f.Serial = "XXXXXXXXXXX";
            f.OpenPdf(pdfPath);

            if (f.PageCount > 0)
            {
                //In most cases we recommend to set 120 dpi to decrease the image size and converting speed
                //Now set 300 dpi - very high quality
                f.ImageOptions.Dpi = 300;

                //Convert 1st page from PDF to image file
                if (f.ToImage(imagePath, 1) == 0)
                {
                    // 0 - converting successfully                
                    // 2 - can't create output file, check the output path
                    // 3 - converting failed
                    System.Diagnostics.Process.Start(imagePath);
                }
            }        
        }
    }
}
CopyHow to set custom dpi in VB.Net
Imports System.IO
Imports System.Drawing.Imaging
Imports System.Collections.Generic
Imports SautinSoft

Module Sample

    Sub Main()
        Dim pdfPath As String = "..\..\..\..\simple text.pdf"
        Dim imagePath As String = Path.ChangeExtension(pdfPath, ".png")

        Dim f As New SautinSoft.PdfFocus()
        'this property is necessary only for registered version
        'f.Serial = "XXXXXXXXXXX";
        f.OpenPdf(pdfPath)

        If f.PageCount > 0 Then
            'In most cases we recommend to set 120 dpi to decrease the image size and converting speed
            'Now set 300 dpi - very high quality
            f.ImageOptions.Dpi = 300

            'Convert 1st page from PDF to image file
            If f.ToImage(imagePath, 1) = 0 Then
                ' 0 - converting successfully                
                ' 2 - can't create output file, check the output path
                ' 3 - converting failed
                System.Diagnostics.Process.Start(imagePath)
            End If
        End If
    End Sub
End Module

See Also