Dim caption As String = "Example: LoadFromFileEx"
Dim oSrcPDF As New GdPicturePDF()
Dim oDstPDF As New GdPicturePDF()
'File access mode will be read/write.
Dim status As GdPictureStatus = oDstPDF.LoadFromFileEx("doc1.pdf", True)
If status = GdPictureStatus.OK Then
'The file will not load into memory.
status = oSrcPDF.LoadFromFile("doc2.pdf", False)
If status = GdPictureStatus.OK Then
Dim srcPageCount As Integer = oSrcPDF.GetPageCount()
status = oSrcPDF.GetStat()
If status = GdPictureStatus.OK Then
For i As Integer = 1 To srcPageCount
status = oDstPDF.ClonePage(oSrcPDF, i)
If status <> GdPictureStatus.OK Then
MessageBox.Show("The ClonePage() method has failed on the page " + i.ToString() + " with the status:" + status.ToString(), caption)
Exit For
End If
Next
If status = GdPictureStatus.OK Then
If oDstPDF.SaveToFileInc("doc1.pdf") = GdPictureStatus.OK Then
MessageBox.Show("The PDF file has been overwritten and saved successfully.", caption)
End If
End If
End If
Else
MessageBox.Show("The source file can't be loaded.", caption)
End If
Else
MessageBox.Show("The destination file can't be loaded.", caption)
End If
oDstPDF.Dispose()
oSrcPDF.Dispose()
string caption = "Example: LoadFromFileEx";
GdPicturePDF oSrcPDF = new GdPicturePDF();
GdPicturePDF oDstPDF = new GdPicturePDF();
//File access mode will be read/write.
GdPictureStatus status = oDstPDF.LoadFromFileEx("doc1.pdf", true);
if (status == GdPictureStatus.OK)
{
//The file will not load into memory.
status = oSrcPDF.LoadFromFile("doc2.pdf", false);
if (status == GdPictureStatus.OK)
{
int srcPageCount = oSrcPDF.GetPageCount();
status = oSrcPDF.GetStat();
if (status == GdPictureStatus.OK)
{
for (int i = 1; i <= srcPageCount; i++)
{
status = oDstPDF.ClonePage(oSrcPDF, i);
if (status != GdPictureStatus.OK)
{
MessageBox.Show("The ClonePage() method has failed on the page " + i.ToString() + " with the status:" + status.ToString(), caption);
break;
}
}
if (status == GdPictureStatus.OK)
{
if (oDstPDF.SaveToFileInc("doc1.pdf") == GdPictureStatus.OK)
MessageBox.Show("The PDF file has been overwritten and saved successfully.", caption);
}
}
}
else
MessageBox.Show("The source file can't be loaded.", caption);
}
else
MessageBox.Show("The destination file can't be loaded.", caption);
oDstPDF.Dispose();
oSrcPDF.Dispose();