Dim caption As String = "Example: ClonePage"
Dim gdpicturePDF1 As New GdPicturePDF()
Dim gdpicturePDF2 As New GdPicturePDF()
If gdpicturePDF1.LoadFromFile("test1.pdf", False) = GdPictureStatus.OK Then
If gdpicturePDF2.LoadFromFile("test2.pdf", False) = GdPictureStatus.OK Then
Dim oGdPictureNewPDF As New GdPicturePDF()
If oGdPictureNewPDF.NewPDF() = GdPictureStatus.OK Then
Dim pageCount As Integer = gdpicturePDF1.GetPageCount()
Dim status As GdPictureStatus = gdpicturePDF1.GetStat()
If status = GdPictureStatus.OK Then
For page As Integer = 1 To pageCount
status = oGdPictureNewPDF.ClonePage(gdpicturePDF1, page)
If status <> GdPictureStatus.OK Then
MessageBox.Show("The ClonePage() method has failed with the status: " + status.ToString() + vbCrLf + "Document: first Page nr. " + page.ToString(), caption)
Exit For
End If
Next
Else
MessageBox.Show("The GetPageCount() method for the first document has failed with the status: " + status.ToString(), caption)
End If
If status = GdPictureStatus.OK Then
pageCount = gdpicturePDF2.GetPageCount()
status = gdpicturePDF2.GetStat()
If status = GdPictureStatus.OK Then
For page As Integer = 1 To pageCount
status = oGdPictureNewPDF.ClonePage(gdpicturePDF2, page)
If status <> GdPictureStatus.OK Then
MessageBox.Show("The ClonePage() method has failed with the status: " + status.ToString() + vbCrLf + "Document: second Page nr. " + page.ToString(), caption)
Exit For
End If
Next
Else
MessageBox.Show("The GetPageCount() method for the second document has failed with the status: " + status.ToString(), caption)
End If
End If
If status = GdPictureStatus.OK Then
Dim message As String = "The pages have been cloned successfully"
If oGdPictureNewPDF.SaveToFile("test_ClonePage.pdf") = GdPictureStatus.OK Then
message = message + " and the file has been saved."
Else
message = message + ", but the file can't be saved."
End If
MessageBox.Show(message, caption)
End If
Else
MessageBox.Show("The destination file can't be created.", caption)
End If
oGdPictureNewPDF.Dispose()
Else
MessageBox.Show("The second file can't be loaded.", caption)
End If
Else
MessageBox.Show("The first file can't be loaded.", caption)
End If
gdpicturePDF1.Dispose()
gdpicturePDF2.Dispose()
string caption = "Example: ClonePage";
GdPicturePDF gdpicturePDF1 = new GdPicturePDF();
GdPicturePDF gdpicturePDF2 = new GdPicturePDF();
if (gdpicturePDF1.LoadFromFile("test1.pdf", false) == GdPictureStatus.OK)
{
if (gdpicturePDF2.LoadFromFile("test2.pdf", false) == GdPictureStatus.OK)
{
GdPicturePDF oGdPictureNewPDF = new GdPicturePDF();
if (oGdPictureNewPDF.NewPDF() == GdPictureStatus.OK)
{
int pageCount = gdpicturePDF1.GetPageCount();
GdPictureStatus status = gdpicturePDF1.GetStat();
if (status == GdPictureStatus.OK)
{
for (int page = 1; page <= pageCount; page++)
{
status = oGdPictureNewPDF.ClonePage(gdpicturePDF1, page);
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The ClonePage() method has failed with the status: " + status.ToString() + "\nDocument: first Page nr. " + page.ToString(), caption);
break;
}
}
}
else
MessageBox.Show("The GetPageCount() method for the first document has failed with the status: " + status.ToString(), caption);
if (status == GdPictureStatus.OK)
{
pageCount = gdpicturePDF2.GetPageCount();
status = gdpicturePDF2.GetStat();
if (status == GdPictureStatus.OK)
{
for (int page = 1; page <= pageCount; page++)
{
status = oGdPictureNewPDF.ClonePage(gdpicturePDF2, page);
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The ClonePage() method has failed with the status: " + status.ToString() + "\nDocument: second Page nr. " + page.ToString(), caption);
break;
}
}
}
else
MessageBox.Show("The GetPageCount() method for the second document has failed with the status: " + status.ToString(), caption);
}
if (status == GdPictureStatus.OK)
{
string message = "The pages have been cloned successfully";
if (oGdPictureNewPDF.SaveToFile("test_ClonePage.pdf") == GdPictureStatus.OK)
message = message + " and the file has been saved.";
else
message = message + ", but the file can't be saved.";
MessageBox.Show(message, caption);
}
}
else
MessageBox.Show("The destination file can't be created.", caption);
oGdPictureNewPDF.Dispose();
}
else
MessageBox.Show("The second file can't be loaded.", caption);
}
else
MessageBox.Show("The first file can't be loaded.", caption);
gdpicturePDF1.Dispose();
gdpicturePDF2.Dispose();