internal static void Run() { // Create a PdfRasterizer object PdfRasterizer rasterizer = new PdfRasterizer(Util.GetResourcePath("DocumentA.pdf")); // Create a GifImageFormat object GifImageFormat GifImageFormat = new GifImageFormat(); // Set the dithering algorithm to FloydSteinberg GifImageFormat.DitheringAlgorithm = DitheringAlgorithm.FloydSteinberg; // Set the dithering percentage GifImageFormat.DitheringPercent = 100; // Set the palette type. GifImageFormat.ColorPalette = Palette.WebPalette; // Set the antialiasing to true GifImageFormat.AntiAliasing = true; // Create a image size tha is a fixed size FixedImageSize fixedImageSize = new FixedImageSize(595, 841); // Save the image rasterizer.Draw("GifWithWebPalette.Gif", GifImageFormat, fixedImageSize); }
internal static void Run() { // Create a PdfRasterizer object PdfRasterizer rasterizer = new PdfRasterizer(Util.GetResourcePath("DocumentA.pdf")); // Create a color array using custom colors Color[] color = new Color[] { Color.FromArgb(255, 0, 0, 0), Color.FromArgb(255, 255, 255, 255), Color.FromArgb(255, 255, 0, 0), Color.FromArgb(255, 0, 255, 0), Color.FromArgb(255, 0, 0, 255), Color.FromArgb(255, 255, 255, 0), Color.FromArgb(255, 0, 255, 255), Color.FromArgb(255, 255, 0, 255) }; // Create a UserPalette object using color array UserPalette userPalette = new UserPalette(color); // Create a PngIndexedColorFormat object using the palette PngIndexedColorFormat pngIndexedColorFormat = new PngIndexedColorFormat(userPalette, 100, DitheringAlgorithm.FloydSteinberg); // Create a PngImageFormat object using indexed color format object PngImageFormat pngImageFormat = new PngImageFormat(pngIndexedColorFormat); // Create a image size tha is a fixed size FixedImageSize fixedImageSize = new FixedImageSize(595, 841); // Save the image rasterizer.Draw("PngImageWithUserPalette.png", pngImageFormat, fixedImageSize); }
// Convert a PDF document to BMP images (one for each page). // Use the ceTe.DynamicPDF.Rasterizer namespace for the PdfRasterizer class. private static void PdfToBmp() { // Create a PdfRasterizer object using the source PDF to be converted to BMP images PdfRasterizer rasterizer = new PdfRasterizer(GetResourcePath("doc-a.pdf")); // Call the Draw method with output image name, image format and the DPI rasterizer.Draw("output.bmp", ImageFormat.Bmp, ImageSize.Dpi96); }
// Convert a PDF document to 4 GIF files (one for each page). // Use the ceTe.DynamicPDF.Rasterizer namespace for the PdfRasterizer class. static void Main(string[] args) { // Create a PdfRasterizer object using the source PDF to be converted to GIF image PdfRasterizer rasterizer = new PdfRasterizer(GetResourcePath("doc-a.pdf")); // Call the Draw method with output image name, image format and the DPI rasterizer.Draw("output.gif", ImageFormat.Gif, ImageSize.Dpi600); }
// Convert a PDF document to TIFF images (one for each page). // Use the ceTe.DynamicPDF.Rasterizer namespace for the PdfRasterizer class. private static void PdfToTiff() { // Create a PdfRasterizer object using the source PDF to be converted to TIFF image PdfRasterizer rasterizer = new PdfRasterizer(GetResourcePath("doc-a.pdf")); // Call the Draw method with output image name, image format and the DPI rasterizer.Draw("EachPage.tiff", ImageFormat.TiffWithLzw, ImageSize.Dpi150); }
// Convert a PDF document to PNG images (one for each page). // Use the ceTe.DynamicPDF.Rasterizer namespace for the PdfRasterizer class. private static void PdfToPng() { // Create a PdfRasterizer object using the source PDF to be converted to PNG image PdfRasterizer rasterizer = new PdfRasterizer(GetResourcePath("doc-a.pdf")); // Call the Draw method with output image name, image format and the DPI rasterizer.Draw("output.png", ImageFormat.Png, ImageSize.Dpi300); }
internal static void Run() { // Create a PdfRasterizer object PdfRasterizer rasterizer = new PdfRasterizer(Util.GetResourcePath("DocumentA.pdf")); // Create a image size tha is a fixed size FixedImageSize fixedImageSize = new FixedImageSize(595, 841); // Create a PngImageFormat object with RGB color PngImageFormat pngImageFormat = new PngImageFormat(PngColorFormat.Rgb); // Save the image rasterizer.Draw("PngImageWithRgbColor.png", pngImageFormat, fixedImageSize); }
/// <summary> /// From NuGet, named ceTe.DynamicPDF.Rasterizer.NET /// Online https://www.dynamicpdf.com/Rasterizer-PDF-.NET.aspx /// To note: https://www.dynamicpdf.com/docs/dotnet/rasterizer-limitations /// Example https://www.dynamicpdf.com/docs/dotnet/cete.dynamicpdf.rasterizer.pdfrasterizer /// </summary> /// <param name="pathToFile"></param> /// <param name="pathToSaveTo"></param> public void RasterisePdf(string pathToFile, string pathToSaveTo) { // Create a PdfRasterizer object. PdfRasterizer rasterizer = new PdfRasterizer(pathToFile); // Save the image. //TiffImageFormat.TiffWithLzw rasterizer.Draw( //FileHelper.PrepareOutputDirectoryAndFileName(pathToFile, pathToSaveTo), FileHelper.PrepareOutputDirectoryAndFileName( FileHelper.FileNameForImage("DynamicPDF", pathToFile, null), pathToSaveTo), PngImageFormat.Png, ImageSize.Dpi72); }
internal static void Run() { // Create a PdfRasterizer object PdfRasterizer rasterizer = new PdfRasterizer(Util.GetResourcePath("DocumentA.pdf")); // Create a JpegImageFormat object JpegImageFormat jpegImageFormat = new JpegImageFormat(100); // Create a image size tha is a fixed size FixedImageSize fixedImageSize = new FixedImageSize(595, 841); // Save the image rasterizer.Draw("JpegImage.jpg", jpegImageFormat, fixedImageSize); }
internal static void Run() { // Create a PdfRasterizer object PdfRasterizer rasterizer = new PdfRasterizer(Util.GetResourcePath("DocumentA.pdf")); // Create a BmpMonochromeColorFormat object BmpMonochromeColorFormat bmpMonochromeColorFormat = new BmpMonochromeColorFormat(DitheringAlgorithm.FloydSteinberg, 100); // Create a BmpImageFormat object with the bmpMonochromeColorFormat BmpImageFormat bmpImageFormat = new BmpImageFormat(bmpMonochromeColorFormat); // Create a image size tha is a fixed size FixedImageSize fixedImageSize = new FixedImageSize(595, 841); // Save the image rasterizer.Draw("MonochromeImage.bmp", bmpImageFormat, fixedImageSize); }
internal static void Run() { // Create a PdfRasterizer object PdfRasterizer rasterizer = new PdfRasterizer(Util.GetResourcePath("DocumentA.pdf")); // Create a image size tha is a fixed size FixedImageSize fixedImageSize = new FixedImageSize(595, 841); // Create a TiffMonochromeColorFormat object with CCIT Group 3 compression. TiffMonochromeColorFormat tiffColorFormat = new TiffMonochromeColorFormat(TiffMonochromeCompressionType.CcitGroup3); // Create a TiffImageFormat object with monocrome color TiffImageFormat tiffImageFormat = new TiffImageFormat(tiffColorFormat); // Save the image rasterizer.Draw("TiffImageColorFormat.tif", tiffImageFormat, fixedImageSize); }
internal static void Run() { // Create a PdfRasterizer object PdfRasterizer rasterizer = new PdfRasterizer(Util.GetResourcePath("DocumentA.pdf")); // Create the GifImageFormat object. GifImageFormat gifImageFormat = new GifImageFormat(); // Set the dithering algorithm to FloydSteinberg gifImageFormat.DitheringAlgorithm = DitheringAlgorithm.FloydSteinberg; // Set the dithering percentage gifImageFormat.DitheringPercent = 100; // Create a image size tha is a fixed size FixedImageSize fixedImageSize = new FixedImageSize(595, 841); // Save the image rasterizer.Draw("IndexedImage.Gif", gifImageFormat, fixedImageSize); }
internal static void Run() { // Get a byte array containing the source PDF byte[] pdfArray = System.IO.File.ReadAllBytes(Util.GetResourcePath("PortFolio.pdf")); // Create an input PDF from the byte array InputPdf inputPdf = new InputPdf(pdfArray); // Get an array of the attachments in the input PDF Attachment[] files = inputPdf.Attachments; // Gets the first attachment as a PDF if it is a PDF file InputPdf inputPdfFile = files[0].TryGetPdf(); // Create a PdfRasterizer object PdfRasterizer rasterizer = new PdfRasterizer(inputPdfFile); // Save the image rasterizer.Draw("PdfPortfolio.png", ImageFormat.Png, ImageSize.Dpi96); }