I have an existing process that builds various PDF documents in memory using aspose.pdf.generator. The process then concatenates the PDF files and returns one PDF to the user at the end.
I now have a requirement to insert existing Word documents into the concatenation process. I can import the Word docs into memory as Aspose.Words documents. How can I insert the Aspose.Words document into my Aspose.PDF.Generator documents at various locations? If I could convert each Aspose.Words document to a Aspose.PDF.Generator document I could insert the method cleanly into my process.
This object var msDoc = new Aspose.Words.Document(ms);
needs inserted into the tdocs.pdf property which is of type Aspose.PDF.Generatorr.Pdf.
PdfFileEditor pdfEditor = new PdfFileEditor();
MemoryStream outStream = new MemoryStream();
MemoryStream[] streamArray = new MemoryStream[tdocs.Count];
int i = 0;
foreach (var tdoc in tdocs)
{
MemoryStream inputStream1 = new MemoryStream();
tdoc.Pdf.Save(inputStream1);
streamArray[i] = inputStream1;
i++;
}
pdfEditor.Concatenate(streamArray, outStream);
using (FileStream file = new FileStream(filePath, FileMode.Create, System.IO.FileAccess.Write))
{
byte[] bytes = new byte[outStream.Length];
outStream.Read(bytes, 0, (int)outStream.Length);
file.Write(bytes, 0, bytes.Length);
outStream.Close();
}
return fileName;