GetPageContent Method (GdPicturePDF)
In This Topic
Returns the whole content (in the form of postscript data) of the current page in the loaded PDF document.
Syntax
'Declaration
Public Function GetPageContent() As String
public string GetPageContent()
public function GetPageContent(): String;
public function GetPageContent() : String;
public: string* GetPageContent();
public:
String^ GetPageContent();
Return Value
The postscript content of the currently selected page. The
GetStat method can be subsequently used to determine if this method has been successful.
Example
How to obtain the postscript content of all pages in the PDF document. The content of each page is subsequently saved into a 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
data = gdpicturePDF.GetPageContent()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
filename = "content_page" + i.ToString() + ".txt"
System.IO.File.WriteAllText(filename, data)
message = message + "Content of the page nr." + i.ToString() + " has been successfully saved." + vbCrLf
Else
message = message + "The GetPageContent() 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
MessageBox.Show(message, "Example: GetPageContent")
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), "Example: GetPageContent")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: GetPageContent")
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)
{
data = gdpicturePDF.GetPageContent();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
filename = "content_page" + i.ToString() + ".txt";
System.IO.File.WriteAllText(filename, data);
message = message + "Content of the page nr." + i.ToString() + " has been successfully saved.\n";
}
else
message = message + "The GetPageContent() 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";
}
MessageBox.Show(message, "Example: GetPageContent");
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), "Example: GetPageContent");
}
else
MessageBox.Show("The file can't be loaded.", "Example: GetPageContent");
gdpicturePDF.Dispose();
Example
How to obtain the postscript content of all pages in the PDF document. The content of each page is subsequently saved into a 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
data = gdpicturePDF.GetPageContent()
status = gdpicturePDF.GetStat()
If status = GdPictureStatus.OK Then
filename = "content_page" + i.ToString() + ".txt"
System.IO.File.WriteAllText(filename, data)
message = message + "Content of the page nr." + i.ToString() + " has been successfully saved." + vbCrLf
Else
message = message + "The GetPageContent() 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
MessageBox.Show(message, "Example: GetPageContent")
Else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), "Example: GetPageContent")
End If
Else
MessageBox.Show("The file can't be loaded.", "Example: GetPageContent")
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)
{
data = gdpicturePDF.GetPageContent();
status = gdpicturePDF.GetStat();
if (status == GdPictureStatus.OK)
{
filename = "content_page" + i.ToString() + ".txt";
System.IO.File.WriteAllText(filename, data);
message = message + "Content of the page nr." + i.ToString() + " has been successfully saved.\n";
}
else
message = message + "The GetPageContent() 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";
}
MessageBox.Show(message, "Example: GetPageContent");
}
else
MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), "Example: GetPageContent");
}
else
MessageBox.Show("The file can't be loaded.", "Example: GetPageContent");
gdpicturePDF.Dispose();
See Also