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

Free Support Forum - aspose.com

Adding a PDF file

I am creating a new PDF file by adding several different file types. One of the files I have to add is another pdf. I am unable to figure this out.

Can you help?





My code goes like this…


Aspose.Pdf.Generator.Pdf pdfx = new Pdf();


Aspose.Pdf.Generator.Section sec = pdfx.Sections.Add();


Aspose.Pdf.Generator.Text txtx = new Text(“Hello World”);


sec.Paragraphs.Add(txtx);




// I now need to add a PDF file and then save pdfx





// add HelloPDF.pdf to pdfx





// save pdfx


pdfx.Save(“HelloWorld2.pdf”);

Hi Prakash,


Thanks for using our API’s.

Aspose.Pdf.Generator only offers the feature to create PDF documents from scratch and it does not offer the feature to concatenate/manipulate existing PDF files. As per your requirement, please save the output from Aspose.Pdf.Generator.Pdf object to file system or Stream instance and use Aspose.Pdf.Document object to concatenate PDF files. For further details, please visit Concatenate PDF Files.

Thanks for the tip about concatenating. I had considered it, but relegated it as a last resort.

The requirement I have is to put together various files into a single pdf - mostly the files are of type TIF, TEXT and PDF. It would be nice to be able to write to a single output pdf file without switching over to a different process for one of the file types.

Is there a way to do this with just the Document object and not using Generator?

Thanks

Hi Prakash,


Thanks for sharing the details.

Aspose.Pdf for .NET offers the feature to convert Convert an Image to PDF, as well as Convert Text File to PDF Format and once the output is saved in PDF format, you can use same Aspose.Pdf.Document object to Concatenate PDF Files.

Thanks for sample on using the Document object.
I was able to use this for my purposes.

When I was using Generator for Text files I was able to use the Section object for setting PageHeight and PageWidth

Example

Aspose.Pdf.Generator.Section sec1 = _pdf1.Sections.Add();

sec1.PageInfo.PageHeight = Aspose.Pdf.Generator.PageSize.A3Height;
sec1.PageInfo.PageWidth = Aspose.Pdf.Generator.PageSize.A3Width;



Is there something similar I can use with the Page object within the Document object?

Thanks

Hi Prakash,


Please visit the following link for required information on Update Page Dimensions.