SetPageContent Method (GdPicturePDF)
In This Topic
Sets the content in the form of postscript data of the current page in the loaded PDF document.
Syntax
Parameters
- Content
- The postscript content to reset the actual content of the currently selected page.
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 reset the postscript content of all pages in the PDF document. The content of each page is read from the separate file.
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
Dim data As String = "", filename As String = "", message As String = ""
For i As Integer = 1 To count
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
filename = "content_page" + i.ToString() + ".txt"
data = System.IO.File.ReadAllText(filename)
status = gdpicturePDF.SetPageContent(data)
If status = GdPictureStatus.OK Then
message = message + "The page content for the page nr." + i.ToString() + " has been set successfully." + vbCrLf
Else
message = message + "The SetPageContent() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Else
message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Next
If gdpicturePDF.SaveToFile("test_SetPageContent.pdf") = GdPictureStatus.OK Then
message = message + "The file has been saved."
Else
message = message + "The file can't be saved."
End If
MessageBox.Show(message, "Example: SetPageContent")
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), "Example: SetPageContent")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: SetPageContent")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetPageCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string data = "", filename = "", message = "";
for (int i = 1; i <= count; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
filename = "content_page" + i.ToString() + ".txt";
data = System.IO.File.ReadAllText(filename);
status = gdpicturePDF.SetPageContent(data);
if (status == GdPictureStatus.OK)
message = message + "The page content for the page nr." + i.ToString() + " has been set successfully.\n";
else
message = message + "The SetPageContent() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
}
else
message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
}
if (gdpicturePDF.SaveToFile("test_SetPageContent.pdf") == GdPictureStatus.OK)
message = message + "The file has been saved.";
else
message = message + "The file can't be saved.";
MessageBox.Show(message, "Example: SetPageContent");
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), "Example: SetPageContent");
}
else
MessageBox.Show("The file can't be loaded.", "Example: SetPageContent");
gdpicturePDF.Dispose();
Example
How to reset the postscript content of all pages in the PDF document. The content of each page is read from the separate file.
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
Dim data As String = "", filename As String = "", message As String = ""
For i As Integer = 1 To count
status = gdpicturePDF.SelectPage(i)
If status = GdPictureStatus.OK Then
filename = "content_page" + i.ToString() + ".txt"
data = System.IO.File.ReadAllText(filename)
status = gdpicturePDF.SetPageContent(data)
If status = GdPictureStatus.OK Then
message = message + "The page content for the page nr." + i.ToString() + " has been set successfully." + vbCrLf
Else
message = message + "The SetPageContent() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Else
message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
End If
Next
If gdpicturePDF.SaveToFile("test_SetPageContent.pdf") = GdPictureStatus.OK Then
message = message + "The file has been saved."
Else
message = message + "The file can't be saved."
End If
MessageBox.Show(message, "Example: SetPageContent")
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), "Example: SetPageContent")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: SetPageContent")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
int count = gdpicturePDF.GetPageCount();
GdPictureStatus status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
string data = "", filename = "", message = "";
for (int i = 1; i <= count; i++)
{
status = gdpicturePDF.SelectPage(i);
if (status == GdPictureStatus.OK)
{
filename = "content_page" + i.ToString() + ".txt";
data = System.IO.File.ReadAllText(filename);
status = gdpicturePDF.SetPageContent(data);
if (status == GdPictureStatus.OK)
message = message + "The page content for the page nr." + i.ToString() + " has been set successfully.\n";
else
message = message + "The SetPageContent() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
}
else
message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
}
if (gdpicturePDF.SaveToFile("test_SetPageContent.pdf") == GdPictureStatus.OK)
message = message + "The file has been saved.";
else
message = message + "The file can't be saved.";
MessageBox.Show(message, "Example: SetPageContent");
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), "Example: SetPageContent");
}
else
MessageBox.Show("The file can't be loaded.", "Example: SetPageContent");
gdpicturePDF.Dispose();
See Also