Hello,
I need a method that composes a large pdf file from other small pdf files. These files are paragraphs with formatted text and they are stored as local resources. How can I read every whole file with format and compose the final pdf file? I am trying something like this:
//Output file is a white page
Document outputFile = new Document(“output.pdf”);
TextBuilder textBuilder = new TextBuilder(outputFile.Pages[1]);
//File1
MemoryStream str = new MemoryStream(Resource.File1);
Document pdfDocument = new Document(str);
Page pdfPage = (Page)pdfDocument.Pages[1];
TextFragmentAbsorber absorber = new TextFragmentAbsorber();
pdfPage.Accept(absorber);
foreach (TextFragment textFragment in absorber.TextFragments)
{
textBuilder.AppendText(textFragment);
}
//Repeat for every file the same code
…
//Save output file
outputFile .Save(“output.pdf”);
str.Dispose();
I have an exception “Object reference not set to an instance of an object.” when AppendText is called.
What other options do I have to storage the files apart from storage them on local resources?
Thank you.