HTML file to PDF document

Hello Friends,

Can any one please guide me to convert html file (in my local machine) to PDF file. Here i wants to open the HTML file and save to memory stream and add some contents to HTML file and then convert it to PDF file

Regards,
Vivek Asthana

@vivekasthana1492

Thank you for contacting support.

Would you please elaborate what contents do you want to add to the file. Can you add that content to resultant PDF file after conversion or do you want to add the content to HTML file and later convert it to PDF. Please clarify these requirements so that we may guide you accordingly.

Hello Farhan,

Thanks for reply.
Sure please find the attached PDF which i wants to convert in HTML. and in that HTML i wants to add dynamic HTML and again convert it to PDF file

checklist-SATR-L-2001_Piping_Generic-Piping-Item-GPI.pdf (168.8 KB)

Regards,
Vivek Asthana

@vivekasthana1492

You can convert a PDF document to HTML file with Aspose.PDF for .NET API as explained over Convert PDF File into HTML Format. Then you can edit HTML document with Aspose.HTML for .NET API by using below code snippet. After editing the HTML file, you may convert it to a PDF document as explained over HTML to PDF Conversion.

About editing the HTML file, you can edit the DOM tree by attaching new elements, editing attributes and properties already existing elements or just removing them from the DOM tree.

using (var document = new Aspose.Html.HTMLDocument())
{
    var body = document.Body;
    // Create paragraph element
    var p = (HTMLParagraphElement)document.CreateElement("p");
    // Set custom attribute
    p.SetAttribute("id", "my-paragraph");

    // Create text node
    var text = document.CreateTextNode("my first paragraph");

    // Attach text to the paragraph
    p.AppendChild(text);

    // Attach paragraph to the document body
    body.AppendChild(p);
}

Along with method AppendChild you can also use the methods RemoveChild and ReplaceChild to edit an existing document content. If you still find any problem, then please elaborate ‘Dynamic Content’ while sharing this content along with expected output, so that we may proceed further to help you out.