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

PDF from large html file

I have registered to your product to test it myself before buyint it for my employer.

I want to do a PDF page from a webform with some textbox controls. The PDF is made of fixed text and values form textbox controls.
All the fixed text contains basic HTML tags and is stored in a text file.
The text include the content of textbox controls and a mutline textbox.
Minimum text length : 8254. Maximum text length : 8856

At a place in the generated PDF, I want to place some rectangles near the text.
To do this, I have made 2 files, the first start at the beginning and stop before rectangles, and the second starts after rectangles.

I draw text with this code :
PdfHTMLTextElement richTextElement = new PdfHTMLTextElement(oStringBuilder.ToString(), font, PdfBrushes.Black);
The first problem is that the whole text is not written. I have to add an additional height, like this :
PdfLayoutResult oPdfLayoutResult = richTextElement.Draw(page, new PointF(0, 70), page.GetClientSize().Width, page.GetClientSize().Height + fAditionalHeight, format);

I have a second problem. I determine the end of the text, to set the rectangles location.Y with :
float fEnd = oPdfLayoutResult.Bounds.Bottom;
RectangleF yes = new RectangleF(0, finPart1, convertor.ConvertUnits(5, PdfGraphicsUnit.Millimeter, PdfGraphicsUnit.Point), convertor.ConvertUnits(5, PdfGraphicsUnit.Millimeter, PdfGraphicsUnit.Point));
RectangleF no = new RectangleF(0,finPart1 + convertor.ConvertUnits(8, PdfGraphicsUnit.Millimeter, PdfGraphicsUnit.Point),convertor.ConvertUnits(5, PdfGraphicsUnit.Millimeter, PdfGraphicsUnit.Point),convertor.ConvertUnits(5, PdfGraphicsUnit.Millimeter, PdfGraphicsUnit.Point));
page.Graphics.DrawRectangle(PdfPens.Black, yes);
page.Graphics.DrawRectangle(PdfPens.Black, no);

but whatever the text length,  has allways the same value.
With the minimum text length (8254), there is a "hole" between the end of the first text and rectangles.
There is there a way to fix this ?
I hope you understand my problems and you could help me.

1 Reply

PH Praveenkumar H Syncfusion Team November 4, 2014 04:20 AM UTC

Hi Lalleman,

Thank you for using syncfusion products,

We have created the sample which fulfill your requirement please try the attached sample and let us know if you need further assistance in this.

With Regards,


Attachment: PDF_Html_text_ecc712c8.zip

Live Chat Icon For mobile
Up arrow icon