Cloud Code function to produce & return PDF file

5 posts, 1 answers
  1. ptw
    ptw avatar
    27 posts
    Member since:
    Sep 2015

    Posted 08 Oct Link to this post

    I'm trying to set up a cloud code function to produce and return a PDF file.

    Ideally, the scenario is this:
    - User requests a PDF file (function call made to cloud code function)
    - cloud code returns PDF file to the user's browser.

    I realise it's possible to create a PDF client-side. The reason for using cloud code is to avoid sending a lot of data (or perhaps confidential data) to the client-side code. And to avoid filling the client-side interface with elements of a multi-page PDF.

    What is needed to get the basic documentation example here to work as a cloud function?

    Thanks

  2. Martin
    Admin
    Martin avatar
    67 posts

    Posted 11 Oct Link to this post

    Hi,

    The creation of PDF file using Kendo UI Drawing API requires to load the library kendo.all.min.js. Still in cloud function the loading of external libraries for the moment is limited to Underscore and RSVP.

    Therefore you cannot create a cloud function which uses Kendo UI Drawing API to create a PDF file.

    Still you may use an external web service provider that creates a PDF file and combine it with a cloud function. A sample process would be the following:

    1. The app sends a request to the cloud function for creating a PDF file (it may hold variables or not that will be filled in the PDF)
    2. The Cloud function gets the content from Telerik Platform database using the JavaScript SDK or makes an HTTP request to external resource.
    3. The Cloud function sends an HTTP request to external web service that will create the PDF file.
    4. A response from the external web service is returned, you attach the response to the cloud function response and return it to the app.

    Still note that there is a possibility to reach one of the cloud function limitations, mainly the maximum execution time of 10 seconds, as you are calling an external web service and waiting for their response.

    Here is a list of some PDF generation APIs - you can search for others as well.

    Let me know if this has helped.

    Regards,
    Martin
    Telerik by Progress
     
    Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
     
  3. ptw
    ptw avatar
    27 posts
    Member since:
    Sep 2015

    Posted 12 Oct Link to this post

    Many thanks for that Martin; very helpful and practical advice.

    I was hoping that, in the absence of a Backend services option, we might be able to somehow use another Telerik service - I like what the company is doing and where it seems to be going. It would be overkill for a few PDF reports right now, but rather than going to a 3rd party, it might eventually be worthwhile for us to look at having a server that runs Telerik Reporting or a Telerik Reporting Server. Two further questions:

    1) I'm guessing that integration between Telerik Platform and these other Telerik offerings would be just as easy (or perhaps easier) than a 3rd party option - is this correct?

    2) Are there any other Telerik add-ons or services that might fill this gap? (ideally a smaller and easier step than getting another/new server for .NET) 

    Regards

    -Paul

  4. Answer
    Martin
    Admin
    Martin avatar
    67 posts

    Posted 14 Oct Link to this post

    Hi,

    Thank you for your feedback.

    Indeed you can use Telerik Reporting or/and Telerik Document Processing Libraries where documents are processed and rendered on the server machine. Both products are included in DevCraft bundles.
    Telerik Report Server is a web application based on Telerik Reporting libraries, including many ready to use features - product page. The product is distributed separately.

    Please feel free to download trials and check the mentioned products. Articles you may find interesting:
    In Telerik Platform though there are no other add-ons or services that can fit in your case from the one already mentioned. I have taken you point on better integration between Telerik Platform products and would forward it to our development team. Indeed your use case seems interesting and we would be happy if you send us a feature request here.

    Regards,
    Martin
    Telerik by Progress
     
    Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
     
  5. ptw
    ptw avatar
    27 posts
    Member since:
    Sep 2015

    Posted 18 Oct in reply to Martin Link to this post

    Many thanks Martin.

    I've followed up on your suggestion and posted on the Ideas & Feedback portal re a potential "New Telerik Cloud PDF service" 

    [Link to Ideas & Feedback Portal post]

Back to Top