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
close icon

HTML to PDF conversion

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??

22 Replies

TE Thiruvenkadam E Syncfusion Team 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



PV Prema Varma 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.


SS Sri Subhashini M Syncfusion Team 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


PV Prema Varma 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.


PV Prema Varma 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);



TE Thiruvenkadam E Syncfusion Team 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


PV Prema Varma 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.


TE Thiruvenkadam E Syncfusion Team 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


PU pusparag 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.


TE Thiruvenkadam E Syncfusion Team 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


DG Divya G Syncfusion Team 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


BP Byju P. Nair 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