We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Compose large pdf file from other small pdf files

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.

Hi Beatriz,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for considering Aspose.Pdf for .NET.

If your requirement is to merge different small PDF files together into a large PDF file, you may check the following documentation links with details on how to merge the PDF files.

Concatenate PDF Files

In case your requirement is to add the text to an existing PDF file, the process you are using is fine.To check the issue you are facing, we would request you to please share your template PDF files with us. We will look into it and get back to you soon.

Sorry for the inconvenience,