Q:
I want to convert an office document to a PDF. I understand that the source file needs to be on disk, but can the result file be a PDF in memory, such as a memory buffer or stream?
A:
Yes, you can output the PDF results as a memory buffer or stream instead of a file on disk. In C#, it would look like:
// Instantiate an in-memory PDFDoc object
pdftron.PDF.PDFDoc pdfdoc = new PDFDoc();
// Convert the on-disk docx file to an in-memory PDFDoc
pdftron.PDF.Convert.ToPdf(pdfdoc, "input.docx");
// Save the document to a memory buffer
byte[] mem_buf = pdfdoc.Save(SDFDoc.SaveOptions.e_linearized);
// Save the document to a stream
using (FileStream ostm = new FileStream("converted_doc_mem.txt", FileMode.Create, FileAccess.Write)) {
pdfdoc.Save(ostm, SDFDoc.SaveOptions.e_linearized);
}