Document .Net can help your application to convert a document from a one format to another.
You'll
need only to Load() a document
and Save() to a desired format.
DocumentCore dc = DocumentCore.Load("...");
dc.Save("....");
Document .Net supports these formats:
DOCX | RTF | HTML | Text | Image | |
---|---|---|---|---|---|
Create/Read/Write | Create/Read/Write | Create/Read/Write | Create/Read/Write | Create/Read/Write | Create/Read(OCR)/Write |
In this code sample, we will show you how to convert PDF (DOCX, RTF, HTML) in Images.
Each document page will be saved in its own image format: PNG, JPEG, TIFF with different DPI.
For example: We have the PDF document with three pages inside:
// PaginationOptions allow to know, how many pages we have in the document.
DocumentPaginator dp = dc.GetPaginator(new PaginatorOptions());
Our task - each document page will be saved in its own image format.
Complete code
using SautinSoft.Document;
namespace Example
{
class Program
{
static void Main(string[] args)
{
ConvertPDFtoImages();
}
/// <summary>
/// Convert PDF to Images (file to file).
/// </summary>
/// <remarks>
/// Details: https://sautinsoft.com/products/document/help/net/developer-guide/convert-pdf-to-images-in-csharp-vb.php
/// </remarks>
static void ConvertPDFtoImages()
{
// Path to a document where to extract pictures.
// By the way: You may specify DOCX, HTML, RTF files also.
DocumentCore dc = DocumentCore.Load(@"..\..\..\example.pdf");
// PaginationOptions allow to know, how many pages we have in the document.
DocumentPaginator dp = dc.GetPaginator(new PaginatorOptions());
// Each document page will be saved in its own image format: PNG, JPEG, TIFF with different DPI.
dp.Pages[0].Save(@"..\..\..\example.png", new ImageSaveOptions() { DpiX = 800, DpiY = 800 });
dp.Pages[1].Save(@"..\..\..\example.jpeg", new ImageSaveOptions() { DpiX = 400, DpiY = 400 });
dp.Pages[2].Save(@"..\..\..\example.tiff", new ImageSaveOptions() { DpiX = 650, DpiY = 650 });
}
}
}
Imports SautinSoft.Document
Namespace Example
Friend Class Program
Shared Sub Main(ByVal args() As String)
ConvertPDFtoImages()
End Sub
''' <summary>
''' Convert PDF to Images (file to file).
''' </summary>
''' <remarks>
''' Details: https://sautinsoft.com/products/document/help/net/developer-guide/convert-pdf-to-images-in-csharp-vb.php
''' </remarks>
Private Shared Sub ConvertPDFtoImages()
' Path to a document where to extract pictures.
' By the way: You may specify DOCX, HTML, RTF files also.
Dim dc As DocumentCore = DocumentCore.Load("..\..\..\example.pdf")
' PaginationOptions allow to know, how many pages we have in the document.
Dim dp As DocumentPaginator = dc.GetPaginator(New PaginatorOptions())
' Each document page will be saved in its own image format: PNG, JPEG, TIFF with different DPI.
dp.Pages(0).Save("..\..\..\example.png", New ImageSaveOptions() With {
.DpiX = 800,
.DpiY = 800
})
dp.Pages(1).Save("..\..\..\example.jpeg", New ImageSaveOptions() With {
.DpiX = 400,
.DpiY = 400
})
dp.Pages(2).Save("..\..\..\example.tiff", New ImageSaveOptions() With {
.DpiX = 650,
.DpiY = 650
})
End Sub
End Class
End Namespace
If you need a new code example or have a question: email us at support@sautinsoft.com or ask at Online Chat (right-bottom corner of this page) or use the Form below: