←Select platform

RasterCodecsTemplate Property


Global template used when loading and saving raster and SVG images.

public static RasterCodecs RasterCodecsTemplate { get; set; } 
Public Shared Property RasterCodecsTemplate() As RasterCodecs 
   static property RasterCodecs^ RasterCodecsTemplate 
      RasterCodecs^ get() 
      void set(RasterCodecs^ value) 
public static RasterCodecs getRasterCodecsTemplate() 
public void sasterCodecs getRasterCodecsTemplate(static value) 

Property Value

The global RasterCodecs template to use when loading and saving raster and SVG images. Default is a RasterCodecs object with the value of CodecsRasterizeDocumentLoadOptions.Resolution set to 300.


The RasterCodecs class is used throughout the Document library to load and save RasterImage and SvgDocument objects. This class contain various options to control how the data is loaded and processed. For example, setting the resolution (DPI) to use when rasterizing a text-based PDF file.

When a new LEADDocument object is created by this factory, a new RasterCodecs object is created and set in RasterCodecs is then checked and if it is not null, then the options are copied from and set to LEADDocument.RasterCodecs using CodecsOptions.Clone. This way, the library guarantees that the same global options set by the user in RasterCodecsTemplate are used throughout the application.

The Document library is thread safe while a single RasterCodecs object is not and cannot be used by multiple threads at the same time, therefore, the library will internally create instances of RasterCodecs and disposes them as needed (for example, when calling DocumentPage.GetImage to get the raster image representation of a page.

Whenever this happens, the library will copy the options from LEADDocument.RasterCodecs into the options of the temporarily created RasterCodecs object using CodecsOptions.Clone. This way, the library guarantees that the same global options set by the user in RasterCodecsTemplate are used throughout the application if needed while the options can be changed for each LEADDocument individually.


This examples shows how to use RasterCodecsTemplate to change the resolution used when loading document files.

using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Document.Writer; 
using Leadtools.Svg; 
using LeadtoolsExamples.Common; 
using Leadtools.Document; 
using Leadtools.Caching; 
using Leadtools.Annotations.Engine; 
using Leadtools.Ocr; 
using Leadtools.Barcode; 
using Leadtools.Document.Converter; 
public static void DocumentFactoryRasterCodecsTemplateExample() 
   DocumentFactory.RasterCodecsTemplate.Options.RasterizeDocument.Load.XResolution = 100; 
   DocumentFactory.RasterCodecsTemplate.Options.RasterizeDocument.Load.YResolution = 100; 
   var options = new LoadDocumentOptions(); 
   using (var document = DocumentFactory.LoadFromFile(Path.Combine(ImagesPath.Path, "Leadtools.pdf"), options)) 
      foreach (var page in document.Pages) 
         Console.WriteLine("Page (" + page.PageNumber + ") - Resolution: " + page.Resolution); 
Imports Leadtools 
Imports Leadtools.Codecs 
Imports Leadtools.Document.Writer 
Imports Leadtools.Svg 
Imports Leadtools.Document 
Imports Leadtools.Caching 
Imports Leadtools.Annotations.Engine 
Imports Leadtools.Barcode 
Imports Leadtools.Ocr 
Imports LeadtoolsDocumentExamples.LeadtoolsExamples.Common 
Imports Leadtools.Document.Converter 
Public Shared Sub DocumentFactoryRasterCodecsTemplateExample() 
   DocumentFactory.RasterCodecsTemplate.Options.RasterizeDocument.Load.XResolution = 100 
   DocumentFactory.RasterCodecsTemplate.Options.RasterizeDocument.Load.YResolution = 100 
   Dim options As New LoadDocumentOptions() 
   Using document As Leadtools.Document.LEADDocument = DocumentFactory.LoadFromFile(Path.Combine(ImagesPath.Path, "Leadtools.pdf"), options) 
      For Each page As Leadtools.Document.DocumentPage In document.Pages 
         Console.WriteLine("Page (" & page.PageNumber & ") - Resolution: " & page.Resolution) 
      Next page 
   End Using 
End Sub 


Target Platforms

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

Leadtools.Document Assembly