Akbar Badhusha
Akbar Badhusha

Reputation: 2627

How to convert DOC or DOCX bytes to PDF without using storage [C#]

I have requirement where I have to convert a doc or docx file into PDF. I have the doc file in byte array format. Need to convert that byte array into PDF without using storage. Is there anyway to do that using only memory. Code I use for conversion using storage is as below.

string outputFileName = destinationFile;
Interopwrd.Application wordApp = new Interopwrd.Application();
Interopwrd.Document wordDoc = null;
wordDoc = wordApp.Documents.Open(sourceFile);
wordDoc.ExportAsFixedFormat(outputFileName, Interopwrd.WdExportFormat.wdExportFormatPDF);

I need to do this without saving in in storage. Is it possible to do that?

Upvotes: 0

Views: 1404

Answers (1)

Brian Berns
Brian Berns

Reputation: 17038

Personally, I would just use a RAM drive, which is block of memory that the OS treats as if it were a disk drive. You can then have Word save to a file on that drive, but it will only exist in memory. That gives you all the performance benefits (and impermanence) of RAM, and the benefits of a file system at the same time. Win-win.

Upvotes: 2

Related Questions