←Select platform

Image Property

Summary
The raster image representation of the page.
Syntax
C#
Objective-C
C++/CLI
Java
Python
public RasterImage Image { get; set; } 
@property (nonatomic, strong) LTRasterImage *image; 
public RasterImage getImage() 
public void setImage(RasterImage image) 
public: 
property RasterImage^ Image { 
   RasterImage^ get(); 
   void set (    RasterImage^ ); 
} 
Image # get and set (DocumentWriterRasterPage) 

Property Value

An RasterImage that contains the image representation of the page.

Remarks

The Image property must contain a RasterImage object --it cannot be null. This image object is used in the DocumentWriter.AddPage or DocumentWriter.InsertPage methods to create the visual representation of the new page added to the document being created.

The LEADTOOLS Document Writer toolkit will not use the RasterImage object after the call to DocumentWriter.AddPage or DocumentWriter.InsertPage returns. This handle needs to be disposed to free the resources associated with it by the user.

The raster image objects can be obtained from multiple sources as explained in LEADTOOLS Document Writers.

The LEADTOOLS Document Writer supports creating documents with zero or more empty pages inside them. Simply pass a page of type DocumentWriterEmptyPage to DocumentWriter.AddPage or DocumentWriter.InsertPage methods. The dimension of the empty page must be 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 and in any index desired. To use empty pages, make sure the DocumentOptions.PageRestriction property is set to DocumentPageRestriction.Relaxed.

Example
C#
Java
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, "TEST.docx"); 
 
   // Output PDF file name 
   var outputFileName = Path.Combine(LEAD_VARS.ImagesDir, "out_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:\LEADTOOLS23\Resources\Images"; 
} 
 
import java.io.File; 
import java.io.IOException; 
 
import org.junit.*; 
import org.junit.runner.JUnitCore; 
import org.junit.runner.Result; 
import org.junit.runner.notification.Failure; 
import static org.junit.Assert.*; 
 
import leadtools.codecs.*; 
import leadtools.document.writer.*; 
 
 
public void documentRasterPageExample() { 
   final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images"; 
   String inputFileName = combine(LEAD_VARS_IMAGES_DIR, "LEADTOOLSEditor.docx"); 
   String outputFileName = combine(LEAD_VARS_IMAGES_DIR, "DocumentRasterExample.pdf"); 
 
   // Create a new instance of the LEADTOOLS Document Writer 
   DocumentWriter docWriter = new DocumentWriter(); 
 
   // Setup a new RasterCodecs object 
   RasterCodecs codecs = new RasterCodecs(); 
   codecs.getOptions().getRasterizeDocument().getLoad().setResolution(300); 
 
   // Get information on the page 
   double pageWidth; 
   double pageHeight; 
   CodecsImageInfo info = codecs.getInformation(inputFileName, false, 1); 
 
   // Get the size in inches, we need it for the empty page 
   pageWidth = info.getDocument().getPageWidth(); 
   pageHeight = info.getDocument().getPageHeight(); 
   info = null; 
 
   // Begin the document 
   docWriter.beginDocument(outputFileName, DocumentFormat.PDF); 
 
   // Add the first page from SVG 
   DocumentWriterSvgPage svgPage = new DocumentWriterSvgPage(); 
   svgPage.setSvgDocument(codecs.loadSvg(inputFileName, 1, null)); 
 
   // Add it 
   docWriter.addPage(svgPage); 
   svgPage.setSvgDocument(null); 
 
   // Add a second page as empty 
   DocumentWriterEmptyPage emptyPage = new DocumentWriterEmptyPage(); 
   emptyPage.setWidth(pageWidth); 
   emptyPage.setHeight(pageHeight); 
   docWriter.addPage(emptyPage); 
 
   assertTrue(emptyPage.getWidth() == pageWidth); 
   assertTrue(emptyPage.getHeight() == pageHeight); 
 
   // Finally, add a third page as an image 
   DocumentWriterRasterPage rasterPage = new DocumentWriterRasterPage(); 
   rasterPage.setImage(codecs.load(inputFileName, 1)); 
 
   // Add it 
   docWriter.addPage(rasterPage); 
   rasterPage.setImage(null); 
 
   // Finally finish writing the HTML file on disk 
   docWriter.endDocument(); 
   assertTrue((new File(outputFileName)).exists()); 
} 
Requirements

Target Platforms

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Document.Writer Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.