We have this code where we convert html to pdf page . But this code fails on linux app service when we start adding logi image
private Document GetDetailsForPDFForm(BookingSheetDetailsDto surgeryBilling, Page pdfPage, Document pdfDocument)
{
var LogoImage = _hostingEnvironment.WebRootPath + “/FOI_Logo.png”;
StringBuilder htmlBuilder = new StringBuilder();
htmlBuilder.Append("<html><head>");
htmlBuilder.Append("<style>");
htmlBuilder.Append("head, html { margin: 0; padding: 0; }");
htmlBuilder.Append($"body {{ width: {pdfPage.PageInfo.Width}; height: {pdfPage.PageInfo.Height}; margin: 0; padding: 0;}}");
htmlBuilder.Append("table { width: 100%; border-collapse: collapse; }");
htmlBuilder.Append("th, td { padding: 0px; text-align: left;} ");
htmlBuilder.Append("th { color: black; font-weight: bold; }");
htmlBuilder.Append(".icdCode-column { width: 25%; } .icdCodeDescription-column { width: 75%; }");
htmlBuilder.Append(".cptCode-column { width: 15%; padding-top: 12px; padding-bottom: 12px; font-weight: bold; }");
htmlBuilder.Append(".side-column, .units-column { width: 10%; padding: 12px 4px 12px 4px; font-weight: bold; }");
htmlBuilder.Append(".levels-column { width: 15%; padding: 12px 4px 12px 4px; font-weight: bold; }");
htmlBuilder.Append(".modifier-column { width: 10%; padding: 12px 4px 12px 4px; font-weight: bold; }");
htmlBuilder.Append(".icdCodeLine-column {width:40%; padding: 12px 6px 12px 2px; font-weight: bold; word-wrap: break-word; overflow-wrap: break-word; word-break: break-word; white-space: normal;} ");
htmlBuilder.Append(".cptCodedescription-column { width: 100%; border: none; }"); // Apply border: none only to CPT description
htmlBuilder.Append("</style>");
htmlBuilder.Append("</head><body>");
if (!surgeryBilling.HospitalMRN.IsNullOrEmpty())
{
htmlBuilder.Append("<h3 style='display: inline; padding-right: 6px;'>Hospital MRN(Practice MRN) - </h3>");
htmlBuilder.Append("<span>").Append(surgeryBilling.HospitalMRN).Append(""</span>);
htmlBuilder.Append("<hr/>");
}
if (!surgeryBilling.AnesthesiaType.IsNullOrEmpty())
{
htmlBuilder.Append("<h3 style='display: inline; padding-right: 6px;'>Anesthesia Type - </h3>");
htmlBuilder.Append("<span>").Append(surgeryBilling.AnesthesiaType).Append(""</span>);
htmlBuilder.Append("<hr/>");
}
if (!surgeryBilling.SurgeryDescription.IsNullOrEmpty())
{
htmlBuilder.Append("<h3>Procedure/Surgery Description</h3>");
htmlBuilder.Append("<p>").Append(surgeryBilling.SurgeryDescription).Append("</p>");
htmlBuilder.Append("<hr/>");
}
if (!surgeryBilling.SpecialEquipmentOrSupplies.IsNullOrEmpty())
{
htmlBuilder.Append("<h3>Special Equipments Or Supplies</h3>");
htmlBuilder.Append("<p>").Append(surgeryBilling.SpecialEquipmentOrSupplies).Append("</p>");
htmlBuilder.Append("<hr/>");
}
htmlBuilder.Append("<h3>Diagnosis Information</h3>");
htmlBuilder.Append("<table><tr><th class='icdCode-column'>DX Code</th><th class='icdCodeDescription-column'>Description</th></tr>");
foreach (var icdDetails in surgeryBilling.ICDCodeDetails)
{
htmlBuilder.Append("<tr><td class='icdCode-column'>").Append(icdDetails.ICDCode).Append("</td>");
htmlBuilder.Append("<td class='icdCodeDescription-column'>").Append(icdDetails.ICDCodeShortDescription).Append("</td></tr>");
}
htmlBuilder.Append("</table>");
htmlBuilder.Append("<h3>Procedure Information</h3>");
htmlBuilder.Append("<table><tr><th class='cptCode-column'>CPT Code</th><th class='icdCode-column'>DX Code</th>");
htmlBuilder.Append("<th class='side-column'>Side</th><th class='levels-column'>Levels</th><th class='units-column'>Unit</th><th class='modifier-column'>Modifier</th></tr>");
foreach (var cptDetails in surgeryBilling.CPTCodeDetails)
{
htmlBuilder.Append("<tr><td class='cptCode-column'>").Append(cptDetails.CPTCode).Append("</td>");
htmlBuilder.Append("<td class='icdCodeLine-column'>").Append(cptDetails.ICDCodesForLineItem).Append(" </td>");
htmlBuilder.Append("<td class='side-column'>").Append(cptDetails.Side).Append("</td>");
htmlBuilder.Append("<td class='levels-column'>").Append(cptDetails.Levels).Append("</td>");
htmlBuilder.Append("<td class='units-column'>").Append(cptDetails.Units).Append("</td>");
htmlBuilder.Append("<td class='modifier-column'>").Append(cptDetails.ModifiersForLineItem).Append("</td></tr>");
htmlBuilder.Append("<tr><td colspan='5' class='cptCodedescription-column'>").Append(cptDetails.CPTCodeLongDescription).Append("</td></tr>");
}
htmlBuilder.Append("</table>");
htmlBuilder.Append("</body></html>");
string htmlString = htmlBuilder.ToString();
HtmlLoadOptions htmlLoadOptions = new HtmlLoadOptions
{
PageInfo = new PageInfo
{
Width = PageSize.PageLetter.Width,
Height = PageSize.PageLetter.Height,
},
InputEncoding = “UTF-8”
};
Document document = new Document(new MemoryStream(Encoding.UTF8.GetBytes(htmlString)), htmlLoadOptions);
return document;
}