Home Forums Support API email_invoice

This topic contains 9 replies, has 3 voices, and was last updated by  Hillel Coren 2 months, 2 weeks ago.

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #572

    Anonymous

    Hi,

    how can I send PDF as attachement by using API
    curl -X POST ninja.dev/api/v1/email_invoice -H "Content-Type:application/json" -d '{"id":1}' -H "X-Ninja-Token: TOKEN"

    #573

    Hillel Coren
    Keymaster

    It’s not supported. The invoice would need to first be saved through the web interface for the PDF to be cached/attached.

    We’re looking into a server-side implementation of the PDF generator in a future release.

    #574

    Anonymous

    Thank you for quick response. It is interesting that user receives link where PDF is generated.

    #576

    Anonymous
    console.log('Loading a web page');
    var fs = require('fs'),
        system = require('system'),
        page = require('webpage').create();
    
    page.viewportSize = { width: 1920, height: 1080 };
    page.settings.userAgent = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36';
    page.settings.webSecurityEnabled = false;
    
    var url = 'http://';
    page.open(url, function (status) {
      if (status !== 'success') {
          console.log('Unable to access the network!');
      } else {
    
        var pdf_binary = page.evaluate(function() {
            try {
              onDownloadClick();
              return doc.output();
            } catch (err) {
              console.log("exception: " + err);
            }
        });
        fs.write('1.pdf', pdf_binary, 'b');
        phantom.exit();
      }
    });
    
    page.onConsoleMessage = function(msg) {
        //console.log(msg);
        console.debug(msg);
    };
    

    Here is workaround.

    #577

    Hillel Coren
    Keymaster

    Thanks for sharing your solution!

    #578

    Anonymous

    No problem. This is phantomjs solution.

    #19178

    mmmichael
    Participant

    are there any changes with this topic? I created an invoice via API and send it via mail, but the pdf is not attached.

    #19179

    Hillel Coren
    Keymaster

    Does the test link on Settings > Email Settings work?

    https://invoice-ninja.readthedocs.io/en/latest/configure.html#troubleshooting

    #19180

    mmmichael
    Participant

    just to be sure: everything works fine if we use the backend. This is the first time I created the invoice via API and send it directly.

    If i view this invoice onetime in the browser everything works fine.

    #19181

    Hillel Coren
    Keymaster

    If you view the PDF in your browser the browser renders it, otherwise we use PhantomJS.

Viewing 10 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic.

Posted in: