I have a Blazor page that has output from a form submission rendered from it's related model (plansold) such as:
<div class="container" id="PdfContent">
<p style="text-align: center;"><img src="/images/Branding.jpg" alt="" /></p>
<h5 style="text-align: center;"><strong>Title Text</strong></h5>
<p> </p>
<p><span style="font-weight: bold; text-decoration: underline;">Customer Information:</span></p>
<p>@plansold.CustName<br />@plansold.Address1 @plansold.Address2<br />@plansold.City, @plansold.State @plansold.Zip<br />@plansold.Phone</p>
<p>Customer Code: @plansold.ContactCode Customer Acct No: @plansold.CustARNumber</p>
<p><span style="font-weight: bold; text-decoration: underline;">Machine Information:</span></p>
<p>Make: @plansold.Make<br />Model: @plansold.Model<br />VIN / Serial: @plansold.SerialNumber<br />Hours: @plansold.MachineHours</p>
<p><span style="font-weight: bold; text-decoration-line: underline;">Maintenance Plan Details:</span></p>
.etc..etc..etc..</div>
Im trying to find a method to extract the rendered HTML into a string that I can use to generate a pdf file. Im in the middle of testing several 'HTML TO PDF' libraries, but none of them have described how to do this. I did try the link at How to render a Blazor component into an HTML string but got compile errors on the Service injection side. Lots of articles out there on printing "Hello World" from Blazor, but that's not helping me, as I need to include my customer information. Ideally looking to extract all rendered html from my div tags only.
Im using .NET 5 / Blazor 5.