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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

HTML to PDF conversion

Thread ID:

Created:

Updated:

Platform:

Replies:

90473 Oct 2,2009 08:35 PM UTC Jun 29,2011 09:12 PM UTC ASP.NET Web Forms (Classic) 22
loading
Tags: PDF
Prema Varma
Asked On October 2, 2009 08:35 PM UTC

When using the HtmlConverter to convert html script to PDF the hyperlinks get dropped in the conversion.

Is this a bug or am I missing something??

Thiruvenkadam E [Syncfusion]
Replied On October 5, 2009 09:15 AM UTC

Hi Prema,

Thank you for your interest in Syncfusion products.

Hyperlinks are get dropped in HTML to PDF conversion

We can able to resolve the above issue by using the "HtmlConverter.EnableHyperlinks=true" property.

Kindly refer the below code snippet.

HtmlConverter html = new HtmlConverter();
// Setting Hyplerlink
html.EnableHyperlinks = true;
// setting Javascript
html.EnableJavaScript = true;
HtmlToPdfResult result = html.Convert("http://www.syncfusion", ImageType.Metafile, (int)width, (int)height,AspectRatio.KeepWidth);


Could you please find the sample from the below location and let us know if this helps.

http://files.syncfusion.com/support/PDF.Windows/F90473/HtmltoPdf.zip

Also please look at the below location if you need more information about the HTMLtoPDF conversion.

http://help.syncfusion.com/UG/Reporting/PDF/ASP.NET/Documents/441htmltopdf.htm

Regards,
Thiru


Prema Varma
Replied On October 5, 2009 01:34 PM UTC

The link seems to work fine now.

However, if the HTML script is say 5 pages as an example then only 1 page is written to the PDF document. All the remaining pages get truncated.

Sri Subhashini M [Syncfusion]
Replied On October 6, 2009 07:08 AM UTC

Hi Prema,

I regret for the inconvenience caused.

I was able to reproduce the issue which you mentioned here. But we can resolve the issue by changing the AspectRatio as KeepWidth. Here is the modified code snippet,


HtmlToPdfResult result = html.Convert(htmlContent, Application.StartupPath, ImageType.Metafile, (int)width, (int)-1, AspectRatio.KeepWidth);


Could you please do find the modified sample from the below specified location and let me know if this helps?
http://files.syncfusion.com/samples/PDF.Windows/PDF_Win_60721.zip

Regards,
Suba

Prema Varma
Replied On October 6, 2009 08:16 PM UTC

The HTML conversion is working fine now. Thank you.

I had a couple of other problems:

A)doc.Save("Sample.pdf", Response, HttpReadType.Open);

When using the above command, in a web application the Sample.pdf opens up in the same browser that the webPage is called. Is there a way to open this PDF in a new window/browser.
Pl. Note this is not a windows application.

B) using (HtmlConverter html = new HtmlConverter()){....}

The following exception gets thrown at the above command line:
ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because the current thread is not in a single-threaded apartment.

The above 2 happen in an ASP.NET Web Application Project.

Prema Varma
Replied On October 7, 2009 01:16 PM UTC

Please ignore the question related to:
pdf.Save("MySample", Response , HttpReadType.Open);

I realized I have to do a
pdf.Save("MySample", Response , HttpReadType.Save);


Thiruvenkadam E [Syncfusion]
Replied On October 9, 2009 11:19 AM UTC

Hi Prema,

I regret for the long delay in getting back with you.

ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because the current thread is not in a single-threaded apartment.

We can able to resolve the above reported issue by adding the AspCompact="true" attribute to the page directive in Default.aspx file.

Kindly refer the below code snippet which helps to resolves the above reported issue.

<%@ Page Language="C#" AutoEventWireup="true" AspCompat ="true" CodeFile="Default.aspx.cs" Inherits="Default" %>

Please do find the sample from the below specified location which resolves the above reported issue and let us know if this helps.

http://files.syncfusion.com/support/pdf.Web/F90473/Sample.zip

Regards,
Thiru

Prema Varma
Replied On October 9, 2009 06:35 PM UTC

In your sample how would you close the Default2.aspx page once the dialog to Open/Save/Cancel PDF document is opened.

Thiruvenkadam E [Syncfusion]
Replied On October 13, 2009 04:31 AM UTC

Hi Prema,

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

If your intention is to close the webpage window after generating the pdf document and we can achieve this by using the window.close() funtion in Javascript.

Kindly reffer the below code snippet.

function closeWindow() {
window.close();
}

Could you please find the sample from the below location and let us know if this helps.

http://files.syncfusion.com/support/pdf.Web/F90473/Sample_Close.zip

If I have misunderstood your requirement, could you please explain me in detail so that I can work in depth and try to send a better solution?

Regards,
Thiru

pusparag
Replied On October 23, 2009 06:28 AM UTC

hi,
was working with html to Pdf funtionality. The external links seem to be working , but i was unable to do work out internal links in a document, like link to the top of a page. Could you please help.

Thiruvenkadam E [Syncfusion]
Replied On October 30, 2009 12:00 PM UTC

Hi Prema,

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

We are currently working on this and we will update you with solution on or before 2nd November 2009.

Please let us know if you need any further information.

Regards,
Thiru

Divya G [Syncfusion]
Replied On November 26, 2009 08:51 AM UTC

Hi pusparag,
Currently Document level bookmarks are not supported during Html to PDF conversion. We have contacted development team for further analysis and will get back to you once we hear from them.
Regards,
Divya.G

Byju P. Nair
Replied On December 10, 2009 09:45 AM UTC

I am evaluating the Essential PDF product in order to find out if it works out of our requirement of converting html files into pdf. I wrote a sample program and came across the following 2 problems, please help resolve it.

1. Iam using asp.net mvc application where I write the convertion code in a controller. When running the conversion, Controller has an exception for something related to "ActiveX control cannot be instantiated". With normal webforms app, it can be resolved using AspCompat="true" attribute on page directive. But how do we resolve it in ASP.NET MVC Controller class?

2. If the html file uses