←Select platform

InitialPath Property

Gets and sets the path to the PDF engine runtime DLL.
public string InitialPath { get; set; } 
public String getInitialPath() 
public void setInitialPath(String value) 
property String^ InitialPath { 
   String^ get(); 
   void set (    String^ ); 
InitialPath # get and set (CodecsPdfOptions) 

Property Value

The path to the PDF runtime files, or an empty string or null, if the default location is to be used.


The value of this property is used only when Leadtools.Pdf.Utilities.dll is used by the application. For more information, refer to Implementing PDF Features.

The PDF engine runtime DLL is Leadtools.Pdf.Utilities.dll. This DLL is never referenced directly by the LEADTOOLS Raster PDF file filter (Leadtools.Pdf.dll) or PDF document readers (Leadtools.DocumentReaders.Pdf) instead it is loaded dynamically and out of process by the filter.

By default, the LEADTOOLS installer will copy this DLL next to the filter (in the Bin\DotNet\Win32, Bin\DotNet\x64, Bin\DotNet4\Win32 and Bin\DotNet4\x64 folders) and the filter will look for the engine DLL in the same folder it is located (default location).

In some cases, you can share the same copy of Leadtools.Pdf.Utilities.dll between different applications. For example, many ASP.NET web applications, in this case, you can copy Leadtools.Pdf.Utilities.dll to a fixed directory on your server and pass the name of this directory to InitialPath. From this point on, LEADTOOLS will use this value to locate and load Leadtools.Pdf.Utilities.dll.

Leadtools.Pdf.Utilities.dll is not a standard .NET assembly. In some project types, such as web applications or services, the compiler will not copy this file to your binary folder even though you have a reference to it in your project. This could cause PDF files to fail to load since IIS will create a temporary folder and copy all other LEADTOOLS referenced assemblies to service a request, but it will not copy Leadtools.Pdf.Utilities.dll. So, when using PDF in a web application, you must always use InitialPath to instruct LEADTOOLS on the location of the PDF engine DLL.

Note that setting this value in a RasterCodecs object will affect all the RasterCodecs objects that are currently created in the application (in all threads) or will be created in the future, for example:

RasterCodecs codecs1 = new RasterCodecs(); 
codecs1.Options.Pdf.InitialPath = @"C:\MyApp\Bin"; 
RasterCodecs codecs2 = new RasterCodecs(); 
// This will work even though the RasterCodecs object that set this value has been disposed. 
System.Diagnostics.Debug.Assert(codecs2.Options.Pdf.InitialPath == @"C:\MyApp\Bin"); 
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing.Core; 
public void CodecsPdfOptionsExample() 
   RasterCodecs codecs = new RasterCodecs(); 
   string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "PDFSegmentation.pdf"); 
   string destFileName1 = Path.Combine(LEAD_VARS.ImagesDir, "PdfOptions.pdf"); 
   string destFileName2 = Path.Combine(LEAD_VARS.ImagesDir, "PdfOptions.bmp"); 
   CodecsImageInfo info = codecs.GetInformation(srcFileName, true); 
   codecs.Options.Pdf.InitialPath = @"C:\MyApp\Bin"; 
   info = codecs.GetInformation(srcFileName, true); 
   Debug.WriteLine("Information for: {0}", srcFileName); 
   Debug.WriteLine(string.Format("Document: {0}", info.Document)); // CodecsDocumentImageInfo reference 
   Debug.WriteLine(string.Format("Document: {0}", info.Document.IsDocumentFile)); 
   Debug.WriteLine(string.Format("Document: {0}", info.Document.PageHeight)); 
   Debug.WriteLine(string.Format("Document: {0}", info.Document.PageWidth)); 
   Debug.WriteLine(string.Format("Document: {0}", info.Document.Unit)); 
   Debug.WriteLine(string.Format("Document: {0}", info.IsGray8Alpha)); 
   Debug.WriteLine(string.Format("Palette: {0}", info.GetPalette())); 
   // Check if the PDF engine is installed then get the load and save options of the PDF files. 
   if (codecs.Options.Pdf.IsEngineInstalled) 
      // Resulting image pixel depth. 
      // CodecsPdfOptions & CodecsPdfLoadOptions reference 
      codecs.Options.Pdf.Load.DisplayDepth = 24; 
      codecs.Options.Pdf.Load.GraphicsAlpha = 4; 
      codecs.Options.Pdf.Load.DisableCieColors = false; 
      codecs.Options.Pdf.Load.DisableCropping = false; 
      codecs.Options.Pdf.Load.EnableInterpolate = false; 
      codecs.Options.Pdf.Load.Password = ""; 
      // Type of font anti-aliasing to use. 
      codecs.Options.Pdf.Load.TextAlpha = 1; 
      codecs.Options.Pdf.Load.UseLibFonts = true; 
      // Horizontal,vertical  display resolution in dots per inch. 
      codecs.Options.RasterizeDocument.Load.XResolution = 150; 
      codecs.Options.RasterizeDocument.Load.YResolution = 150; 
      // CodecsRasterizeDocumentOptions & CodecsRasterizeDocumentLoadOptions reference 
      codecs.Options.RasterizeDocument.Load.BottomMargin = 0.1; 
      codecs.Options.RasterizeDocument.Load.LeftMargin = 0.1; 
      codecs.Options.RasterizeDocument.Load.PageHeight = 11; 
      codecs.Options.RasterizeDocument.Load.PageWidth = 8.5; 
      codecs.Options.RasterizeDocument.Load.Resolution = 150; 
      codecs.Options.RasterizeDocument.Load.RightMargin = 1.25; 
      codecs.Options.RasterizeDocument.Load.SizeMode = CodecsRasterizeDocumentSizeMode.None; // CodecsRasterizeDocumentSizeMode Enumeration reference 
      codecs.Options.RasterizeDocument.Load.TopMargin = 1.0; 
      codecs.Options.RasterizeDocument.Load.Unit = CodecsRasterizeDocumentUnit.Pixel; // CodecsRasterizeDocumentUnit Enumeration reference 
      using (RasterImage image = codecs.Load(srcFileName, 0, CodecsLoadByteOrder.BgrOrGray, 1, 1)) 
         // Set access rights for the user when he\she opens the file we create 
         // CodecsPdfSaveOptions reference 
         codecs.Options.Pdf.Save.AssembleDocument = true; 
         codecs.Options.Pdf.Save.ExtractText = true; 
         codecs.Options.Pdf.Save.ExtractTextGraphics = true; 
         codecs.Options.Pdf.Save.PrintDocument = false; 
         codecs.Options.Pdf.Save.FillForm = true; 
         codecs.Options.Pdf.Save.ModifyAnnotation = true; 
         codecs.Options.Pdf.Save.ModifyDocument = true; 
         codecs.Options.Pdf.Save.OwnerPassword = "LEAD Technologies"; 
         codecs.Options.Pdf.Save.PrintFaithful = false; 
         codecs.Options.Pdf.Save.TextEncoding = CodecsPdfTextEncoding.Hex; 
         codecs.Options.Pdf.Save.Use128BitEncryption = true; 
         codecs.Options.Pdf.Save.UserPassword = "LEAD"; 
         // Set the PDF version to be v1.4 
         codecs.Options.Pdf.Save.Version = CodecsRasterPdfVersion.V14; 
         // Save it as linearized (optimized for web view) 
         codecs.Options.Pdf.Save.Linearized = true; 
         codecs.Options.Pdf.Save.LowMemoryUsage = false; 
         codecs.Options.Pdf.Save.SavePdfA = false; 
         codecs.Options.Pdf.Save.SavePdfv13 = false; 
         codecs.Options.Pdf.Save.SavePdfv14 = false; 
         codecs.Options.Pdf.Save.SavePdfv15 = false; 
         codecs.Options.Pdf.Save.SavePdfv16 = false; 
         codecs.Options.Pdf.Save.SavePdfv17 = false; 
         codecs.Options.Pdf.Save.UseImageResolution = true; 
         // Save the image back as PDF 
         codecs.Save(image, destFileName1, RasterImageFormat.RasPdf, 24); 
      // And load it back before saving it as BMP 
      using (RasterImage image = codecs.Load(destFileName1)) 
         codecs.Save(image, destFileName2, RasterImageFormat.Bmp, image.BitsPerPixel); 
      Debug.WriteLine("PDF Engine is not found!"); 
   // Clean up 
static class LEAD_VARS 
   public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; 

Target Platforms

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

Leadtools.Codecs Assembly

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