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 in PDF

When I put the following code in a Web form as part of a sample provided by you, Syncfusion, HTMLToDoc sample... HTMLToDLS convertor = new HTMLToDLS(); convertor.Convert( document , "This is normal text" ); I receive the following error: bounds Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.ArgumentException: bounds line 168 -> document.Save( "Sample.pdf", Response , Syncfusion.Pdf.HttpReadType.Save); The only part I changed was hardcoding the HTML string instead of using the default text from the provided textbox. Is there something I am doing incorrectly to receive this error? That is the only line of code I changed within the sample project. Also, does the HTML have to be included as part of an HTML page? It can''t take a piece of HTML and add it to the PDF file? For example, does the HTML string have to be "< html >< body >< H1 > Hello < / H1> < / body> < / html >" or can I simply pass in " < h1 > Hello < / h1 >"? Thanks for the help!

18 Replies

AJ Ajish Syncfusion Team June 6, 2006 09:09 AM UTC

Hi Michelle, The code that you use is correct, you can convert normal text or part of html page and convert it to pdf. Here is a asp.net sample which does the same: HTMLToDoc.zip Please take a look at this sample and let me if you have any other questions. Thanks, Ajish.


MC Michelle Cutchins June 6, 2006 08:55 PM UTC

Is there a reason why when I try to add a section/paragraph above or below the HTML conversion in the sample, I receive an error? Code: //Add a section in the PDF document. IPDFSection section = document.AddSection(); //Adding a paragraph to the section. IPDFParagraph paragraph = section.AddParagraph(); paragraph.AppendText("Hello World!"); HTMLToDLS convertor = new HTMLToDLS(); convertor.Convert(document, "

Hello

"); section = document.AddSection(); //Adding a paragraph to the section. paragraph = section.AddParagraph(); //Adding text to the paragraph. paragraph.AppendText("Hello World!"); document.Save( "Sample.pdf", Response , Syncfusion.Pdf.HttpReadType.Save); I was trying to add text above and below the HTML section but get a "bounds" error message. "Exception Details: System.ArgumentException: bounds" Thanks!



AJ Ajish Syncfusion Team June 7, 2006 06:20 AM UTC

Hi Michelle, I am afraid I was unable to reprodue problem. Here is sample which does exactly the same as you do: HTMLToDoc.zip Could you please try this one and let me know if the problem still exists, if so can you send me with more details the stack trace of the error modify the existing sample to reproduce the error so that I can further investigate on this issue. Thanks, Ajish.


MC Michelle Cutchins June 7, 2006 03:55 PM UTC

I am attaching my project, that contains the code from your sample, and I still receive an error message. Thanks! Michelle

HTMLToDoc.zip


JJ Jason Jensen October 9, 2006 04:05 PM UTC

I am having this error too. Did anyone ever receive an answer?

>I am attaching my project, that contains the code from your sample, and I still receive an error message.
>
>Thanks!
>Michelle

HTMLToDoc.zip


JJ Jason Jensen October 9, 2006 04:05 PM UTC

I am having this error too. Did anyone ever receive an answer?

>I am attaching my project, that contains the code from your sample, and I still receive an error message.
>
>Thanks!
>Michelle

HTMLToDoc.zip


JJ Jason Jensen October 9, 2006 04:11 PM UTC

What was the solution to this problem? I am having a similar issue.


DK Dhivya K Syncfusion Team October 10, 2006 05:21 PM UTC

Hi Jason,

I tried testing this issue. I am afraid.I am unable to reproduce the issue.

Html text can be added in PDF in two ways using flow model:

1) Adding html text by using HTMLToDLS convertor in between the sections as in the case of previous post.

Here is a sample for your reference:
www.syncfusion.com/support/user/uploads/HTMLToDoc.zip

Could you please run this sample and let me know if the problem exist?

2) You can also add html using "InsertHTML" method, for which I shall provide you with a sample by tomorrow. This method is available from 4.3.0.30 release.

Regards,
Dhivya.


DK Dhivya K Syncfusion Team October 11, 2006 07:14 AM UTC

Hi Jason,

Here is a sample to insert HTML text between sections using InsertHTML() method.
InsertHTML.zip

Please take a look into it and let me know if you have anyother queries.
Note: InsertHTML() is included from 4.3.0.30 release.

Thanks,
Dhivya.


JW Jimmy Wang October 27, 2006 07:44 PM UTC


void menuSaveFundingMemoAsPDF_Click(object sender, EventArgs e)
{
SaveFileDialog saveFileDialog = new SaveFileDialog();

saveFileDialog.Filter = "PDF files (*.pdf)|*.pdf|All files (*.*)|*.*";
saveFileDialog.FilterIndex = 1;
saveFileDialog.RestoreDirectory = true;
if (saveFileDialog.ShowDialog() == DialogResult.OK)
{
//PDFDocument pdfDoc = new PDFDocument();
//pdfDoc.Pages.Remove(pdfDoc.Pages[0]);
PDFLogicDocument pdfDoc = new PDFLogicDocument();

Dictionary gridList = GetAllGrids(TabExcelSplit, false);
foreach (KeyValuePair kvp in gridList)
{
string sheetName = kvp.Key;
GridControl grid = kvp.Value;
if (sheetName.Trim() == "Funding Memo")
{
SettlementBlastGridBase.ImportGridDataToPDFPage(pdfDoc, grid);
break;
}
}

pdfDoc.Save(saveFileDialog.FileName);
//System.Diagnostics.Process.Start(saveFileDialog.FileName);

pdfDoc.Close();
}
}


I got the same error message from the Save function call. It was working before.

>Hi Jason,

Here is a sample to insert HTML text between sections using InsertHTML() method.
InsertHTML.zip

Please take a look into it and let me know if you have anyother queries.
Note: InsertHTML() is included from 4.3.0.30 release.

Thanks,
Dhivya.


DK Dhivya K Syncfusion Team November 1, 2006 01:08 PM UTC

Hi Jimmy,

Thanks for the code snippet.
I refered your stack trace which you have posted in following url:
http://www.syncfusion.com/support/forums/message.aspx?&MessageID=51125
Can you please provide me with the details regarding your system configuration,.Net framework version and Essential studio version.This will help me investigating further on this issue.

Thanks,
Dhivya.


MZ Marc Ziss December 18, 2006 04:50 PM UTC

Dhivya,
I want to convert an entire HTML doc (not just some text) to a pdf; Is the InsertHTML() the best way to do this? I'm having problems (it hangs) with saving it after reading the entire html document in.
Thanks for your help,
Marc

>Hi Jason,

Here is a sample to insert HTML text between sections using InsertHTML() method.
InsertHTML.zip

Please take a look into it and let me know if you have anyother queries.
Note: InsertHTML() is included from 4.3.0.30 release.

Thanks,
Dhivya.


DK Dhivya K Syncfusion Team December 22, 2006 06:53 AM UTC

Hi Marc,

Thank you for your interest in Essential PDF.

InsertHTML can handle only simple html strings. However, we do have option to convert a html page into image[bitmap or metafile] and render that image into the PDF document.

Converting to Bitmap image will have lower resolution, but it will be fast.

Converting to Metafile will have high resolution and the text will be searchable,but it will be slow.

You can find the sample at the following url:
C:\Program Files\Syncfusion\Essential Studio\4.4.0.51\Windows\Pdf.Windows\Samples\Grid Model\HTMLToPDF

Please let me know if you have any queries.

Regards,
Dhivya.


FL Florin January 19, 2007 06:42 PM UTC

Hi,

I've been running the C:\Program Files\Syncfusion\Essential Studio\4.4.0.51\Windows\Pdf.Windows\Samples\Grid Model\HTMLToPDF sample and I noticed with metafile options checked the image for http://www.syncfusion.com is not correct. In the left side the text "The Syncfusion Grid is atleast 3 times " overlaps with the next line.
When generating an image (uncheck the metafile option) the result is correct. Why is happening this?

Then I tried to generate a PDF with an image that spans on many pages but I couldn't find a way to insert page number in the bottom without to have the image overlapping with the footer. Do you have any sample for this?

Regards,
Florin


>Hi Marc,

Thank you for your interest in Essential PDF.

InsertHTML can handle only simple html strings. However, we do have option to convert a html page into image[bitmap or metafile] and render that image into the PDF document.

Converting to Bitmap image will have lower resolution, but it will be fast.

Converting to Metafile will have high resolution and the text will be searchable,but it will be slow.

You can find the sample at the following url:
C:\Program Files\Syncfusion\Essential Studio\4.4.0.51\Windows\Pdf.Windows\Samples\Grid Model\HTMLToPDF

Please let me know if you have any queries.

Regards,
Dhivya.


DK Dhivya K Syncfusion Team January 22, 2007 01:30 PM UTC

Hi Florin,

Thank you for your interest in Essential PDF.

I tried testing this issue with overlapping text with metafile option. I am afraid. I am unable to reproduce the issue.
Here is a sample PDF generated.
http://www.syncfusion.com/Support/user/uploads/sample_adb1db78.pdf

As said in my previous post,Converting to Bitmap image will have lower resolution, but it will be fast.
Converting to Metafile will have high resolution and the text will be searchable,but it will be slow.

Regarding rendering the image without overlapping the footer,add the footer before you render the image into PDF.
Here is a sample for your reference:
HTML_to_PDF.zip

Please take a look into the sample and let me know if you have any other queries.

Regards,
Dhivya.


JW Jimmy Wang March 15, 2007 06:54 PM UTC

It happens when trying to export a grid to a PDF file. Following is the call stack:

Stack Trace : at Syncfusion.Layouting.LayoutArea.TopSubtract(RectangleF bounds)
at Syncfusion.Layouting.LCLineContainer.CommitForClosed(LCBase childContext)
at Syncfusion.Layouting.LCContainer.CommitChildContext(LCBase childContext)
at Syncfusion.Layouting.LCContainer.Layout(RectangleF rect)
at Syncfusion.Layouting.LCContainer.DoLayoutChild(LCBase childContext)
at Syncfusion.Layouting.LCContainer.Layout(RectangleF rect)
at Syncfusion.Layouting.LCContainer.DoLayoutChild(LCBase childContext)
at Syncfusion.Layouting.LCContainer.Layout(RectangleF rect)
at Syncfusion.Layouting.Layouter.Layout(IWidgetContainer wtContainer, ILayoutProcessHandler lpHandler, CustomGraphics cg)
at Syncfusion.DLS.Rendering.DocumentLayouter.LayoutPages()
at Syncfusion.DLS.Rendering.DocumentLayouter.Layout(IDocument doc, CustomGraphics cg)
at Syncfusion.Pdf.DLS.PDFLogicDocument.DrawToInnerDocument()
at Syncfusion.Pdf.DLS.PDFLogicDocument.Save(String fileName)

It does not happen when starting my app to debug.


AD Administrator Syncfusion Team March 16, 2007 09:48 PM UTC

Hi Jimmy,

Thank you for your continued interest in Syncfusion products.

Can you please provide us with some detailed information on this issue. Also can you please proivde us the details regarding your system configuration, .Net Framework version and Essential studio version you are working with.

Please let me know if you face any issues.

Thanks,
Dhivya.


AD Administrator Syncfusion Team March 16, 2007 09:49 PM UTC

Hi Jimmy,

Thank you for your continued interest in Syncfusion products.

Can you please provide us with some detailed information on this issue. Also can you please proivde us the details regarding your system configuration, .Net Framework version and Essential studio version you are working with.

Please let me know if you face any issues.

Regards,
Sarath

Loader.
Live Chat Icon For mobile
Up arrow icon