Free Support Forum - aspose.com

HTML file to PDF creation

Creation of a pdf from an html file or stream

I can create a stream or html file easily enough however when using the
BindHTML method the resulting XML file is void of anything that resembles
the html file and hence the pdf is also. Code below:

try
{
Pdf pdf1 = new Pdf();
pdf1.Security = new Security();
pdf1.Security.UserPassword = “TEST”;
string licenseFile = MapPath(“License”) + \Aspose.Pdf.lic;
Aspose.Pdf.License pdflicense = new Aspose.Pdf.License();
pdflicense.SetLicense(@licenseFile);
pdf1.CompressionLevel=9;

string htmlFile = Server.MapPath("~/ASPOSE/PDF/TESTPAGE.htm");

// Create a html file
StreamWriter sw = File.CreateText(htmlFile);
sw.Write(RadEditor1.Html);
sw.Close();

pdf1.BindHTML(htmlFile);
pdf1.Save(Server.MapPath("~/ASPOSE/PDF/") + @“Test.pdf”);

System.IO.File.Delete(htmlFile);
}
catch(Exception ex)
{
Response.Write (ex.Message);
}

Where am I going wrong? I am using version 2.3.0 PDF.

Html file is a simple

This changes the actual Page code Cool

Kind regards
Gareth

Dear Gareth,

Thank you for considering Aspose.Pdf.

Please make sure the html document you generated is valid. If it is valid, please attach it in the post and let us test it.