←Select platform

DocumentRasterPage Class

Summary

Data for one raster page to be added to a document file.

Syntax

C#
VB
Java
Objective-C
C++
public class DocumentRasterPage : DocumentPage 
Public Class DocumentRasterPage  
   Inherits Leadtools.Forms.Documentwriters.DocumentPage 
@interface LTDocumentRasterPage : LTDocumentPage <NSCopying> 
public class DocumentRasterPage extends DocumentPage 
public ref class DocumentRasterPage : public Leadtools.Forms.Documentwriters.DocumentPage  

Remarks

The DocumentRasterPage structure contains the data for one raster image page to be added to a document file. It is used as a parameter to the DocumentWriter.AddPage or DocumentWriter.InsertPage methods used to add the page.

The DocumentRasterPage.Image property must contain a valid raster image (RasterImage) object that contains the visual representation of the page. This image object can obtained through multiple sources as explained in LEADTOOLS Document Writers.

DocumentRasterPage.Image is used as is when DocumentWriter.AddPage or DocumentWriter.InsertPage is called and the framework does not delete it. You must dispose the object when it is no longer used.

The LEADTOOLS Document Writer supports creating documents with zero or more empty pages inside them. Use DocumentWriter.AddPage or DocumentWriter.InsertPage with an DocumentEmptyPage with the dimension of the empty page set before hand in the DocumentOptions.EmptyPageWidth and DocumentOptions.EmptyPageHeight and its resolution set to DocumentOptions.EmptyPageResolution. As many empty pages as desired can be added in any index desired. To use empty pages, make sure the DocumentOptions.PageRestriction property is set to DocumentPageRestriction.Relaxed.

For more information, refer to PdfDocumentOptions.

Example

This example will create a PDF document with first page from SVG data, second page empty and third page from raster image.

C#
VB
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Forms.DocumentWriters; 
using Leadtools.Forms.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 DocumentSvgPage(); 
      using (svgPage.SvgDocument = codecs.LoadSvg(inputFileName, 1, null)) 
      { 
         // Add it 
         docWriter.AddPage(svgPage); 
      } 
 
      // Add a second page as empty 
      var emptyPage = new DocumentEmptyPage(); 
      emptyPage.Width = pageWidth; 
      emptyPage.Height = pageHeight; 
      docWriter.AddPage(emptyPage); 
 
      // Finally, add a third page as an image 
      var rasterPage = new DocumentRasterPage(); 
      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:\Users\Public\Documents\LEADTOOLS Images"; 
} 
Imports Leadtools 
Imports Leadtools.Codecs 
Imports Leadtools.Forms.DocumentWriters 
Imports Leadtools.Forms.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 DocumentSvgPage() 
      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 DocumentEmptyPage() 
      emptyPage.Width = pageWidth 
      emptyPage.Height = pageHeight 
      docWriter.AddPage(emptyPage) 
 
      ' Finally, add a third page as an image 
      Dim rasterPage As New DocumentRasterPage() 
      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:\Users\Public\Documents\LEADTOOLS Images" 
End Class 

Requirements

Target Platforms

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Forms.DocumentWriters Assembly