public CodecsRasterPdfVersion Version { get; set; }
@property (nonatomic, assign) LTCodecsRasterPdfVersion version;
public CodecsRasterPdfVersion getVersion()
public void setVersion(CodecsRasterPdfVersion value)
public:
property CodecsRasterPdfVersion Version {
CodecsRasterPdfVersion get();
void set ( CodecsRasterPdfVersion );
}
Version # get and set (CodecsRasterPdfInfo)
One of the CodecsRasterPdfVersion enumeration members that indicate the version of the PDF file. The default value is V12
.
This is the same value as CodecsPdfSaveOptions.Version used when saving this file with the RasterCodecs.Save method.
This property is guaranteed to contain accurate information only if the value of IsLeadPdf is true.
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Color;
using Leadtools.Svg;
private static void CodecsRasterPdfInfoExample()
{
string multiPageRasterPdfFileName = Path.Combine(LEAD_VARS.ImagesDir, "MultiPageRasterPdf.pdf");
string pagesPdfFileNames = Path.Combine(LEAD_VARS.ImagesDir, "Page{0}.pdf");
// Create a 4 pages PDF file
CreateMultiPageRasterPdfFile(multiPageRasterPdfFileName);
// Without prior information, we will split this multi-page PDF file into
// multiple single page PDF files with original size, resolution, bit-depth and compression
using (RasterCodecs codecs = new RasterCodecs())
{
int pagesSaved = 0;
// Get the file information
using (CodecsImageInfo imageInfo = codecs.GetInformation(multiPageRasterPdfFileName, true))
{
Debug.WriteLine(
"Information: Format:\n Format: {0}\n Pages: {1}\n Bits/Pixel: {2}\n Size: {3} by {4}\n Resolution: {5} by {6}",
imageInfo.Format, imageInfo.TotalPages, imageInfo.BitsPerPixel, imageInfo.Width, imageInfo.Height, imageInfo.XResolution, imageInfo.YResolution);
Debug.WriteLine("-----------------------");
// Now show the PDF specific information
// Notice: GetInformation will return RasPdf as the format for all PDF files
// regardless of the actual compression
if (imageInfo.Format == RasterImageFormat.RasPdf)
{
Debug.WriteLine("Image is PDF, getting the specific info for each page");
for (int i = 0; i < imageInfo.TotalPages; i++)
{
int pageNumber = i + 1;
CodecsRasterPdfInfo pdfInfo = codecs.GetRasterPdfInfo(multiPageRasterPdfFileName, i + 1);
if (pageNumber == 1)
{
Debug.WriteLine(" LEAD PDF?: {0}", pdfInfo.IsLeadPdf);
Debug.WriteLine(" Version: {0}", pdfInfo.Version);
}
if (pdfInfo.IsLeadPdf)
{
Debug.WriteLine(
"Page {0} of {1} info:\n Bits/Pixel: {2}\n Size: {3} by {4}\n Resolution: {5} by {6}\n Format: {7}",
pageNumber, imageInfo.TotalPages, pdfInfo.BitsPerPixel, pdfInfo.Width, pdfInfo.Height, pdfInfo.XResolution, pdfInfo.YResolution, pdfInfo.Format);
Debug.WriteLine("-----------------------");
// Load this page with its original parameters
codecs.Options.RasterizeDocument.Load.XResolution = pdfInfo.XResolution;
codecs.Options.RasterizeDocument.Load.YResolution = pdfInfo.YResolution;
codecs.Options.Pdf.Load.DisplayDepth = pdfInfo.BitsPerPixel;
using (RasterImage pageImage = codecs.Load(multiPageRasterPdfFileName, 0, CodecsLoadByteOrder.BgrOrGray, pageNumber, pageNumber))
{
Debug.WriteLine(
"Page {0} of {1} loaded:\n Bits/Pixel: {2}\n Size: {3} by {4}\n Resolution: {5} by {6}",
pageNumber, imageInfo.TotalPages, pageImage.BitsPerPixel, pageImage.Width, pageImage.Height, pageImage.XResolution, pageImage.YResolution);
Debug.WriteLine("-----------------------");
// Setup the PDF save options
codecs.Options.Pdf.Save.UseImageResolution = true;
codecs.Options.Pdf.Save.Version = pdfInfo.Version;
// Save this page to a separate file
string pagePdfFileName = string.Format(pagesPdfFileNames, pageNumber);
codecs.Save(pageImage, pagePdfFileName, pdfInfo.Format, pdfInfo.BitsPerPixel);
pagesSaved++;
}
}
}
}
}
// We are done, now show the info of the generated files
for (int i = 0; i < pagesSaved; i++)
{
int pageNumber = i + 1;
string pagePdfFileName = string.Format(pagesPdfFileNames, pageNumber);
CodecsRasterPdfInfo pdfInfo = codecs.GetRasterPdfInfo(pagePdfFileName, 1);
Debug.WriteLine(
"Page {0} of {1} info:\n Bits/Pixel: {2}\n Size: {3} by {4}\n Resolution: {5} by {6}\n Format: {7}",
pageNumber, pagesSaved, pdfInfo.BitsPerPixel, pdfInfo.Width, pdfInfo.Height, pdfInfo.XResolution, pdfInfo.YResolution, pdfInfo.Format);
Debug.WriteLine("-----------------------");
}
}
}
private static void CreateMultiPageRasterPdfFile(string pdfFileName)
{
string sourceFile = Path.Combine(LEAD_VARS.ImagesDir, "Sample1.cmp");
// Delete the destination PDF file if exists
if (System.IO.File.Exists(pdfFileName))
{
System.IO.File.Delete(pdfFileName);
}
using (RasterCodecs codecs = new RasterCodecs())
{
// Save to PDF v1.4
codecs.Options.Pdf.Save.Version = CodecsRasterPdfVersion.V14;
// Save using image resolution
codecs.Options.Pdf.Save.UseImageResolution = true;
// Load the source file to use for each page
using (RasterImage pageImage = codecs.Load(sourceFile, 0, CodecsLoadByteOrder.BgrOrGray, 1, 1))
{
Debug.WriteLine(
"Original image dimension:\n Size: {0} by {1}\n Resolution: {2} by {3}",
pageImage.Width, pageImage.Height, pageImage.XResolution, pageImage.YResolution);
// Array of bits/pixel and compression to use when saving the pages
int[] bitsPerPixel =
{
1,
8,
24
};
RasterImageFormat[] formats =
{
RasterImageFormat.RasPdfG4,
RasterImageFormat.RasPdfLzw,
RasterImageFormat.RasPdfJpeg422
};
int pageCount = bitsPerPixel.Length;
for (int i = 0; i < pageCount; i++)
{
// Append this page with given format
Debug.WriteLine("Saving page {0} of {1} using {2} at {3}", i + 1, pageCount, bitsPerPixel[i], formats[i]);
codecs.Save(pageImage, pdfFileName, formats[i], bitsPerPixel[i], 1, 1, -1, CodecsSavePageMode.Append);
}
}
Debug.WriteLine("-----------------------");
}
}
static class LEAD_VARS
{
public const string ImagesDir = @"C:\LEADTOOLS22\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