DocumentWriterRasterPage Class
Summary
Data for one raster page to be added to a document file.
Syntax
C#
VB
Objective-C
C++
Java
@interface LTDocumentWriterRasterPage : LTDocumentPage <NSCopying>
public class DocumentWriterRasterPage extends DocumentWriterPage
Example
This example will create a PDF document with first page from SVG data, second page empty and third page from raster image.
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Document.Writer;
using Leadtools.Ocr;
public void DocumentRasterPageExample()
{
// Input file name
var inputFileName = Path.Combine(LEAD_VARS.ImagesDir, "Leadtools.docx");
// Output PDF file name
var outputFileName = Path.Combine(LEAD_VARS.ImagesDir, "Example.pdf");
// Create a new instance of the LEADTOOLS Document Writer
var docWriter = new DocumentWriter();
// Setup a new RasterCodecs object
using (var codecs = new RasterCodecs())
{
codecs.Options.RasterizeDocument.Load.Resolution = 300;
// Get information on the page
double pageWidth;
double pageHeight;
using (var info = codecs.GetInformation(inputFileName, false, 1))
{
// Get the size in inches, we need it for the empty page
pageWidth = info.Document.PageWidth;
pageHeight = info.Document.PageHeight;
}
// Begin the document
docWriter.BeginDocument(outputFileName, DocumentFormat.Pdf);
// Add the first page from SVG
var svgPage = new DocumentWriterSvgPage();
using (svgPage.SvgDocument = codecs.LoadSvg(inputFileName, 1, null))
{
// Add it
docWriter.AddPage(svgPage);
}
// Add a second page as empty
var emptyPage = new DocumentWriterEmptyPage();
emptyPage.Width = pageWidth;
emptyPage.Height = pageHeight;
docWriter.AddPage(emptyPage);
// Finally, add a third page as an image
var rasterPage = new DocumentWriterRasterPage();
using (rasterPage.Image = codecs.Load(inputFileName, 1))
{
// Add it
docWriter.AddPage(rasterPage);
}
}
// Finally finish writing the HTML file on disk
docWriter.EndDocument();
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\LEADTOOLS21\Resources\Images";
}
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.Document.Writer
Imports Leadtools.Ocr
Public Sub DocumentRasterPageExample()
' Input file name
Dim inputFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Leadtools.docx")
' Output PDF file name
Dim outputFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Example.pdf")
' Create a new instance of the LEADTOOLS Document Writer
Dim docWriter As New DocumentWriter()
' Setup a new RasterCodecs object
Using codecs As New RasterCodecs()
codecs.Options.RasterizeDocument.Load.Resolution = 300
' Get information on the page
Dim pageWidth As Double
Dim pageHeight As Double
Using info As CodecsImageInfo = codecs.GetInformation(inputFileName, False, 1)
' Get the size in inches, we need it for the empty page
pageWidth = info.Document.PageWidth
pageHeight = info.Document.PageHeight
End Using
' Begin the document
docWriter.BeginDocument(outputFileName, DocumentFormat.Pdf)
' Add the first page from SVG
Dim svgPage As New DocumentWriterSvgPage()
svgPage.SvgDocument = codecs.LoadSvg(inputFileName, 1, Nothing)
' Add it
docWriter.AddPage(svgPage)
svgPage.SvgDocument.Dispose()
' Add a second page as empty
Dim emptyPage As New DocumentWriterEmptyPage()
emptyPage.Width = pageWidth
emptyPage.Height = pageHeight
docWriter.AddPage(emptyPage)
' Finally, add a third page as an image
Dim rasterPage As New DocumentWriterRasterPage()
rasterPage.Image = codecs.Load(inputFileName, 1)
' Add it
docWriter.AddPage(rasterPage)
rasterPage.Image.Dispose()
End Using
' Finally finish writing the HTML file on disk
docWriter.EndDocument()
End Sub
Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\LEADTOOLS21\Resources\Images"
End Class