ImageGear .NET - Updated
PDF to Multi-Page Image
User 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):

C#
Copy Code
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);
   }
}
VB.NET
Copy Code
Public Sub savePDFAsMultiplePageTIF(igDocument As ImGearDocument, outfile As String)
   ' Set some raster options.
   Dim rasterOptions As 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 As New FileStream(outfile, FileMode.OpenOrCreate, FileAccess.ReadWrite)
       ImGearFileFormats.SaveDocument(igDocument, fileStream, 0, ImGearSavingModes.OVERWRITE, ImGearSavingFormats.TIF_DEFLATE, rasterOptions)
   End Using
End Sub

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:

C#
Copy Code
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);
   }
}
VB.NET
Copy Code
Public Sub savePDFAsMultiplePageTIF2(igDocument As ImGearDocument, outfile As String)
   ' Change global control parameters for PDF resolution. ImGearSaveOptions in SaveDocument should be set to null.
   Dim pdfFilter As IImGearFormat = ImGearFileFormats.Filters.[Get](ImGearFormats.PDF)

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

   ' Save to TIF file.
   Using fileStream As New FileStream(outfile, FileMode.OpenOrCreate, FileAccess.ReadWrite)
       ImGearFileFormats.SaveDocument(igDocument, fileStream, 0, ImGearSavingModes.OVERWRITE, ImGearSavingFormats.TIF_DEFLATE, Nothing)
   End Using
End Sub