Provides extra options for loading and saving PDF images.
Object Model
Syntax
Visual Basic (Declaration) | |
---|
Public Class CodecsPdfOptions |
C# | |
---|
public class CodecsPdfOptions |
C++/CLI | |
---|
public ref class CodecsPdfOptions |
Example
Visual Basic | Copy Code |
---|
Public Sub CodecsPdfOptionsExample()
Dim codecs As New RasterCodecs()
Dim srcFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "PDFSegmentation.pdf")
Dim destFileName1 As String = Path.Combine(LEAD_VARS.ImagesDir, "PdfOptions.pdf")
Dim destFileName2 As String = Path.Combine(LEAD_VARS.ImagesDir, "PdfOptions.bmp")
' Check if the PDF engine is installed then get the load and save options of the PDF files.
If codecs.Options.Pdf.IsEngineInstalled Then
' 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.Enabled = True
codecs.Options.RasterizeDocument.Load.XResolution = 150
codecs.Options.RasterizeDocument.Load.YResolution = 150
Using image As RasterImage = 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 the image back as PDF
codecs.Save(image, destFileName1, RasterImageFormat.RasPdf, 24)
End Using
' And load it back before saving it as BMP
Using image As RasterImage = codecs.Load(destFileName1)
codecs.Save(image, destFileName2, RasterImageFormat.Bmp, image.BitsPerPixel)
End Using
Else
Console.WriteLine("PDF Engine is not found!")
End If
' Clean up
codecs.Dispose()
End Sub
Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class |
C# | Copy Code |
---|
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");
// 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.Enabled = true;
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 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:\Users\Public\Documents\LEADTOOLS Images";
} |
SilverlightCSharp | Copy Code |
---|
|
SilverlightVB | Copy Code |
---|
|
Remarks
Inheritance Hierarchy
Requirements
Target Platforms: Silverlight, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7, MAC OS/X (Intel Only)
See Also