GdPicture.NET.14
GdPicture14 Namespace / GdPicturePDF Class / RenderPageToGdPictureImageEx Method / RenderPageToGdPictureImageEx(Single,Boolean,Double) Method
The dpi resolution to be used for rendering. If the page is entirely image-based, means the whole page is only one image, the original (for the given image) dpi resolution is used instead.

A value of 72 will give the same result as Acrobat when the zoom level is 100%. Values over 300 will cause excessive memory usage.

Set this parameter to true, if you also want to render form fields and annotations included within the page, else set it to false.
Example





In This Topic
RenderPageToGdPictureImageEx(Single,Boolean,Double) Method
In This Topic
Renders the currently selected page of the loaded PDF document to an image resource according to what you have specified. The current page is converted to an image, which is subsequently stored as an object of the type GdPictureImage. The produced image is in the 32-bit ARGB pixel format.

The method's behavior is specific for entirely image-based pages, where the whole page area is covered by a single image, so that the whole image is extracted "as is" in its original bit depth with the original dpi. Additionally, if a rotation is applied to the current page, the resulting image is extracted with the applied rotation as well.

The created image is clearly recognizable by the returned unique image identifier and you can take advantages of the GdPictureImaging class and its methods for further manipulation with this object.

Syntax
'Declaration
 
Public Overloads Function RenderPageToGdPictureImageEx( _
   ByVal DPI As Single, _
   ByVal RenderFormFields As Boolean, _
   Optional ByVal TimeoutMilliseconds As Double _
) As Integer
public int RenderPageToGdPictureImageEx( 
   float DPI,
   bool RenderFormFields,
   double TimeoutMilliseconds
)
public function RenderPageToGdPictureImageEx( 
    DPI: Single;
    RenderFormFields: Boolean;
    TimeoutMilliseconds: Double
): Integer; 
public function RenderPageToGdPictureImageEx( 
   DPI : float,
   RenderFormFields : boolean,
   TimeoutMilliseconds : double
) : int;
public: int RenderPageToGdPictureImageEx( 
   float DPI,
   bool RenderFormFields,
   double TimeoutMilliseconds
) 
public:
int RenderPageToGdPictureImageEx( 
   float DPI,
   bool RenderFormFields,
   double TimeoutMilliseconds
) 

Parameters

DPI
The dpi resolution to be used for rendering. If the page is entirely image-based, means the whole page is only one image, the original (for the given image) dpi resolution is used instead.

A value of 72 will give the same result as Acrobat when the zoom level is 100%. Values over 300 will cause excessive memory usage.

RenderFormFields
Set this parameter to true, if you also want to render form fields and annotations included within the page, else set it to false.
TimeoutMilliseconds

Return Value

A unique image identifier of the GdPictureImage object representing the newly created image resource. The GetStat method can be subsequently used to determine if this method has been successful.

Be aware that you need to release the image after being used, for the suitable method please refer to the Remarks section below.

Remarks
This method is only allowed for use with non-encrypted documents.

It is recommend to use the GetStat method to identify the specific reason for the method's failure, if any instead of checking the returned value.

Likewise just to remind you that you need to release the image after being used using either the ReleaseGdPictureImage method or the static DisposeImage method.

For entirely image-based pages, please consider using the %RenderPageToGdPictureImage(float, bool)% method or its overloads if you need to change the resulting dpi.

Example
How to render all pages of the PDF document to PNG formatted images.
Dim caption As String = "Example: RenderPageToGdPictureImageEx"
Dim gdpicturePDF As New GdPicturePDF()
Dim gdpictureImaging As New GdPictureImaging()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
    Dim count As Integer = gdpicturePDF.GetPageCount()
    Dim status As GdPictureStatus = gdpicturePDF.GetStat()
    If status = GdPictureStatus.OK Then
        Dim message As String = ""
        Dim image_index As Integer = 0
        Dim filename As String = "image_page0.png"
        For i As Integer = 1 To count
            status = gdpicturePDF.SelectPage(i)
            If status = GdPictureStatus.OK Then
                image_index = gdpicturePDF.RenderPageToGdPictureImageEx(72, True)
                status = gdpicturePDF.GetStat()
                If status = GdPictureStatus.OK Then
                    filename = filename.Replace((i - 1).ToString(), i.ToString())
                    status = gdpictureImaging.SaveAsPNG(image_index, filename)
                    If status = GdPictureStatus.OK Then
                        message = message + "The image of the page nr." + i.ToString() + " has been successfully saved." + vbCrLf
                    Else
                        message = message + "The SaveAsPNG() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
                    End If
                    gdpictureImaging.ReleaseGdPictureImage(image_index)
                    'Or you can use this one:
                    'GdPictureDocumentUtilities.DisposeImage(image_index)
                Else
                    message = message + "The RenderPageToGdPictureImageEx() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
                End If
            Else
                message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
            End If
        Next
        MessageBox.Show(message, caption)
    Else
        MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption)
    End If
Else
    MessageBox.Show("The file can't be loaded.", caption)
End If
gdpictureImaging.Dispose()
gdpicturePDF.Dispose()
string caption = "Example: RenderPageToGdPictureImageEx";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureImaging gdpictureImaging = new GdPictureImaging();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
    int count = gdpicturePDF.GetPageCount();
    GdPictureStatus status = gdpicturePDF.GetStat();
    if (status == GdPictureStatus.OK)
    {
        string message = "";
        int image_index = 0;
        string filename = "image_page0.png";
        for (int i = 1; i <= count; i++)
        {
            status = gdpicturePDF.SelectPage(i);
            if (status == GdPictureStatus.OK)
            {
                image_index = gdpicturePDF.RenderPageToGdPictureImageEx(72, true);
                status = gdpicturePDF.GetStat();
                if (status == GdPictureStatus.OK)
                {
                    filename = filename.Replace((i - 1).ToString(), i.ToString());
                    status = gdpictureImaging.SaveAsPNG(image_index, filename);
                    if (status == GdPictureStatus.OK)
                        message = message + "The image of the page nr." + i.ToString() + " has been successfully saved.\n";
                    else
                        message = message + "The SaveAsPNG() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
                    gdpictureImaging.ReleaseGdPictureImage(image_index);
                    //Or you can use this one:
                    //GdPictureDocumentUtilities.DisposeImage(image_index);
                }
                else
                    message = message + "The RenderPageToGdPictureImageEx() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
            }
            else
                message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
        }
        MessageBox.Show(message, caption);
    }
    else
        MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption);
}
else
    MessageBox.Show("The file can't be loaded.", caption);
gdpictureImaging.Dispose();
gdpicturePDF.Dispose();
See Also

Reference

GdPicturePDF Class
GdPicturePDF Members
Overload List
GetPageThumbnail(Int32,Int32,Color) Method
RenderPageToGdPictureImage(float, bool)
RenderPageToGdPictureImage(float, bool, bool)