SetPageUserUnit Method (GdPicturePDF)
In This Topic
Sets the user space unit value defined for the currently selected page in the loaded PDF document. It is the positive number specifying the size of default user space units, in multiples of 1/72 inch. The default value is 1.
Please note that you need to create or load the PDF document properly to set the valid value, otherwise the method does nothing. At the same, the specified value only relates to the currently selected page.
Syntax
'Declaration
Public Sub SetPageUserUnit( _
ByVal As Single _
)
public void SetPageUserUnit(
float
)
public procedure SetPageUserUnit(
: Single
);
public function SetPageUserUnit(
: float
);
public: void SetPageUserUnit(
float
)
public:
void SetPageUserUnit(
float
)
Parameters
- UserUnit
- The positive number defining the size of default user space units. The minimum allowed value is 1, the maximum allowed value is not restricted by the toolkit.
The GetStat method can be subsequently used to determine if this method has been successful.
Example
How to specify the user space unit value for the current page to define required page dimensions.
Dim caption As String = "Example: SetPageUserUnit"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.NewPDF() = GdPictureStatus.OK Then
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitPoint)
'The height and the width for the new page in PDF points.
Dim pageDim As Single = 14400
'Be sure you have selected the proper page.
If (gdpicturePDF.NewPage(pageDim, pageDim) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SelectPage(1) = GdPictureStatus.OK) Then
'To create a page of size 200 * 200 inches.
Dim userUnit As Single = 75000
gdpicturePDF.SetPageUserUnit(userUnit)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitInch)
pageDim = gdpicturePDF.GetPageHeight()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
MessageBox.Show("The current page height and width is " + pageDim + " inches.", caption)
Else
MessageBox.Show("The GetPageHeight() failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SetPageUserUnit() failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The new page can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The new file can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetPageUserUnit";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.NewPDF() == GdPictureStatus.OK)
{
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitPoint);
float pageDim = 14400; //The height and the width for the new page in PDF points.
//Be sure you have selected the proper page.
if ((gdpicturePDF.NewPage(pageDim, pageDim) == GdPictureStatus.OK) &&
(gdpicturePDF.SelectPage(1) == GdPictureStatus.OK))
{
float userUnit = 75000; //To create a page of size 200 * 200 inches.
gdpicturePDF.SetPageUserUnit(userUnit);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitInch);
pageDim = gdpicturePDF.GetPageHeight();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
MessageBox.Show("The current page height and width is " + pageDim + " inches.", caption);
else
MessageBox.Show("The GetPageHeight() failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SetPageUserUnit() failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The new page can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The new file can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption);
gdpicturePDF.Dispose();
Example
How to specify the user space unit value for the current page to define required page dimensions.
Dim caption As String = "Example: SetPageUserUnit"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.NewPDF() = GdPictureStatus.OK Then
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitPoint)
'The height and the width for the new page in PDF points.
Dim pageDim As Single = 14400
'Be sure you have selected the proper page.
If (gdpicturePDF.NewPage(pageDim, pageDim) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SelectPage(1) = GdPictureStatus.OK) Then
'To create a page of size 200 * 200 inches.
Dim userUnit As Single = 75000
gdpicturePDF.SetPageUserUnit(userUnit)
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitInch)
pageDim = gdpicturePDF.GetPageHeight()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
MessageBox.Show("The current page height and width is " + pageDim + " inches.", caption)
Else
MessageBox.Show("The GetPageHeight() failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The SetPageUserUnit() failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The new page can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The new file can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetPageUserUnit";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.NewPDF() == GdPictureStatus.OK)
{
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitPoint);
float pageDim = 14400; //The height and the width for the new page in PDF points.
//Be sure you have selected the proper page.
if ((gdpicturePDF.NewPage(pageDim, pageDim) == GdPictureStatus.OK) &&
(gdpicturePDF.SelectPage(1) == GdPictureStatus.OK))
{
float userUnit = 75000; //To create a page of size 200 * 200 inches.
gdpicturePDF.SetPageUserUnit(userUnit);
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitInch);
pageDim = gdpicturePDF.GetPageHeight();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
MessageBox.Show("The current page height and width is " + pageDim + " inches.", caption);
else
MessageBox.Show("The GetPageHeight() failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The SetPageUserUnit() failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The new page can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The new file can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption);
gdpicturePDF.Dispose();
See Also