GdPicture.NET.14
GdPicture14 Namespace / GdPictureImaging Class / TiffSaveAsMultiPageFile Method / TiffSaveAsMultiPageFile(Int32,Stream,TiffCompression,Int32) Method
A unique image identifier of the GdPicture image representing the first page of the resulting multipage TIFF image file. Do not release this image resource before closing the resulting multipage TIFF image file using the TiffCloseMultiPageFile method.

Please follow the attached example on how to properly use the method.

A Stream object where the newly created multipage TIFF image file will be stored. This Stream object must be initialized before it can be sent into this method and it should remain open for subsequent use.
A member of the TiffCompression enumeration. The resulting TIFF compression scheme to be used.
The compression quality level from 0 to 100. 0 means the worst quality and the best compression, 100 means the best quality and the worst compression. This parameter is ignored when the required compression scheme is different than JPEG.
Example





In This Topic
TiffSaveAsMultiPageFile(Int32,Stream,TiffCompression,Int32) Method
In This Topic
Stores a specified GdPicture image, that is represented by its unique image identifier, as the first page of a new multipage TIFF image file to a given stream. You can also define a JPEG quality parameter when the JPEG compression is required using this method. You can subsequently add a new page to this image file using one of the TiffAddToMultiPageFile() methods, for example the TiffAddToMultiPageFile(Int32,Int32,TiffCompression,Int32) method.

This sequential writing is the faster way to create multipage TIFF image files by adding individual pages based on one page files.

Syntax
'Declaration
 
Public Overloads Function TiffSaveAsMultiPageFile( _
   ByVal ImageID As Integer, _
   ByVal Stream As Stream, _
   ByVal Compression As TiffCompression, _
   ByVal JpegQuality As Integer _
) As GdPictureStatus
public GdPictureStatus TiffSaveAsMultiPageFile( 
   int ImageID,
   Stream Stream,
   TiffCompression Compression,
   int JpegQuality
)
public function TiffSaveAsMultiPageFile( 
    ImageID: Integer;
    Stream: Stream;
    Compression: TiffCompression;
    JpegQuality: Integer
): GdPictureStatus; 
public function TiffSaveAsMultiPageFile( 
   ImageID : int,
   Stream : Stream,
   Compression : TiffCompression,
   JpegQuality : int
) : GdPictureStatus;
public: GdPictureStatus TiffSaveAsMultiPageFile( 
   int ImageID,
   Stream* Stream,
   TiffCompression Compression,
   int JpegQuality
) 
public:
GdPictureStatus TiffSaveAsMultiPageFile( 
   int ImageID,
   Stream^ Stream,
   TiffCompression Compression,
   int JpegQuality
) 

Parameters

ImageID
A unique image identifier of the GdPicture image representing the first page of the resulting multipage TIFF image file. Do not release this image resource before closing the resulting multipage TIFF image file using the TiffCloseMultiPageFile method.

Please follow the attached example on how to properly use the method.

Stream
A Stream object where the newly created multipage TIFF image file will be stored. This Stream object must be initialized before it can be sent into this method and it should remain open for subsequent use.
Compression
A member of the TiffCompression enumeration. The resulting TIFF compression scheme to be used.
JpegQuality
The compression quality level from 0 to 100. 0 means the worst quality and the best compression, 100 means the best quality and the worst compression. This parameter is ignored when the required compression scheme is different than JPEG.

Return Value

A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK. We strongly recommend always checking this status first.
Remarks
Please note that you need to close the resulting file using the TiffCloseMultiPageFile method when you finish aing pages. At the same, the output stream should be open for writing and should be closed/disposed of by the user as well.

Be aware that for accessing the data of the newly created image file you have to save, close and release the image resource, and then you need to reload it again, for example, using the CreateGdPictureImageFromFile(String).

This method requires the Image Documents component to run.

Example
Generating a multipage tiff using streams, from different image files, using specific compression mode per page.
using (GdPictureImaging gdpictureImaging = new GdPictureImaging())
{
    using (System.IO.Stream inputStream = new System.IO.FileStream("image.jpg", System.IO.FileMode.Open))
    {
        /*Adding first page from a jpeg file*/
        int tiffImageID = gdpictureImaging.CreateGdPictureImageFromStream(inputStream, GdPicture14.DocumentFormat.DocumentFormatJPEG); /* or "image.jpg"*/
 
        using (System.IO.Stream outputStream = new System.IO.FileStream("multipage.tif", System.IO.FileMode.CreateNew))
        {
            //After calling TiffSaveAsMultiPageFile, tiffID will specify the multipage tiff identifier.
            gdpictureImaging.TiffSaveAsMultiPageFile(tiffImageID, outputStream, TiffCompression.TiffCompressionJPEG, 75 /*Jpeg quality*/);
 
            using (System.IO.Stream nextStream = new System.IO.FileStream("image.png", System.IO.FileMode.Open))
            {
                /*Adding second page from a png file*/
                int imageID = gdpictureImaging.CreateGdPictureImageFromStream(nextStream, GdPicture14.DocumentFormat.DocumentFormatPNG); /* or "image.png"*/
                //Enabling horizontal differencing predictor mode for lzw compression.
                gdpictureImaging.TagSetValueString(imageID, Tags.TagPredictor, TagType.TagTypeShort, "2");
                gdpictureImaging.TiffAddToMultiPageFile(tiffImageID, imageID, TiffCompression.TiffCompressionLZW);
                gdpictureImaging.ReleaseGdPictureImage(imageID);
            }
 
            using (System.IO.Stream nextStream = new System.IO.FileStream("image.tif", System.IO.FileMode.Open))
            {
                /*Adding third page from a single page tiff-ccitt4 file*/
                int imageID = gdpictureImaging.CreateGdPictureImageFromStream(nextStream, GdPicture14.DocumentFormat.DocumentFormatTIFF); /* or "image.tif"*/
                gdpictureImaging.TiffAddToMultiPageFile(tiffImageID, imageID, TiffCompression.TiffCompressionCCITT4);
                gdpictureImaging.ReleaseGdPictureImage(imageID);
            }
 
            /*Closing the produced multipage file*/
            gdpictureImaging.TiffCloseMultiPageFile(tiffImageID);
        }
    }
}
See Also