ImageGear .NET
Saving

ImGearFileFormats class provides the APIs needed to save a document/image. ImageGear only supports saving to a .NET Stream object that have the seek ability. If the save operation cannot be conducted, an exception with the following code is thrown: ImageGear.Core.ImGearErrorCodes.CANT_SAVE_FORMAT.

Save a Single Page

Use the SavePage method to a save a single page as follows:

C#
Copy Code
using System.IO;
using ImageGear.Core;
using ImageGear.Formats;
public void SavePageToFile(ImGearPage loadedPage, string outputFilePath)
{
     // Save to JPG file.
     using (FileStream fileStream = new FileStream(outputFilePath, FileMode.OpenOrCreate, FileAccess.ReadWrite))
     {
          ImGearFileFormats.SavePage(loadedPage, fileStream, 0, ImGearSavingModes.OVERWRITE, ImGearSavingFormats.JPG);
     }
}
VB.NET
Copy Code
Imports System.IO
Imports ImageGear.Core
Imports ImageGear.Formats
Public Sub SavePageToFile(loadedPage As ImGearPage, outputFilePath As String)
            ' Save to JPG file.
            Using fileStream As New FileStream(outputFilePath, FileMode.OpenOrCreate, FileAccess.ReadWrite)
                        ImGearFileFormats.SavePage(loadedPage, fileStream, 0, ImGearSavingModes.OVERWRITE, ImGearSavingFormats.JPG)
            End Using
End Sub

Save a Document (Multiple Pages as a Document)

For this purpose, use the SaveDocument method. See What's the Best Format for...? for a list of the multi-page formats supported by ImageGear .NET, for example, PDF:

C#
Copy Code
using System.IO;
using ImageGear.Core;
using ImageGear.Formats;
public void SaveDocumentToFile(ImGearDocument loadedPDFDocument, string outputFilePath)
{
     // Save to PDF file.
     using (FileStream fileStream = new FileStream(outputFilePath, FileMode.OpenOrCreate, FileAccess.ReadWrite))
     {
          ImGearFileFormats.SaveDocument(loadedPDFDocument, fileStream, 0, ImGearSavingModes.OVERWRITE, ImGearSavingFormats.PDF);
     }
}
VB.NET
Copy Code
Imports System.IO
Imports ImageGear.Core
Imports ImageGear.Formats
Public Sub SaveDocumentToFile(loadedPDFDocument As ImGearDocument, outputFilePath As String)
            ' Save to PDF file.
            Using fileStream As New FileStream(outputFilePath, FileMode.OpenOrCreate, FileAccess.ReadWrite)
                        ImGearFileFormats.SaveDocument(loadedPDFDocument, fileStream, 0, ImGearSavingModes.OVERWRITE, ImGearSavingFormats.PDF)
            End Using
End Sub

 

 


©2017. Accusoft Corporation. All Rights Reserved.

Send Feedback