Forum Discussion

acesario's avatar
acesario
Contributor II
5 years ago
Solved

Adding utilities to snaplogic to generate pdf files (from an html input document)?

I’m wondering if it is possible to add utilities to snaplogic to support scripting. Specifically I’m looking for something to help write dynamically generated (via xslt) html into a pdf file , basically to get a pretty print data output to our sftp server.

There seem to be a lot of options out there for python or javascript
Python Convert Html to PDF: Python Convert Html to PDF - GeeksforGeeks
PSPDFKit : How to Generate a PDF with JavaScript | PSPDFKit

Or via an api like pdfcrowd: HTML to PDF with HTTP POST - Pdfcrowd

Also, if anyone has worked with these or similar products your advice would be most welcome.

  • Actually, it works with the Upload File row removed, and with nothing for “Single file upload: File key”.

    I got it to work with the “url” option of the conversion service. Pretty cool!

8 Replies

  • I would say, however, that this is a bit of a hack, in that you have to (1) Add an HTTP Header for Content-Type = application/x-www-form-urlencoded, and (2) set the HTTP Entity to a string using application/x-www-form-urlencoded that you’re responsible for encoding yourself. In this case, it’s pretty simple since that string is just one key/value pair and there’s no special characters that need to be escaped. I think we need more direct support in the REST Post snap for this encoding. The “Upload body type” should include an option corresponding to this content type and the snap should automatically build a properly-encoded string from the input entity if it’s an object (it could just encode that object’s key/value pairs).

  • acesario's avatar
    acesario
    Contributor II

    Followup to my own question: I’m playing around with pdfcrowd, and able to get back pdf content from them on an http post. Unfortunately, the response causes and error. Can snaplogic handle this type of content somehow?

      • ptaylor's avatar
        ptaylor
        Employee

        Which snap are you using to call it and how exactly are you configuring it?

  • acesario's avatar
    acesario
    Contributor II

    Patrick,
    I was able to get a valid response - I simply changed my response entity type to Binary

    I will continue with my prototyping, but I think this is going to be a great solution!

    • ptaylor's avatar
      ptaylor
      Employee

      Thanks. I’m trying to understand a few things about your solution.

      For the Upload File, you have “HTTP entity” = $html, but I don’t see how that would evaluate to anything valid.

      • ptaylor's avatar
        ptaylor
        Employee

        Actually, it works with the Upload File row removed, and with nothing for “Single file upload: File key”.

        I got it to work with the “url” option of the conversion service. Pretty cool!