The unique image identifier of the GdPictureImage object representing the required image. You need to add the image resource into the currently loaded PDF document, for example, using methods of the GdPictureImaging class, whose returned value is the unique image identifier.
A member of the PdfAdvancedImageCompression enumeration. Specifies the advanced compression mechanism.
Example





In This Topic
GdPicture14 Namespace / GdPicturePDF Class / AddImageFromGdPictureImage Method / AddImageFromGdPictureImage(Int32,PdfAdvancedImageCompression) Method

AddImageFromGdPictureImage(Int32,PdfAdvancedImageCompression) Method

In This Topic
Adds an image resource, specified by its unique image identifier, and then subsequently draws this image onto a newly created page within the currently loaded PDF document. You can obtain this identifier, for example, using methods of the GdPictureImaging class when you create the image resource using an object of the type GdPictureImage. You can also specify an advanced compression mechanism such as color detection or mixed raster content (MRC) compression when drawing an image. The dimensions of the newly added page are the same as the original dimensions of the inserted image and the page is inserted as the last page in the document.
Syntax
'Declaration
 
Public Overloads Function AddImageFromGdPictureImage( _
   ByVal ImageID As Integer, _
   ByVal AvancedCompression As PdfAdvancedImageCompression _
) As GdPictureStatus
public GdPictureStatus AddImageFromGdPictureImage( 
   int ImageID,
   PdfAdvancedImageCompression AvancedCompression
)
public function AddImageFromGdPictureImage( 
    ImageID: Integer;
    AvancedCompression: PdfAdvancedImageCompression
): GdPictureStatus; 
public function AddImageFromGdPictureImage( 
   ImageID : int,
   AvancedCompression : PdfAdvancedImageCompression
) : GdPictureStatus;
public: GdPictureStatus AddImageFromGdPictureImage( 
   int ImageID,
   PdfAdvancedImageCompression AvancedCompression
) 
public:
GdPictureStatus AddImageFromGdPictureImage( 
   int ImageID,
   PdfAdvancedImageCompression AvancedCompression
) 

Parameters

ImageID
The unique image identifier of the GdPictureImage object representing the required image. You need to add the image resource into the currently loaded PDF document, for example, using methods of the GdPictureImaging class, whose returned value is the unique image identifier.
AvancedCompression
A member of the PdfAdvancedImageCompression enumeration. Specifies the advanced compression mechanism.

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
This method is only allowed for use with non-encrypted documents.

Just to remind you, that the newly created page is always inserted as the last page in the loaded document.

Example
How to convert a multipage tif file to a PDF document using mixed raster content compression.
Dim caption As String = "Example: AddImageFromGdPictureImage"
Dim gdpictureImaging As New GdPictureImaging()
Dim imageID As Integer = gdpictureImaging.CreateGdPictureImageFromFile("multi_image.tif")
If gdpictureImaging.GetStat() = GdPictureStatus.OK Then
    Dim count As Integer = gdpictureImaging.GetPageCount(imageID)
    If gdpictureImaging.GetStat() = GdPictureStatus.OK Then
        Dim gdpicturePDF As New GdPicturePDF()
        If gdpicturePDF.NewPDF() = GdPictureStatus.OK Then
            Dim message As String = ""
            gdpicturePDF.SetMRCImageBackgroundResolution(100)
            gdpicturePDF.SetMRCPreserveSmoothing(False)
            For i As Integer = 1 To count
                message = message + "The image nr." + i.ToString()
                If (gdpictureImaging.SelectPage(imageID, i) = GdPictureStatus.OK) AndAlso
                   (gdpicturePDF.AddImageFromGdPictureImage(imageID, PdfAdvancedImageCompression.PdfAdvancedImageCompressionMRC) = GdPictureStatus.OK) Then
                    message = message + " has been successfully drawn." + vbCrLf
                Else
                    message = message + " has not been drawn - the last status is " + gdpicturePDF.GetStat().ToString() + "." + vbCrLf
                End If
            Next
            If gdpicturePDF.SaveToFile("test_AddImageFromGdPictureImage.pdf", True) = GdPictureStatus.OK Then
                message = message + "The file has been saved successfully."
            Else
                message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
            End If
            MessageBox.Show(message, caption)
        Else
            MessageBox.Show("The NewPDF() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
        End If
        gdpicturePDF.Dispose()
    Else
        MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpictureImaging.GetStat().ToString(), caption)
    End If
Else
    MessageBox.Show("The CreateGdPictureImageFromFile() method has failed with the status: " + gdpictureImaging.GetStat().ToString(), caption)
End If
gdpictureImaging.ReleaseGdPictureImage(imageID)
gdpictureImaging.Dispose()
string caption = "Example: AddImageFromGdPictureImage";
GdPictureImaging gdpictureImaging = new GdPictureImaging();
int imageID = gdpictureImaging.CreateGdPictureImageFromFile("multi_image.tif");
if (gdpictureImaging.GetStat() == GdPictureStatus.OK)
{
    int count = gdpictureImaging.GetPageCount(imageID);
    if (gdpictureImaging.GetStat() == GdPictureStatus.OK)
    {
        GdPicturePDF gdpicturePDF = new GdPicturePDF();
        if (gdpicturePDF.NewPDF() == GdPictureStatus.OK)
        {
            string message = "";
            gdpicturePDF.SetMRCImageBackgroundResolution(100);
            gdpicturePDF.SetMRCPreserveSmoothing(false);
            for (int i = 1; i <= count; i++)
            {
                message = message + "The image nr." + i.ToString();
                if ((gdpictureImaging.SelectPage(imageID, i) == GdPictureStatus.OK) &&
                    (gdpicturePDF.AddImageFromGdPictureImage(imageID, PdfAdvancedImageCompression.PdfAdvancedImageCompressionMRC) == GdPictureStatus.OK))
                    message = message + " has been successfully drawn.\n";
                else
                    message = message + " has not been drawn - the last status is " + gdpicturePDF.GetStat().ToString() + ".\n";
            }
            if (gdpicturePDF.SaveToFile("test_AddImageFromGdPictureImage.pdf", true) == GdPictureStatus.OK)
                message = message + "The file has been saved successfully.";
            else
                message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
            MessageBox.Show(message, caption);
        }
        else
            MessageBox.Show("The NewPDF() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
        gdpicturePDF.Dispose();
    }
    else
        MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpictureImaging.GetStat().ToString(), caption);
}
else
    MessageBox.Show("The CreateGdPictureImageFromFile() method has failed with the status: " + gdpictureImaging.GetStat().ToString(), caption);
gdpictureImaging.ReleaseGdPictureImage(imageID);
gdpictureImaging.Dispose();
See Also