Код: Выделить всё
var uploadPath = _webHostEnvironment.WebRootPath + atta.AttachmentPath;
using var doc = new TemplateDocument(uploadPath);
var data = await CreateDictionary(reservation);
var src = new VariableSource(data);
var engine = new DefaultOpenXmlTemplateEngine();
engine.ReplaceAll(doc, src);
var path = await SaveFile(doc, reservation, 4,attachmentName);
doc.SaveAs(path);
doc.Dispose();
//GeneratePDF
await CreatePDF(path);
Код: Выделить всё
private async Task CreatePDF(string path)
{
Document docs = new Document();
// Load a Word document
docs.LoadFromFile(path);
// Save the document to PDF
docs.SaveToFile("reservation.pdf", FileFormat.PDF);
// Dispose resources
docs.Dispose();
}
Я также пробовал использовать .Close() в конце, но это тоже не сработало.
Подробнее здесь: https://stackoverflow.com/questions/787 ... er-process