ImageGear for .NET
Saving to Raster Formats

ImageGear for .NET provides the ImGearRasterSaveOptions class that defines options for saving vector pages and documents to raster formats. This class is derived from the regular ImGearSaveOptions class and could be used with the regular ImGearFileFormats.SavePage and ImGearFileFormats.SaveDocument methods that take ImGearSaveOptions parameter.

The following sample code demonstrates how to use the ImGearRasterSaveOptions class for saving vector PDF document to TIF:

C# Example
Copy Code
        ImGearDocument doc = null;
        // Load PDF document.
        using (FileStream fileStream = new FileStream(infile, FileMode.Open, FileAccess.Read, FileShare.Read))
        {
            doc = ImGearFileFormats.LoadDocument(fileStream, 0, -1);
        }
        // Specify raster options for saving.
        ImGearRasterSaveOptions rasterOptions = new ImGearRasterSaveOptions();
        rasterOptions.BitDepth = 24;
        rasterOptions.ScaleX = 2.0;
        rasterOptions.ScaleY = 2.0;
        // Save to TIF file.
        using (FileStream fileStream = new FileStream(outfile, FileMode.OpenOrCreate, FileAccess.ReadWrite))
        {
            ImGearFileFormats.SaveDocument(doc, fileStream, 0, ImGearSavingModes.OVERWRITE, ImGearSavingFormats.TIF_DEFLATE, rasterOptions);
        }
VB.NET Example
Copy Code
        Dim doc As ImGearDocument
        ' Load PDF document.
        Using fileStream As FileStream = New FileStream(infile, FileMode.Open, FileAccess.Read, FileShare.Read)
            doc = ImGearFileFormats.LoadDocument(fileStream, 0, -1)
        End Using
        ' Specify raster options for saving.
        Dim rasterOptions As ImGearRasterSaveOptions = New ImGearRasterSaveOptions()
        rasterOptions.BitDepth = 24
        rasterOptions.ScaleX = 2.0
        rasterOptions.ScaleY = 2.0
        ' Save to TIF file.
        Using fileStream As FileStream = New FileStream(outfile, FileMode.OpenOrCreate, FileAccess.ReadWrite)
            ImGearFileFormats.SaveDocument(doc, fileStream, 0, ImGearSavingModes.OVERWRITE, ImGearSavingFormats.TIF_DEFLATE, rasterOptions)
        End Using

 

 

 


©2015. Accusoft Corporation. All Rights Reserved.

Send Feedback