We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

HTML to PDF in earlier version?

Hi,

Is there a way in a previous version of syncfusion (6.3) to be able to take an html string and convert to PDF?

Many thanks,

Jesse Robbins

5 Replies

SS Sri Subhashini M Syncfusion Team October 6, 2009 07:30 AM UTC

Hi Jesse,

Thank you for your interest in Essential PDF.

We can convert a HTML content as PDF document using the method FromString() in previous version of Essential PDF (6.3). We recommend you to upgrade to our latest version. We have very good support for HTML to PDF in this version.

Please let me know if you need any further assistance.

Regards,
Suba


JR Jesse Robbins October 6, 2009 02:20 PM UTC

Can you please give me an example of this? Does this use HTMLConverter? If so, what namespace is this using (i.e. System.PDF) in version 6.3.0.30?

Thanks,

Jesse


SS Sri Subhashini M Syncfusion Team October 7, 2009 01:35 PM UTC

Hi Jesse,

Could you please do find the sample which demonstrates the FromString() method and let me know if this helps?

http://files.syncfusion.com/samples/PDF.Windows/PDF_Win_90501.zip

Regards,
Suba


JR Jesse Robbins October 7, 2009 06:54 PM UTC

Hi,

Please see error (attached) and code snippet below.



private void GeneratePDF(HttpResponse httpResponse, string PDFPass, string PayYear, string P11D)
{
//Create P11D PDF Document

PdfDocument doc = new PdfDocument();

//Add Page
PdfPage page = doc.Pages.Add();
SizeF pageSize = page.GetClientSize();

//PdfSolidBrush brush = new PdfSolidBrush(Color.Black);
//PdfPen pen = new PdfPen(Color.Black, 1f);

//Set font
//PdfFont font1 = new PdfStandardFont(PdfFontFamily.Helvetica, 8);

//Set Page Dimensions
//page.Section.PageSettings.Orientation = PdfPageOrientation.Portrait;
//page.Section.PageSettings.Margins.Bottom = 0;
//page.Section.PageSettings.Margins.Left = 15;
//page.Section.PageSettings.Margins.Right = 15;
//page.Section.PageSettings.Margins.Top = 0;

PdfUnitConvertor converter = new PdfUnitConvertor();
float width = converter.ConvertToPixels(page.GetClientSize().Width, PdfGraphicsUnit.Point);

//Draw Logo
//string ImagePath = Server.MapPath("..\\Images\\");
//PdfGraphics g = page.Graphics;
//PdfImage pdfImage = new PdfBitmap(ImagePath + "\\urgbx1.jpg");
//g.DrawImage(pdfImage, 5, 20, 69, 24);

HtmlConverter html = new HtmlConverter();
Image img = html.FromString(P11D, ImageType.Metafile);



//PdfMetafile metafile = (PdfMetafile)PdfImage.FromImage(img);
//PdfMetafileLayoutFormat format = new PdfMetafileLayoutFormat();
//format.Break = PdfLayoutBreakType.FitPage;
//format.Layout = PdfLayoutType.Paginate;
//doc.PageSettings.Height = img.Height;
//format.SplitTextLines = false;
//metafile.Draw(page, new RectangleF(0, 25, pageSize.Width, -1), format);


doc.Security.SetPermissions(Syncfusion.Pdf.Security.PdfPermissionsFlags.Print);
doc.Security.UserPassword = PDFPass;
doc.Save("P11D_" + PayYear + ".pdf", httpResponse, HttpReadType.Save);

}


The above code is failing at assigning the new IMage to the FromString conversion. Can you please assist?

Thanks,

Jesse



error_2724a110.zip


TE Thiruvenkadam E Syncfusion Team October 9, 2009 11:41 AM UTC

Hi Jesse,

I regret for the long delay in getting back to you on this.

System.web.HttpUnhandledException

I am afraid that I was not able to reproduce the reported issue in our side . Please check the working sample in the link below location ,

http://files.syncfusion.com/support/PDF.Web/F90501/Sample.zip

Please have a look at the above sample and if still the issue exists,

Could you please try to reproducing it in the above sample or send us few html files or html text so that we could sort out the cause of the issue and provide you a solution?

Please let us know if you need any further information.

Regards,
Thiru

Loader.
Live Chat Icon For mobile
Up arrow icon