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

Converting Aspx page into PDF file.

Hi,
I doing some assignment for converting aspx page in to pdf.I am using Syncfusion 5.1.1.47.
I added two aspx pages in webproject and written code for converting second page in to pdf in the page load of first page. But when code is executed i am getting null exception for following line.
System.Drawing.Image _img = html.ConvertToImage("webpage.aspx", ImageType.Bitmap);
Here i have mentioned "webpage.aspx" page to be converted in to pdf file. Since i am calling convertoimage function by passing appropriate parameter it is returning null value not a converted image. Please let me know what is wrong in above code since i copied it from your snippest.
Also let me know can we convert any aspx page which user modifies by adding/editing few data and instead of save clicks convert to pdf button? Please provide help.
Thanks in advance.

12 Replies

AD Administrator Syncfusion Team October 18, 2007 05:57 PM UTC

Hi Ganesh,

Thank you for your interest in Syncfusion products.

Please follow the steps below that has to be done under Asp.net environment for converting HTML webpage to PDF document .

1) Include the attribute AspCompat="true" in the @Page directive.

Here is the code snippet

[Aspx]
<%@ Page Language="C#" AutoEventWireup="true" AspCompat="true" %>

2) Reference the "AxSHDocVw.dll, SHDocVw.dll" assembly to the project. This dll can be found along with the below sample that shipped with Essential studio.

[Install drive]:\Documents and Settings\Username\My Documents\Syncfusion\ EssentialStudio \version\Windows\Pdf.Windows\ Samples\2.0\HtmlToPdf\CS

3) Place these COM assemblies in the "BIN" directory of your project.

The above steps helps you to resolve the issues you have faced.

I am working on the sample and will update you tomorrow in the specified version along with second query 'Whether data added into Aspx can be converted to PDF' .

Please let me know if you have any other queries.

Regards,
Jaya


AD Administrator Syncfusion Team October 25, 2007 02:04 PM UTC

Hi Ganesh,

Sorry for the delayed response.

Please refer the working sample in the below location and let me know if you have any other queries.

http://websamples.syncfusion.com/samples/PDF.Web/5.1.1.47/HTMLToPDFWeb_5.1/main.htm

Thanks for your patience.

Regards,
Jaya


MI Mike January 15, 2008 03:18 PM UTC

I tried your sample in my computer.
But I got an error.

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

I'm wondering what is wrong.

Thanks

>Hi Ganesh,

Sorry for the delayed response.

Please refer the working sample in the below location and let me know if you have any other queries.

http://websamples.syncfusion.com/samples/PDF.Web/5.1.1.47/HTMLToPDFWeb_5.1/main.htm

Thanks for your patience.

Regards,
Jaya



AD Administrator Syncfusion Team January 17, 2008 09:48 AM UTC

Hi Mike,

Sorry for the delay in getting back to you.

If you try to open the PDF document inside the browser windows and it opens as blank page or hangs up then you can try the following trouble shooting steps:

1) Please try the following trouble shooting option in the following link.

http://www.bnl.gov/itd/webapps/pdf_help.asp

2) The problem might also be because of the ActiveX controls are not being properly loaded as expected in Internet Explorer. Please try the following if point #1 did not work out.

http://support.microsoft.com/kb/909889

Please let me know if this helps you.

Regards,
Jaya



PR Pierpaolo Rebecchi February 1, 2008 09:06 AM UTC

I have exactly the same exception (ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because).
I installed on our server the code from rel='nofollow' href='http://websamples.syncfusion.com/samples/PDF.Web/5.1.1.47/HTMLToPDFWeb_5.1/main.htm' and it gives me the execption. The execption is thrown by HtmlConverter html = new HtmlConverter().

Please give us a solution to this issue as soon as possible. Thank you very much. Best regards

>I tried your sample in my computer.
But I got an error.

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

I'm wondering what is wrong.

Thanks

>Hi Ganesh,

Sorry for the delayed response.

Please refer the working sample in the below location and let me know if you have any other queries.

http://websamples.syncfusion.com/samples/PDF.Web/5.1.1.47/HTMLToPDFWeb_5.1/main.htm

Thanks for your patience.

Regards,
Jaya





AD Administrator Syncfusion Team February 1, 2008 01:14 PM UTC

Hi Rebecchi,

Thank you for your interest in Syncfusion products.

Could you please make sure whether your webserver is configured for using ActiveX controls?

If you have some problems in opening the pdf file in web browser, please try the trouble shooting options specified in the previous update.

Please let me know if you still face any further issues.

Regards,
Jaya




AN Anil March 13, 2008 04:09 PM UTC

Hi Jaya,
I tried the code after making the changes that you suggested. On click of a button (for Converting the webpage to pdf), I am getting an error which says "Internet explorer cannot download "
Am I missing something here? Any IE settings etc?
Please suggest.

Thanks,
Anil P

>Hi Ganesh,

Thank you for your interest in Syncfusion products.

Please follow the steps below that has to be done under Asp.net environment for converting HTML webpage to PDF document .

1) Include the attribute AspCompat="true" in the @Page directive.

Here is the code snippet

[Aspx]
<%@ Page Language="C#" AutoEventWireup="true" AspCompat="true" %>

2) Reference the "AxSHDocVw.dll, SHDocVw.dll" assembly to the project. This dll can be found along with the below sample that shipped with Essential studio.

[Install drive]:\Documents and Settings\Username\My Documents\Syncfusion\ EssentialStudio \version\Windows\Pdf.Windows\ Samples\2.0\HtmlToPdf\CS

3) Place these COM assemblies in the "BIN" directory of your project.

The above steps helps you to resolve the issues you have faced.

I am working on the sample and will update you tomorrow in the specified version along with second query 'Whether data added into Aspx can be converted to PDF' .

Please let me know if you have any other queries.

Regards,
Jaya





AD Administrator Syncfusion Team March 25, 2008 03:27 AM UTC

Hi Anil,

Thanks for the update.

Please make sure that you have added this attribute AspCompat="true" in the @Page directive and check the whole thread and verify you have tried all the possibilities.

If you are still able to reproduce this issue, could you please send your system configuration, IE version, Essential studio version and please provide your HTML file that you have tried to convert to PDF, so that we can investigate more on this issue?

Best Regards,
Bhuvana




KE Kevin March 26, 2008 07:45 AM UTC

I am Converting a webpage to a PDF file
Using SyncFusion EssentialStudio 5.1.1.47
and ASP.NET 2.0
As I see it, this is done in 2 steps
HTML to Image -> Image to PDF
The problem is when ever I run my code or the sample that u guys have put up, from the "Asp.Net Development Server" it returns a "null Image"

Now if i publish the code on to a server running IIS then it runs fine but not always
some times it gives a "COM Object Fail check H_Result ..... error "

this get sorted out if we restart www services on the server

can somebody explain why this happens it would be really helpfull




AD Administrator Syncfusion Team March 31, 2008 07:16 AM UTC

Hi Kevin,

This is a known issue but we couldn't reproduce this issue in our machines. We tried all the possible ways for reproducing this but of no help. This issue is due to usage of interop assemblies which throws this exception in some environment due to IIS restrictions. Some of the solutions suggested in websites for these kind of exception are :

1) Set ASP .NET permission to System
2) Restart IIS
3) Generate com assemblies internally in your server.

Best Regards,
Bhuvana



AD Administrator Syncfusion Team May 8, 2008 08:17 AM UTC

Hi divya

I am also facing the same problem and raised a ticket in direct track.
https://www.syncfusion.com/Support/DirectTrac/user/details.aspx?id=45950

can you please explain me in detail. thanks



NR Nandakumar R Syncfusion Team May 8, 2008 01:11 PM UTC


Hi Pon Saravanan,

Thank you. The incident has been updated with the details and also the similar forum post has also been updated with the details.

Please let us know if you have any other concerns.

Regards,
Nanda



Loader.
Live Chat Icon For mobile
Up arrow icon