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

Does HTMLtoPDF allow setting virtual Client width?

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.

3 Replies

DK Dhivya K Syncfusion Team 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.


JF Jason Finch 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.


DK Dhivya K Syncfusion Team 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.

Loader.
Live Chat Icon For mobile
Up arrow icon