Dim caption As String = "Example: AutoDeskew"
Using pdf As GdPicturePDF = New GdPicturePDF()
Dim message As String = ""
Dim status As GdPictureStatus = pdf.LoadFromFile("source.pdf", False)
If status = GdPictureStatus.OK Then
Dim pageCount As Integer = pdf.GetPageCount()
status = pdf.GetStat()
Dim pageNo As Integer = 1
While (pageNo <= pageCount) AndAlso (status = GdPictureStatus.OK)
status = pdf.SelectPage(pageNo)
If status = GdPictureStatus.OK Then
Dim angle As Single = pdf.AutoDeskew(15, False)
status = pdf.GetStat()
If status = GdPictureStatus.OK Then
message += "PageNo " + pageNo.ToString() + ". - skew angle = " + angle.ToString() + vbCrLf
Else
message += "PageNo " + pageNo.ToString() + ". - status: " + status.ToString() + vbCrLf
End If
End If
pageNo += 1
End While
If status = GdPictureStatus.OK Then
status = pdf.SaveToFile("dest.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show(message + vbCrLf + "The file has been saved.", caption)
Else
MessageBox.Show(message + vbCrLf + "The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The example has NOT been followed successfully. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption)
End If
End Using
string caption = "Example: AutoDeskew";
using (GdPicturePDF pdf = new GdPicturePDF())
{
string message = "";
GdPictureStatus status = pdf.LoadFromFile("source.pdf", false);
if (status == GdPictureStatus.OK)
{
int pageCount = pdf.GetPageCount();
status = pdf.GetStat();
for (int pageNo = 1; (pageNo <= pageCount) && (status == GdPictureStatus.OK); pageNo++)
{
status = pdf.SelectPage(pageNo);
if (status == GdPictureStatus.OK)
{
float angle = pdf.AutoDeskew(15, false);
status = pdf.GetStat();
if (status == GdPictureStatus.OK)
message += "PageNo " + pageNo.ToString() + ". - skew angle = " + angle.ToString() + "\n";
else
message += "PageNo " + pageNo.ToString() + ". - status: " + status.ToString() + "\n";
}
}
if (status == GdPictureStatus.OK)
{
status = pdf.SaveToFile("dest.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show(message + "\nThe file has been saved.", caption);
else
MessageBox.Show(message + "\nThe example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The example has NOT been followed successfully. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption);
}