NormalizePage Method (GdPicturePDF)
In This Topic
Normalizes the currently selected page in the loaded PDF document, in other words all the page boundary boxes are adjusted to the physical size of the page
(means the CropBox property is equal to the MediaBox property) and the page's rotation is reset to 0. The actual page rendering is not changed.
Syntax
Return Value
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Example
How to normalize all pages in the PDF document.
Dim caption As String = "Example: NormalizePage"
Dim gdpicturePDF As New GdPicturePDF()
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
For i As Integer = 1 To count
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
status = gdpicturePDF.NormalizePage()
If status <> GdPictureStatus.OK Then
MessageBox.Show("The NormalizePage() method has failed for the page number " + i.ToString() + " with the status: " + status.ToString(), caption)
Exit For
End If
Else
Exit For
End If
Next
If status = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("test_NormalizePage.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The pages have been normalized successfully and the file has been saved.", caption)
Else
MessageBox.Show("The pages have been normalized successfully but the file can't be saved.", caption)
End If
End If
End If
If status <> GdPictureStatus.OK Then
MessageBox.Show("The example HAS NOT been followed successfully. The last error status is: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: NormalizePage";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetPageCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
for (int i = 1; i <= count; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.NormalizePage();
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The NormalizePage() method has failed for the page number " + i.ToString() + " with the status: " + status.ToString(), caption);
break;
}
}
else break;
}
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("test_NormalizePage.pdf") == GdPictureStatus.OK)
MessageBox.Show("The pages have been normalized successfully and the file has been saved.", caption);
else
MessageBox.Show("The pages have been normalized successfully but the file can't be saved.", caption);
}
}
if (status != GdPictureStatus.OK)
MessageBox.Show("The example HAS NOT been followed successfully. The last error status is: " + status.ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
Example
How to normalize all pages in the PDF document.
Dim caption As String = "Example: NormalizePage"
Dim gdpicturePDF As New GdPicturePDF()
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
For i As Integer = 1 To count
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
status = gdpicturePDF.NormalizePage()
If status <> GdPictureStatus.OK Then
MessageBox.Show("The NormalizePage() method has failed for the page number " + i.ToString() + " with the status: " + status.ToString(), caption)
Exit For
End If
Else
Exit For
End If
Next
If status = GdPictureStatus.OK Then
If gdpicturePDF.SaveToFile("test_NormalizePage.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The pages have been normalized successfully and the file has been saved.", caption)
Else
MessageBox.Show("The pages have been normalized successfully but the file can't be saved.", caption)
End If
End If
End If
If status <> GdPictureStatus.OK Then
MessageBox.Show("The example HAS NOT been followed successfully. The last error status is: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: NormalizePage";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetPageCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
for (int i = 1; i <= count; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
status = gdpicturePDF.NormalizePage();
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The NormalizePage() method has failed for the page number " + i.ToString() + " with the status: " + status.ToString(), caption);
break;
}
}
else break;
}
if (status == GdPictureStatus.OK)
{
if (gdpicturePDF.SaveToFile("test_NormalizePage.pdf") == GdPictureStatus.OK)
MessageBox.Show("The pages have been normalized successfully and the file has been saved.", caption);
else
MessageBox.Show("The pages have been normalized successfully but the file can't be saved.", caption);
}
}
if (status != GdPictureStatus.OK)
MessageBox.Show("The example HAS NOT been followed successfully. The last error status is: " + status.ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
See Also