Giter Club home page Giter Club logo

Comments (5)

mplodowski avatar mplodowski commented on September 9, 2024

OctoberCMS ajax framework cannot handle this type of response.

Read this: octobercms/october#2182

Recommended approach is to save PDF file locally and return redirect to PDF file.

from dynamicpdf-plugin.

virtualLast avatar virtualLast commented on September 9, 2024

Hi that is the way I decided to go after testing a few other things out.

from dynamicpdf-plugin.

chocolata avatar chocolata commented on September 9, 2024

Hi, does anyone have a code example?

I'm trying to generate a PDF via a button in the backend of the update page of a model. The button uses the October CMS AJAX framework and calls a function onGeneratePDF in the controller file.

I tried:

        $path = 'storage/app/media/'.$file.'.pdf';
        $saved = PDF::loadTemplate($templateCode, $data)->save($path);
        $headers = [
            'HTTP/1.1 200 OK',
            'Pragma: public',
            'Content-Type: application/pdf'
        ];
        return Response::download(base_path($path), $file.'.pdf', $headers)->deleteFileAfterSend(true);

This does generate the file (and clears it), but it does not show it to the browser.

The following

return Redirect::to('storage/app/media/'.$file.'.pdf');

... does work, but it has the disadvantage that the file stays on the server and this is not intended. The PDF contains private information and should not be available via a URL.

What is the right way to tackle this?

from dynamicpdf-plugin.

mplodowski avatar mplodowski commented on September 9, 2024

Read documentation:

https://github.com/mplodowski/dynamicpdf-plugin#tip-download-pdf-via-ajax-response

If you just want to stream PDF, than just create normal method in controller:

https://github.com/mplodowski/dynamicpdf-plugin#render-pdf-in-browser

from dynamicpdf-plugin.

chocolata avatar chocolata commented on September 9, 2024

I wouldn't ask a question without reading the docs... I solved it in a different way, via an attachOne relation to my model and redirecting to that.

from dynamicpdf-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.