This is a migrated thread and some comments may be shown as answers.

SaveAsPDF from opening the result while forcing a proxy

1 Answer 86 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Zabbu
Top achievements
Rank 1
Zabbu asked on 13 Nov 2019, 10:07 PM

When I use the Editor's proxy feature and 'force proxy' to true i cannot seem to prevent the response from being opened into a new tab or window.   I would like this to simply save off the PDF and NOT open it in any way.   I presumed that this would be possible by using the proxyTarget and referencing an invisible I-Frame but I have not been able to successfully pull this off.   Any thoughts?

 

<script>
    $("#TestEditor").kendoEditor({
        tools: [],
        pdf: {
            allPages: true,
            proxyURL: 'dynamic',
            paperSize: "Letter",
            margin: { top: "2cm", left: "1cm", right: "1cm", bottom: "1cm" },
            fileName: "Test.pdf",
            forceProxy: true,
            proxyTarget: "_blank"
        }
    });
 
    function MakeMeAPdf() {
        var $editor = $("#TestEditor").getKendoEditor();
        $editor.value("<div>Some HTML stored for the editor</div>");
        $editor.options.pdf.proxyURL = 'http://The.Url.To.com/my_proxy';
        $editor.saveAsPDF();
    }
</script>

1 Answer, 1 is accepted

Sort by
0
Ianko
Telerik team
answered on 15 Nov 2019, 11:22 AM

Hello Zabbu,

The setup used will open the exported PDF to a new tab/window. This is instructed by the proxyTarget: "_blank"

In order to have the file downloaded instead of opened in the browser, you need to setup the  "Content-Disposition" header on the server proxy to attachment; filename="<fileName.pdf>". That is described here: https://docs.telerik.com/kendo-ui/api/javascript/ui/editor/configuration/pdf.proxyurl

Even with that setting adjusted, the browser might still open the PDF instead of downloading it. Here you are an article about how to handle that in Chrome: https://www.makeuseof.com/tag/download-pdf-files-chrome/.

Regards,
Ianko
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Editor
Asked by
Zabbu
Top achievements
Rank 1
Answers by
Ianko
Telerik team
Share this question
or