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

Error while saving pdf using save method of PdfDocument

Thread ID:

Created:

Updated:

Platform:

Replies:

108458 Apr 22,2013 02:52 PM UTC May 27,2013 03:55 AM UTC ASP.NET Web Forms (Classic) 6
loading
Tags: PDF
Prakash Makhija
Asked On April 22, 2013 02:52 PM UTC

Hi ,

I am creating a pdf from html document and saving the file.

when I use

document.Save("htmltopdf.pdf");

It's works fine, but when I use:

document.Save("htmltopdf.pdf", Response, HttpReadType.Save);

It gives error i.e. when I try to save file on client machine it doesn't work

Can you please help me out solve this problem.

I have attached the code.

 



syncfusiontest_83e8accc.rar

KarthikeyanC [Syncfusion]
Replied On April 24, 2013 08:55 AM UTC

Hi Prakash,

Thank you for using Syncfusion Products.

 

Please include the following mentioned line for generating PDF without error.

Thread t = new Thread(new ThreadStart(converter));

t.SetApartmentState(ApartmentState.STA);

t.Start();

t.Join();

 

Please let us know if you have any concern.

 

Thanks,

Karthikeyan.C


Prakash Makhija
Replied On April 28, 2013 11:25 PM UTC

Thanks!!

It works when I created a project in my machine and executed but when i deployed on server and try to call aspx page on click of button it doesn't work.

Can you please let me know the possible causes?



KarthikeyanC [Syncfusion]
Replied On May 1, 2013 09:01 AM UTC

Hi Prakash,

Thank you for your update.

 

Please use the HTML converter inside “Using” statement, here is the code snippet:

using (HtmlConverter html = new HtmlConverter())

{

  Image img = html.ConvertToImage("http://www.google.com", ImageType.Metafile, (int)width, (int)pageSize.Height, AspectRatio.KeepWidth);

 

I have attached a sample for your reference.

WebApplication1.zip

Also make sure that web application deployed in full trust mode.

We do not support for converting HTML to PDF in Medium Trust.

Please refer the link for more details.

http://help.syncfusion.com/ug/wpf/pdf/default.htm#!documents/232webapplicationdeployment.htm

 

Please let us know if you have any concern.

 

Thanks,

Karthikeyan.C

 


Prakash Makhija
Replied On May 22, 2013 08:55 AM UTC

Hello,

I have noticed that t.join in the below code is giving error when i deploy the code on server.

Thread t = new Thread(new ThreadStart(converter));

t.SetApartmentState(ApartmentState.STA);

t.Start();

t.Join();

If i comment the join stmt it doesn't give error, it just display the blank page i.e. converter method doesn't get executed, can you please let me know the possible cause of error?

Thanks


Prakash Makhija
Replied On May 22, 2013 12:17 PM UTC

Hello,

I got it working, the issue was Microsoft.MSHTML.dll was not there in GAC, but i got another issue my web page is more than one page but in pdf it renders only one page so i lost remaining data.

Can you please provide me the solution to this problem?

Thanks

 


KarthikeyanC [Syncfusion]
Replied On May 27, 2013 03:55 AM UTC

Hi Prakash,

Thank you for your update.

 

Could you please set the Layout to Paginate.

Please see the code snippet below:

//Set the layout format

PdfMetafileLayoutFormat format = new PdfMetafileLayoutFormat();

format.Layout = PdfLayoutType.Paginate;

 

This will create the multipage Pdf document. The sample attached in the last update have these code snippet.

Please let us know if you have any concern.

 

Thanks,

Karthikeyan.C

 


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

;