Hi All,
It seems that the PdfDocumentRenderer.Save() does not stop others processes reading the file while it writes the file to disk, thus if you have another process which is simply moving files (File.Copy()) the PDF file can be copied regardless it is stated and it could be corrupted.
I would just like to ask for confirmation (I tend to put an exclusive lock when writing a file) and how I could work around this.
Code:
Document doc = Documents.CreateResultDocument(data);
//Create a renderer for PDF that uses Unicode font encoding
PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(true);
//Set the MigraDoc document
pdfRenderer.Document = doc;
//Create and save the PDF document
pdfRenderer.RenderDocument();
log.Info("Saving PDF for file: " + originalFilename + " ...");
pdfRenderer.Save(outputFilename);
log.Info("PDF for file: " + originalFilename + " has been created => " + outputFilename);
Many thanks