Welcome Guest Search | Active Topics | Sign In | Register

Make "Save PDF" dialog appear when using ConvertURL Options
ckmba
Posted: Thursday, February 6, 2014 11:12:41 AM
Rank: Member
Groups: Member

Joined: 4/25/2013
Posts: 17
I would like to know if it is possible to force a "Save As" dialog box when generating a PDF via a ConvertURL() call. When I use the RenderAsPDF() call to render page contents as a PDF it generates a "Save As" dialog box, but it doesn't do that when I use the ConvertURL() call.


Process that I would like to happen:
1. Click a Button on page 1
2. Request contents from page 2
3. Get the contents and put into pdf
3. Stay on page 1 and see a view/save dialog


What Actually happens now:
1. Click a Button
2. Opens pdf in pdf viewer


Here is the code that I'm trying:

Code: C#
protected void Button1_Click(object sender, EventArgs e)
    {
        //Convert to the output stream
        EO.Pdf.PdfDocument doc = new EO.Pdf.PdfDocument();

        HttpResponse response = HttpContext.Current.Response;
        response.Clear();
        response.ClearHeaders();
        response.ContentType = "application/pdf";


        EO.Pdf.HtmlToPdf.ConvertUrl("www.abc.com/page2.aspx", doc );

        doc.Save(Response.OutputStream);


        response.End();

    }



I also tried to do something like this:


Code: C#
protected void Button1_Click(object sender, EventArgs e)
    {
        //Convert to the output stream
        EO.Pdf.PdfDocument doc = new EO.Pdf.PdfDocument();

        EO.Pdf.HtmlToPdf.ConvertUrl("www.abc.com/page2.aspx", doc );

                //Save the PDF file
        doc.Save(Path.GetTempPath() + "test.pdf");

    }


Thanks in advance for your help!
eo_support
Posted: Thursday, February 6, 2014 1:19:28 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,196
Hi,

EO.Pdf does not have built-in support for this since this is a generic Web programming topic that can arise with any kind of dynamically created content. You can search online for how to display "save as dialog" and you should be able to find additional information on that. Alternatively, you can also take a look of the Downloader control in our EO.Web product. The Downloader control is specifically built for this purpose and can handle any kind of content.

Thanks!
ckmba
Posted: Thursday, February 6, 2014 1:30:08 PM
Rank: Member
Groups: Member

Joined: 4/25/2013
Posts: 17
Thanks for your reply. Is there a specific reason why when I use RenderAsPDF() it shows the save dialog but when I use ConvertURL() it does not? Also, unfortunately I did look online and didn't really find anything useful. :(
eo_support
Posted: Thursday, February 6, 2014 1:54:27 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,196
Hi,

I apologize that I was not accurate. ASPXToPDF does have built-in "Save As" support. You can turn it on or off with this property:

http://www.essentialobjects.com/doc/1/eo.web.aspxtopdf.resultasdownload.aspx

However the core HTML to PDF converter has nothing to do with your Web application (many users don't even use it in a web application), so it does not do anything regarding the "Save As" option. As such in order to force a download with ConvertUrl/ConvertHtml, you have to use the Downloader, or if you already have additional code to force dynamic contents as a download, you can use that as well.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.