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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Does HTMLtoPDF allow setting virtual Client width?

Thread ID:

Created:

Updated:

Platform:

Replies:

48899 Sep 6,2006 08:13 AM UTC Sep 11,2006 11:53 AM UTC ASP.NET Web Forms (Classic) 3
loading
Tags: PDF
Jason Finch
Asked On September 6, 2006 08:13 AM UTC

Hello,

I was wondering if there exists in the HTMLtoPDF methods a way of setting the psuedo browsers width.

For example a browser at 800 pixels wraps things differently than say one at 1027 pixels. Does the conversion to PDF allow setting something that would allow a wider pixel width, and then also possibly allow a scaling feature to fit back onto standard page width.

In the help file, I found InputHTML.ClientSize property Is this what would perform this above?

I would try this myself unfortunately I am having problems getting the product to convert at the moment without error.

Dhivya K [Syncfusion]
Replied On September 7, 2006 01:29 PM UTC

Hi Jason,

Yes,it is possible to set the width of the client in terms of pixel as follows.

1.HTML string is first converted into HTML document using following statement:

//Converts HTMl strings into HTML document.
InputHTML doc = new InputHTML(StreamFromString(text), manager);

2.The HTML document is converted into Bitmap image.

3.Bitmap image is then rendered into PDF whose pixels can be adjusted as follows.

//This will set the client size in terms of pixels
doc.ClientSize = new Size((int)pdfDoc.Graphics.ConvertUnits(pdfDoc.LastPage.DrawingWidth,PrintUnits.Point,PrintUnits.Pixel),800);

Here is a sample for your reference.
HTMLToDoc_44c2c9cf.zip

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

Thanks,
Dhivya.

Jason Finch
Replied On September 11, 2006 01:30 AM UTC

Thanks Dhivya

Unfortunately I was using htmlConverter object so I couldn''t figure out how to apply what you wrote below to the code example I had.

I did notice in Object Browser I could pass ConvertToImage the width of the browser.
ie.
HtmlConverter html = new HtmlConverter()
html.ConvertToImage(this.TextBox1.Text, GetImageType(),1024))

I could not find any mention of this in the Documentation, mayby this could be updated?

Regards,
Jason

>Hi Jason,

Yes,it is possible to set the width of the client in terms of pixel as follows.

1.HTML string is first converted into HTML document using following statement:

//Converts HTMl strings into HTML document.
InputHTML doc = new InputHTML(StreamFromString(text), manager);

2.The HTML document is converted into Bitmap image.

3.Bitmap image is then rendered into PDF whose pixels can be adjusted as follows.

//This will set the client size in terms of pixels
doc.ClientSize = new Size((int)pdfDoc.Graphics.ConvertUnits(pdfDoc.LastPage.DrawingWidth,PrintUnits.Point,PrintUnits.Pixel),800);

Here is a sample for your reference.
HTMLToDoc_44c2c9cf.zip

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

Thanks,
Dhivya.

Dhivya K [Syncfusion]
Replied On September 11, 2006 11:53 AM UTC

Hi Jason,

Thank you for pointing out the missing functionality in documentation.It will be modified in next release.

You are right. html.ConvertToImage has browser width and height as one of its overload which allows to set width and height of browser in grid model. In grid model, it works as follows:
1. Html page is converted into bitmap/metafile image using HtmlConverter.
2. Image is then rendered into PDF with the specified width and height.
Here is a sample for your reference.
HTML_TO_PDF_CS_2005.zip

However,"ClientSize" is used to set the browser width in flow model where the html tags are used as input.

Please let me know if you have any other queries.
Thanks,
Dhivya.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;