GdPicture.NET.14
GdPicture14 Namespace / GdPicturePDF Class / SetOrigin Method
A member of the PdfOrigin enumeration. You can select one of these: bottom left, top left, bottom right and top right.
Example





In This Topic
SetOrigin Method (GdPicturePDF)
In This Topic
Sets the new origin's location of the currently used coordinate system defined in the loaded PDF document. Please note that you need to create or load the PDF document properly to set the valid value, otherwise the value will remain undefined.
Syntax
'Declaration
 
Public Sub SetOrigin( _
   ByVal Origin As PdfOrigin _
) 
public void SetOrigin( 
   PdfOrigin Origin
)
public procedure SetOrigin( 
    Origin: PdfOrigin
); 
public function SetOrigin( 
   Origin : PdfOrigin
);
public: void SetOrigin( 
   PdfOrigin Origin
) 
public:
void SetOrigin( 
   PdfOrigin Origin
) 

Parameters

Origin
A member of the PdfOrigin enumeration. You can select one of these: bottom left, top left, bottom right and top right.
Remarks
It is recommend to use the GetStat method to identify the specific reason for the method's failure, if any. Please ensure that you have successfully created or loaded a PDF document, otherwise the method does nothing.

The location of the origin of a PDF document is defined by default to be at the lower left corner.

Example
How to find out the position of the first page's media box in millimetres of the currently loaded PDF document.
Dim gdpicturePDF As New GdPicturePDF()
Dim message As String = "NO document IS loaded." + vbCrLf + vbCrLf
            
'This is the incorrect usage - the values will remain undefined.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
Dim status As GdPictureStatus = gdpicturePDF.GetStat()
message = message + "Status for SetOrigin(PdfOrigin.PdfOriginTopLeft): " + status.ToString()
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
status = gdpicturePDF.GetStat()
message = message + vbCrLf + "Status for SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter): " + status.ToString()
MessageBox.Show(message, "Example: SetOrigin")
            
'You need to load the file here.
status = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
    message = "Your pdf document IS loaded." + vbCrLf + vbCrLf
            
    status = gdpicturePDF.SelectPage(1)
    If status = GdPictureStatus.OK Then
        'This is the correct usage.
        gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
        If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
            gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
            If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
                Dim pLeft As Single = 0
                Dim pTop As Single = 0
                Dim pRight As Single = 0
                Dim pBottom As Single = 0
                gdpicturePDF.GetPageBox(PdfPageBox.PdfPageBoxMediaBox, pLeft, pTop, pRight, pBottom)
                message = message + "First page mediabox : (" + pLeft.ToString() + " * " + pTop.ToString() + ")-(" + pRight.ToString() + "*" + pBottom.ToString() + ") millimetres."
                MessageBox.Show(message, "Example: SetOrigin")
            End If
        End If
    Else
        MessageBox.Show("This PDF has no pages.", "Example: SetOrigin")
    End If
Else
    MessageBox.Show("The file can't be loaded.", "Example: SetOrigin")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
string message = "NO document IS loaded.\n\n";
            
//This is the incorrect usage - the values will remain undefined.
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
GdPictureStatus status = gdpicturePDF.GetStat();
message = message + "Status for SetOrigin(PdfOrigin.PdfOriginTopLeft): " + status.ToString();
gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
status = gdpicturePDF.GetStat();
message = message + "\nStatus for SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter): " + status.ToString();
MessageBox.Show(message, "Example: SetOrigin");
            
 //You need to load the file here.
status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
    message = "Your pdf document IS loaded.\n\n";
            
    status = gdpicturePDF.SelectPage(1);
    if (status == GdPictureStatus.OK)
    {
        //This is the correct usage.
        gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
        if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
        {
            gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
            if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
            {
                float pLeft = 0;
                float pTop = 0;
                float pRight = 0;
                float pBottom = 0;
                gdpicturePDF.GetPageBox(PdfPageBox.PdfPageBoxMediaBox, ref pLeft, ref pTop, ref pRight, ref pBottom);
                message = message + "First page mediabox : (" + pLeft.ToString() + " * " + pTop.ToString() + ")-(" + pRight.ToString() + "*" + pBottom.ToString() + ") millimetres.";
                MessageBox.Show(message, "Example: SetOrigin");
            }
        }
    }
    else
    {
        MessageBox.Show("This PDF has no pages.", "Example: SetOrigin");
    }
}
else
{
    MessageBox.Show("The file can't be loaded.", "Example: SetOrigin");
}
gdpicturePDF.Dispose();
See Also