I want to read the contents of my pdf file into another pdf file using pdfsharp, here is my code below, i just wanted to read the contents either in the form of bytes or in string format, but by using pdfsharp.
public static void Main()
{
PdfDocument pdf = PdfReader.Open(@"C:\backup_temp\Template.pdf");
string outputText= "";
foreach (PdfPage page in pdf.Pages)
{
for (int index = 0; index < page.Contents.Elements.Count; index++)
{
PdfDictionary.PdfStream stream = Page.Contents.Elements.GetDictionary(index).Stream;
outputText += new PDFParser().ExtractTextFromPDFBytes(stream.Value);
}
}
string pdfFilename = @"C:\backup_temp\source.pdf";
pdf.Save(pdfFilename);
}