public class CodecsPdfOptions
Public Class CodecsPdfOptions
@interface LTCodecsPdfOptions : NSObject
public class CodecsPdfOptions
public ref class CodecsPdfOptions
To load or save PDF documents to/from a raster image in LEADTOOLS, use the Leadtools.Pdf.dll assembly. This is the file filter for the PDF format (as well as Postscript and Enhanced Postscript). Use this assembly as any other file filter in LEADTOOLS, such as Leadtools.Codecs.Bmp.dll for BMP support and Leadtools.Codecs.Tif.dll for TIF support.
In addition to Leadtools.Pdf.dll, the Leadtools.Pdf.Utilities.dll assembly is required in the following situations:
When loading Postscript (PS) or Enhanced Postscript (EPS) files. This is always needed regardless of the value of the UsePdfEngine option described below.
When the value of CodecsPdfLoadOptions.UsePdfEngine is set to true (the default value is false). When this option is used, then LEADTOOLS will use both Leadtools.Pdf.dll and Leadtools.Pdf.Utilities.dll when loading PDF files. This is provided for legacy support.
Leadtools.Pdf.Utilities.dll contains many resources such as tables and fonts required to render a PDF image (if one of the options above is satisfied and also always for PS and EPS files). This DLL is not referenced in a direct way by the file filter; instead it is loaded dynamically and out of a process if needed. You must ensure that this DLL is present on the machine. By default, it is required to have this DLL in the same directory where the file filter is located. However, to share many instances of the Leadtools.Pdf.Utilities.dll assembly between many applications, use the CodecsPdfOptions.InitialPath property.
Note that if the application does not required PDF Engine, for example, the application is only loading and saving PDF files as raster images. Then, Leadtools.Pdf.Utilities.dll is not required to be present on the machine. Leadtools.Pdf.dll is always required regardless.
using Leadtools;
using Leadtools.Codecs;
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");
codecs.Options.Pdf.InitialPath = @"C:\MyApp\Bin";
// 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.
codecs.Options.Pdf.Load.DisplayDepth = 24;
codecs.Options.Pdf.Load.GraphicsAlpha = 4;
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;
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
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;
// 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);
}
}
else
{
Console.WriteLine("PDF Engine is not found!");
}
// Clean up
codecs.Dispose();
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\LEADTOOLS21\Resources\Images";
}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document