public enum CodecsRasterPdfVersion typedef NS_ENUM(NSInteger, LTCodecsRasterPdfVersion) {LTCodecsRasterPdfVersionV12,LTCodecsRasterPdfVersionV14,LTCodecsRasterPdfVersionPdfA,LTCodecsRasterPdfVersionV15,LTCodecsRasterPdfVersionV16,LTCodecsRasterPdfVersionV13,LTCodecsRasterPdfVersionV17,};
public enum CodecsRasterPdfVersion public enum class CodecsRasterPdfVersion class CodecsRasterPdfVersion(Enum):V12 = 0V14 = 1PdfA = 2V15 = 3V16 = 4V13 = 5V17 = 6
| Value | Member | Description |
|---|---|---|
| 0 | V12 |
Adobe Acrobat PDF version 1.2 |
| 1 | V14 |
Adobe Acrobat PDF version 1.4 |
| 2 | PdfA |
Adobe Acrobat PDF/A. PDF/A is a subset of the PDF standard that contains only those features that are suited for long-term archival. Primarily this means that the document will be completely self-contained: it includes all content, font and color information |
| 3 | V15 |
Adobe Acrobat PDF version 1.5 |
| 4 | V16 |
Adobe Acrobat PDF version 1.6 |
| 5 | V13 |
Adobe Acrobat PDF version 1.3 |
| 6 | V17 |
Adobe Acrobat PDF version 1.7 |
Used as value for CodecsRasterPdfInfo.Version to determine the version of the raster PDF file and CodecsPdfSaveOptions.Version to specify the version of the raster PDF file to save.
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 fileCreateMultiPageRasterPdfFile(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 compressionusing (RasterCodecs codecs = new RasterCodecs()){int pagesSaved = 0;// Get the file informationusing (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 compressionif (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 parameterscodecs.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 optionscodecs.Options.Pdf.Save.UseImageResolution = true;codecs.Options.Pdf.Save.Version = pdfInfo.Version;// Save this page to a separate filestring pagePdfFileName = string.Format(pagesPdfFileNames, pageNumber);codecs.Save(pageImage, pagePdfFileName, pdfInfo.Format, pdfInfo.BitsPerPixel);pagesSaved++;}}}}}// We are done, now show the info of the generated filesfor (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 existsif (System.IO.File.Exists(pdfFileName)){System.IO.File.Delete(pdfFileName);}using (RasterCodecs codecs = new RasterCodecs()){// Save to PDF v1.4codecs.Options.Pdf.Save.Version = CodecsRasterPdfVersion.V14;// Save using image resolutioncodecs.Options.Pdf.Save.UseImageResolution = true;// Load the source file to use for each pageusing (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 pagesint[] 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 formatDebug.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:\LEADTOOLS23\Resources\Images";}
import java.io.*;import java.net.*;import java.nio.file.Paths;import java.util.*;import java.time.Instant;import java.time.Duration;import org.junit.*;import org.junit.runner.JUnitCore;import org.junit.runner.Result;import org.junit.runner.notification.Failure;import static org.junit.Assert.*;import leadtools.*;import leadtools.codecs.*;import leadtools.codecs.RasterCodecs.FeedCallbackThunk;import leadtools.drawing.internal.*;import leadtools.imageprocessing.*;import leadtools.imageprocessing.color.ChangeIntensityCommand;import leadtools.svg.*;public void codecsRasterPdfInfoExample() throws IOException {final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images";String multiPageRasterPdfFileName = combine(LEAD_VARS_IMAGES_DIR, "MultiPageRasterPdf.pdf");String pagesPdfFileNames = combine(LEAD_VARS_IMAGES_DIR, "Page%s.pdf");// Create a 4 pages PDF filecreateMultiPageRasterPdfFile(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// compressionRasterCodecs codecs = new RasterCodecs();int pagesSaved = 0;// Get the file informationCodecsImageInfo imageInfo = codecs.getInformation(multiPageRasterPdfFileName, true);System.out.printf("Information: Format:%n Format: %s%n Pages: %s%n Bits/Pixel: %s%n Size: %S%n by %s%n Resolution: %s by %s%n",imageInfo.getFormat(), imageInfo.getTotalPages(), imageInfo.getBitsPerPixel(), imageInfo.getWidth(),imageInfo.getHeight(), imageInfo.getXResolution(), imageInfo.getYResolution());System.out.println("-----------------------");// Now show the PDF specific information// Notice: GetInformation will return RasPdf as the format for all PDF files// regardless of the actual compressionif (imageInfo.getFormat() == RasterImageFormat.RAS_PDF) {System.out.println("Image is PDF, getting the specific info for each page");ILeadStream multiPageRasterStream = LeadStreamFactory.create(multiPageRasterPdfFileName);for (int i = 0; i < imageInfo.getTotalPages(); i++) {int pageNumber = i + 1;CodecsRasterPdfInfo pdfInfo = codecs.getRasterPdfInfo(multiPageRasterStream, i + 1);if (pageNumber == 1) {System.out.println(" LEAD PDF?: " + pdfInfo.isLeadPdf());System.out.println(" Version: " + pdfInfo.getVersion());}if (pdfInfo.isLeadPdf()) {System.out.printf("Page %s of %s info:%n Bits/Pixel: %s%n Size: %s by %s%n Resolution: %s by %s%n Format: %s%n",pageNumber, imageInfo.getTotalPages(), pdfInfo.getBitsPerPixel(), pdfInfo.getWidth(),pdfInfo.getHeight(), pdfInfo.getXResolution(), pdfInfo.getYResolution(), pdfInfo.getFormat());System.out.println("-----------------------");// Load this page with its original parameterscodecs.getOptions().getRasterizeDocument().getLoad().setXResolution(pdfInfo.getXResolution());codecs.getOptions().getRasterizeDocument().getLoad().setYResolution(pdfInfo.getYResolution());codecs.getOptions().getPdf().getLoad().setDisplayDepth(pdfInfo.getBitsPerPixel());RasterImage pageImage = codecs.load(multiPageRasterPdfFileName, 0, CodecsLoadByteOrder.BGR_OR_GRAY,pageNumber, pageNumber);System.out.printf("Page %s of %s loaded:%n Bits/Pixel: %s%n Size: %s by %s%n Resolution: %s by %s%n",pageNumber, imageInfo.getTotalPages(), pageImage.getBitsPerPixel(), pageImage.getWidth(),pageImage.getHeight(), pageImage.getXResolution(), pageImage.getYResolution());System.out.println("-----------------------");// Setup the PDF save optionscodecs.getOptions().getPdf().getSave().setUseImageResolution(true);codecs.getOptions().getPdf().getSave().setVersion(pdfInfo.getVersion());// Save this page to a separate fileString pagePdfFileName = String.format(pagesPdfFileNames, pageNumber);codecs.save(pageImage, pagePdfFileName, pdfInfo.getFormat(), pdfInfo.getBitsPerPixel());pagesSaved++;}}multiPageRasterStream.close();}// We are done, now show the info of the generated filesfor (int i = 0; i < pagesSaved; i++) {int pageNumber = i + 1;String pagePdfFileName = String.format(pagesPdfFileNames, pageNumber);ILeadStream pagePdfFileStream = LeadStreamFactory.create(pagePdfFileName);CodecsRasterPdfInfo pdfInfo = codecs.getRasterPdfInfo(pagePdfFileStream, 1);System.out.printf("Page %s of %s info:%n Bits/Pixel: %s%n Size: %s by %s%n Resolution: %s by %s%n Format: %s%n",pageNumber, pagesSaved, pdfInfo.getBitsPerPixel(), pdfInfo.getWidth(), pdfInfo.getHeight(),pdfInfo.getXResolution(), pdfInfo.getYResolution(), pdfInfo.getFormat());System.out.println("-----------------------");pagePdfFileStream.close();}}private static void createMultiPageRasterPdfFile(String pdfFileName) {final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images";String sourceFile = combine(LEAD_VARS_IMAGES_DIR, "Sample1.cmp");// Delete the destination PDF file if existsFile pdfFile = new File(pdfFileName);if (pdfFile.exists()) {pdfFile.delete();}RasterCodecs codecs = new RasterCodecs();// Save to PDF v1.4codecs.getOptions().getPdf().getSave().setVersion(CodecsRasterPdfVersion.V14);// Save using image resolutioncodecs.getOptions().getPdf().getSave().setUseImageResolution(true);// Load the source file to use for each pageRasterImage pageImage = codecs.load(sourceFile, 0, CodecsLoadByteOrder.BGR_OR_GRAY, 1, 1);System.out.printf("Original image dimension:%n Size: %s by %s%n Resolution: %s by %s%n",pageImage.getWidth(), pageImage.getHeight(), pageImage.getXResolution(), pageImage.getYResolution());// Array of bits/pixel and compression to use when saving the pagesint[] bitsPerPixel = { 1, 8, 24 };RasterImageFormat[] formats = { RasterImageFormat.RAS_PDF_G4, RasterImageFormat.RAS_PDF_LZW,RasterImageFormat.RAS_PDF_JPEG };int pageCount = bitsPerPixel.length;for (int i = 0; i < pageCount; i++) {// Append this page with given formatSystem.out.printf("Saving page %s of %s using %s at %s", i + 1, pageCount, bitsPerPixel[i], formats[i]);codecs.save(pageImage, pdfFileName, formats[i], bitsPerPixel[i], 1, 1, -1, CodecsSavePageMode.APPEND);}System.out.println("-----------------------");}
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
