ImageGear v26.0 - Updated
PDF to Multi-Page Image
Developer Guide > How to Work with ... > PDF > How to... > Convert... > PDF to Multi-Page Image

The following savePDFAsMultiplePageTIF sample illustrates how you can create a multi-page TIFF from a multi-page PDF loaded in an igDocument. In the following sample we use ImGearSavingModes to control some raster options like bit depth and scaling (to control resolution):

PDF support needs to be initialized first for this snippet to work. To get familiar with initializing IGNET, initializing PDF support, loading a PDF, saving a PDF, and terminating PDF support, try any one of the tutorials.

C#

using System.IO;

using ImageGear.Core;
using ImageGear.Formats;
using ImageGear.Formats.PDF;

public void savePDFAsMultiplePageTIF(ImGearDocument igDocument, string outfile)
{       
   // Set some raster options.
   ImGearRasterSaveOptions rasterOptions = new ImGearRasterSaveOptions();
   rasterOptions.BitDepth = 24;
   // Set scaling factor for rasterized image. Scale = 1 (default) corresponds to 72 dpi, 2 to 144 dpi, etc.
   rasterOptions.ScaleX = 4;
   rasterOptions.ScaleY = 4;
           
   // Save to TIF file.
   using (FileStream fileStream = new FileStream(outfile, FileMode.OpenOrCreate, FileAccess.ReadWrite))
   {
       ImGearFileFormats.SaveDocument(igDocument, fileStream, 0, ImGearSavingModes.OVERWRITE,    ImGearSavingFormats.TIF_DEFLATE, rasterOptions);
   }
}

In the following sample we use an alternative approach to the one above that uses global control parameters to control some raster options like bit depth and resolution:

PDF support needs to be initialized first for this snippet to work. To get familiar with initializing IGNET, initializing PDF support, loading a PDF, saving a PDF, and terminating PDF support, try any one of the tutorials.

C#

using System.IO;

using ImageGear.Core;
using ImageGear.Formats;
using ImageGear.Formats.PDF;

public void savePDFAsMultiplePageTIF(ImGearDocument igDocument, string outfile)
{
   // Change global control parameters for PDF resolution. ImGearSaveOptions in SaveDocument should be set to null.
   IImGearFormat pdfFilter = ImGearFileFormats.Filters.Get(ImGearFormats.PDF);

   ImGearControlParameter bitDepth = pdfFilter.Parameters.GetByName("Depth");
   ImGearControlParameter resolutionX = pdfFilter.Parameters.GetByName("ResolutionX");
   ImGearControlParameter resolutionY = pdfFilter.Parameters.GetByName("ResolutionY");
   bitDepth.Value = 24;
   resolutionX.Value = 300;
   resolutionY.Value = 300;

   // Save to TIF file.
   using (FileStream fileStream = new FileStream(outfile, FileMode.OpenOrCreate, FileAccess.ReadWrite))
   {
       ImGearFileFormats.SaveDocument(igDocument, fileStream, 0, ImGearSavingModes.OVERWRITE, ImGearSavingFormats.TIF_DEFLATE, null);
   }
}
Is this page helpful?
Yes No
Thanks for your feedback.