public string modify([FromBody] DocumentHeader documentHeader) { IBlobService blobService = new AzureBlobService(); var blobContents = blobService.getBlobContents(blobContainerConnString, blobContainerName, documentHeader.BlobItemName); var tempGUID = Guid.NewGuid().ToString(); var tempDocPath = $"./local/{tempGUID}"; System.IO.Directory.CreateDirectory(tempDocPath); System.IO.File.WriteAllBytes($"{tempDocPath}.docx", blobContents); var bookmarkReplacements = new Dictionary <string, string>(); bookmarkReplacements.Add("Commentor_adresse", "Andevej 14"); bookmarkReplacements.Add("Commentor_navn_header", "Anders And"); bookmarkReplacements.Add("Commentor_navn_body", "Anders And"); bookmarkReplacements.Add("Commentor_registreringsnummer", "1234 1234512345"); bookmarkReplacements.Add("Commentor_dato", DateTime.Now.ToString("dd.MM.yyyy")); bookmarkReplacements.Add("Commentor_bodytext", documentHeader.BodyText); openDocument.ReplaceBookmarks($"{tempDocPath}.docx", $"{tempDocPath} - REPLACED.docx", bookmarkReplacements); var htmlSimpleInputBytes = System.IO.File.ReadAllBytes($"{tempDocPath} - REPLACED.docx"); var serviceUser = docProvider.GetUser("*****@*****.**"); byte[] pdfHTMLSimpleDocBytes = docProvider.ConvertDocumentToPDF(htmlSimpleInputBytes, $"Temp/{Guid.NewGuid()}.docx", serviceUser.Id); System.IO.File.WriteAllBytes($"{tempDocPath} - REPLACED.pdf", pdfHTMLSimpleDocBytes); return(tempGUID); }