GetPageWidth Method (GdPicturePDF)
In This Topic
Returns the page width of the currently selected page in the loaded PDF document expressed in the current units used in this document.
You can simply use the GetMeasurementUnit method to determine the currently defined units or you can easily use the SetMeasurementUnit method to reset the units according to your preference.
Syntax
'Declaration
Public Function GetPageWidth() As Single
public float GetPageWidth()
public function GetPageWidth(): Single;
public function GetPageWidth() : float;
public: float GetPageWidth();
public:
float GetPageWidth();
Return Value
The page width expressed in the current units specified by the SetMeasurementUnit method. The
GetStat method can be subsequently used to determine if this method has been successful.
Be aware that any potential page rotation is not respected. The returned value is always the original page width value, that has been set when adding the page.
Example
How to find out the page width of the currently selected page in the loaded PDF document. This example shows you that the page rotation is not respected when
determining the page width.
Dim caption As String = "Example: GetPageWidth"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.NewPDF() = GdPictureStatus.OK Then
Dim status As GdPictureStatus = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) 'A4 = (210mm x 270mm)
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
Dim width As Single = gdpicturePDF.GetPageWidth()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The width of the current page is " + width.ToString() + " mm.", caption)
Else
MessageBox.Show("The GetPageWidth() method has failed with the status: " + status.ToString(), caption)
End If
status = gdpicturePDF.RotatePage(90)
If status = GdPictureStatus.OK Then
width = gdpicturePDF.GetPageWidth()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The width of the current page after the rotation is " + width.ToString() + " mm.", caption)
Else
MessageBox.Show("The GetPageWidth() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The RotatePage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetPageWidth";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.NewPDF() == GdPictureStatus.OK)
{
GdPictureStatus status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4); //A4 = (210mm x 270mm)
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
float width = gdpicturePDF.GetPageWidth();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
MessageBox.Show("The width of the current page is " + width.ToString() + " mm." , caption);
else
MessageBox.Show("The GetPageWidth() method has failed with the status: " + status.ToString(), caption);
status = gdpicturePDF.RotatePage(90);
if (status == GdPictureStatus.OK)
{
width = gdpicturePDF.GetPageWidth();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
MessageBox.Show("The width of the current page after the rotation is " + width.ToString() + " mm.", caption);
else
MessageBox.Show("The GetPageWidth() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The RotatePage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
Example
How to find out the page width of the currently selected page in the loaded PDF document. This example shows you that the page rotation is not respected when
determining the page width.
Dim caption As String = "Example: GetPageWidth"
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.NewPDF() = GdPictureStatus.OK Then
Dim status As GdPictureStatus = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) 'A4 = (210mm x 270mm)
If status = GdPictureStatus.OK Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
Dim width As Single = gdpicturePDF.GetPageWidth()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The width of the current page is " + width.ToString() + " mm.", caption)
Else
MessageBox.Show("The GetPageWidth() method has failed with the status: " + status.ToString(), caption)
End If
status = gdpicturePDF.RotatePage(90)
If status = GdPictureStatus.OK Then
width = gdpicturePDF.GetPageWidth()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
MessageBox.Show("The width of the current page after the rotation is " + width.ToString() + " mm.", caption)
Else
MessageBox.Show("The GetPageWidth() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The RotatePage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: GetPageWidth";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.NewPDF() == GdPictureStatus.OK)
{
GdPictureStatus status = gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4); //A4 = (210mm x 270mm)
if (status == GdPictureStatus.OK)
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
float width = gdpicturePDF.GetPageWidth();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
MessageBox.Show("The width of the current page is " + width.ToString() + " mm." , caption);
else
MessageBox.Show("The GetPageWidth() method has failed with the status: " + status.ToString(), caption);
status = gdpicturePDF.RotatePage(90);
if (status == GdPictureStatus.OK)
{
width = gdpicturePDF.GetPageWidth();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
MessageBox.Show("The width of the current page after the rotation is " + width.ToString() + " mm.", caption);
else
MessageBox.Show("The GetPageWidth() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The RotatePage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The NewPage() method has failed with the status: " + status.ToString(), caption);
}
else
MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
See Also