Free Support Forum -

Using asposepdf.kit with aspose.pdf

I have a page that creates a pdf using aspose.pdf. We now have aspose.pdf.kit as that as the page is being created, we can insert pdf documents. I have looked through but I am not sure how this would be applied to a PDF that is still being created (as compared to a pdf that is already created as found in the linked article above). Is there anyone that can give some insight on this topic? Below I have included a stripped down example. Thanks.

 Dim pdf1 As Aspose.Pdf.Pdf = New Aspose.Pdf.Pdf
 Dim sec1 As Aspose.Pdf.Section = pdf1.Sections.Add()
 sec1.Paragraphs.Add(New Aspose.Pdf.Text(“Some cool stuff…”))
  //CODE TO INSERT PDF DOCUMENT example.pdf TO pdf1
 sec1.Paragraphs.Add(New Aspose.Pdf.Text("…Other Stuff"))


Thanks for using our products.

Aspose.Pdf is a component which is used to generate PDF documents from scratch. Once the PDF document is generated, save the resultant PDF in MemoryStream object i.e. pdf.Save("myStream"); and use Aspose.Pdf.Kit to insert the pages of newly generated PDF document into existing PDF document i.e. PdfFileEditor.Insert(mystream,location ....). In case your problem is still not resolved, please feel free to contact. We apologize for your inconvenience.

I understand that Aspose.PDF is creating a document on the fly, I am wanting to add a PDF to the document that is being created on the fly, as it is being created. Is that possible?


Thanks for sharing your feedback.

Please take a look over the following code snippet in which I have created a simple PDF document containing a simple text paragraph. Later on, the pages from this newly generated PDF document are inserted into already existing PDF file. I have also attached the already existent PDF document and the resultant PDF that I have generated after Insert(...) method.

In case still it does not resolve your problem or you have any further query, please feel free to contact. We apologize for your inconvenience.


// create MemoryStream object
MemoryStream memorystream = new MemoryStream();
// Instantiate an object PDF class
Pdf pdf = new Pdf();
// add the section to PDF document sections collection
Aspose.Pdf.Section section = pdf.Sections.Add();

// create a simple text paragraph
Text text1 = new Text("Hello world in document generated with Aspose.Pdf");
// add text paragraph to the paragraphs collection of section object
//Save the pdf document

//Initialize the string variables storing paths of PDF files
string inFile1 = @"D:/pdftest/TIFFtoPDFConversion_test.pdf";
//Creating stream objects holding the PDF files in Open Mode
FileStream inStream1 = new FileStream(inFile1, FileMode.Open);
//Creating output stream object that will store the extracted pages as a PDF file
FileStream outputStream = new FileStream(@"D:/pdftest/ResultantPDF_Document.pdf", FileMode.Create);

//Instantiating PdfFileEditor object
PdfFileEditor editor = new PdfFileEditor();
//Setting the page number of the inStream1 as location where pages will be inserted
int location = 1;
//Creating an array of Page Numbers to be inserted
int[] pages = new int[] { 1};
//Calling Insert method
editor.Insert(memorystream, location, inStream1, pages, outputStream);
//Closing output stream