PdfConversionMode Enumeration |
An enumeration of the PDF document conversion modes.
Namespace: SautinSoft.DocumentAssembly: SautinSoft.Document (in SautinSoft.Document.dll) Version: 2024.11.20
Syntax public enum PdfConversionMode
Public Enumeration PdfConversionMode
Members Member name | Value | Description |
---|
Flowing | 0 |
The most useful and common type of document for editing.
The resulting document looks as if it was typed by human.
|
Continuous | 1 |
A golden mean between Flowing and
Exact modes.
|
Exact | 2 |
The most precise and fastest mode. The resulting document looks exact as PDF pixel by pixel.
|
Example See Developer Guide: Rasterizing - save PDF document as PNG and JPEG images
Rasterizing - save PDF document as PNG and JPEG images in C#
using System;
using System.IO;
using SautinSoft.Document;
using SkiaSharp;
namespace Example
{
class Program
{
static void Main(string[] args)
{
RasterizePdfToPicture();
}
static void RasterizePdfToPicture()
{
string inputFile = @"..\..\..\example.pdf";
string jpegFile = "Result.jpg";
string pngFile = "Result.png";
DocumentCore dc = DocumentCore.Load(inputFile, new PdfLoadOptions()
{
DetectTables = false,
ConversionMode = PdfConversionMode.Exact
});
DocumentPaginator documentPaginator = dc.GetPaginator(new PaginatorOptions() { UpdateFields = true });
int dpi = 300;
int pagesToRasterize = 2;
int currentPage = 1;
foreach (DocumentPage page in documentPaginator.Pages)
{
var DPI = new ImageSaveOptions();
DPI.DpiX = 300;
DPI.DpiY = 300;
SkiaSharp.SKBitmap picture = page.Rasterize(DPI, SautinSoft.Document.Color.White);
if (currentPage == 1)
picture.Encode(new FileStream(pngFile, FileMode.Create), SkiaSharp.SKEncodedImageFormat.Png, 100);
else if (currentPage == 2)
picture.Encode(new FileStream(jpegFile, FileMode.Create), SkiaSharp.SKEncodedImageFormat.Jpeg, 100);
currentPage++;
if (currentPage > pagesToRasterize)
break;
}
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(pngFile) { UseShellExecute = true });
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(jpegFile) { UseShellExecute = true });
}
}
}
Rasterizing - save PDF document as PNG and JPEG images in VB.Net
Imports System
Imports System.IO
Imports SautinSoft.Document
Imports SkiaSharp
Namespace Example
Friend Class Program
Shared Sub Main(ByVal args() As String)
RasterizePdfToPicture()
End Sub
Private Shared Sub RasterizePdfToPicture()
Dim inputFile As String = "..\..\..\example.pdf"
Dim jpegFile As String = "Result.jpg"
Dim pngFile As String = "Result.png"
Dim dc As DocumentCore = DocumentCore.Load(inputFile, New PdfLoadOptions() With {
.DetectTables = False,
.ConversionMode = PdfConversionMode.Exact
})
Dim documentPaginator As DocumentPaginator = dc.GetPaginator(New PaginatorOptions() With {.UpdateFields = True})
Dim pagesToRasterize As Integer = 2
Dim currentPage As Integer = 1
For Each page As DocumentPage In documentPaginator.Pages
Dim dpi As ImageSaveOptions = New ImageSaveOptions
dpi.DpiX = 72
dpi.DpiY = 72
Dim picture As SKBitmap = page.Rasterize(dpi, SautinSoft.Document.Color.White)
If currentPage = 1 Then
picture.Encode(New FileStream(pngFile, FileMode.Create), SkiaSharp.SKEncodedImageFormat.Png, 100)
ElseIf currentPage = 2 Then
picture.Encode(New FileStream(jpegFile, FileMode.Create), SkiaSharp.SKEncodedImageFormat.Jpeg, 100)
End If
currentPage += 1
If currentPage > pagesToRasterize Then
Exit For
End If
Next page
System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(pngFile) With {.UseShellExecute = True})
System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(jpegFile) With {.UseShellExecute = True})
End Sub
End Class
End Namespace
See Also