GdPicture.NET.14
GdPicture14 Namespace / GdPictureDocumentConverter Class / PageRange Property
Example





In This Topic
PageRange Property (GdPictureDocumentConverter)
In This Topic
Specifies individual pages or page intervals related to the loaded document for further processing.

The required page numbers need to be defined in the matching pattern, for example use the string of "1-5" for pages 1 to 5, or use the string of "1,5,6" to specify pages 1 and 5 and 6. You can use the string of "1,5,8-12" to specify pages 1, 5, 8 and all pages from page 8 to page 12, etc.

Syntax
'Declaration
 
Public Property PageRange As String
public string PageRange {get; set;}
public read-write property PageRange: String; 
public function get,set PageRange : String
public: __property string* get_PageRange();
public: __property void set_PageRange( 
   string* value
);
public:
property String^ PageRange {
   String^ get();
   void set (    String^ value);
}

Property Value

The default value is the string of "*", which means all pages.
Example
The first example shows you how to load only the first page of the source document you want to convert.

The second example shows you how to convert and save only the first page of the loaded source document.

Using gdpictureDocumentConverter As New GdPictureDocumentConverter()
    'Only the first page is loaded.
    gdpictureDocumentConverter.PageRange = "1"
    'Please try to use also a multi-page document.
    Dim status As GdPictureStatus = gdpictureDocumentConverter.LoadFromFile("test_doc.docx", GdPicture14.DocumentFormat.DocumentFormatDOCX)
    If status = GdPictureStatus.OK Then
        MessageBox.Show("The file has been loaded successfully.", "GdPicture")
        status = gdpictureDocumentConverter.SaveAsPDF("load_first_page.pdf", PdfConformance.PDF)
        If status = GdPictureStatus.OK Then
            MessageBox.Show("The file has been saved successfully.", "GdPicture")
        Else
            MessageBox.Show("The file has failed to save. Status: " + status.ToString(), "GdPicture")
        End If
    Else
        MessageBox.Show("The file has failed to load. Status: " + status.ToString(), "GdPicture")
    End If
End Using
using (GdPictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter())
{
    //Only the first page is loaded.
    gdpictureDocumentConverter.PageRange = "1";
    //Please try to use also a multi-page document.
    GdPictureStatus status = gdpictureDocumentConverter.LoadFromFile("test_doc.docx", GdPicture14.DocumentFormat.DocumentFormatDOCX);
    if (status == GdPictureStatus.OK)
    {
        MessageBox.Show("The file has been loaded successfully.", "GdPicture");
        status = gdpictureDocumentConverter.SaveAsPDF("load_first_page.pdf", PdfConformance.PDF);
        if (status == GdPictureStatus.OK)
        {
            MessageBox.Show("The file has been saved successfully.", "GdPicture");
        }
        else
        {
            MessageBox.Show("The file has failed to save. Status: " + status.ToString(), "GdPicture");
        }
    }
    else
    {
        MessageBox.Show("The file has failed to load. Status: " + status.ToString(), "GdPicture");
    }
}
Using gdpictureDocumentConverter As New GdPictureDocumentConverter()
    'Please try to use also a multi-page document.
    Dim status As GdPictureStatus = gdpictureDocumentConverter.LoadFromFile("test_doc.docx", GdPicture14.DocumentFormat.DocumentFormatDOCX)
    If status = GdPictureStatus.OK Then
        MessageBox.Show("The file has been loaded successfully.", "GdPicture")
        'Only the first page is saved.
        gdpictureDocumentConverter.PageRange = "1"
        status = gdpictureDocumentConverter.SaveAsPDF("save_first_page.pdf", PdfConformance.PDF)
        If status = GdPictureStatus.OK Then
            MessageBox.Show("The file has been saved successfully.", "GdPicture")
        Else
            MessageBox.Show("The file has failed to save. Status: " + status.ToString(), "GdPicture")
        End If
    Else
        MessageBox.Show("The file has failed to load. Status: " + status.ToString(), "GdPicture")
    End If
End Using
using (GdPictureDocumentConverter gdpictureDocumentConverter = new GdPictureDocumentConverter())
{
    //Please try to use also a multi-page document.
    GdPictureStatus status = gdpictureDocumentConverter.LoadFromFile("test_doc.docx", GdPicture14.DocumentFormat.DocumentFormatDOCX);
    if (status == GdPictureStatus.OK)
    {
        MessageBox.Show("The file has been loaded successfully.", "GdPicture");
        //Only the first page is saved.
        gdpictureDocumentConverter.PageRange = "1";
        status = gdpictureDocumentConverter.SaveAsPDF("save_first_page.pdf", PdfConformance.PDF);
        if (status == GdPictureStatus.OK)
        {
            MessageBox.Show("The file has been saved successfully.", "GdPicture");
        }
        else
        {
            MessageBox.Show("The file has failed to save. Status: " + status.ToString(), "GdPicture");
        }
    }
    else
    {
        MessageBox.Show("The file has failed to load. Status: " + status.ToString(), "GdPicture");
    }
}
See Also