Export pdf and send to the server instead of the client?

8 posts, 0 answers
  1. Jason
    Jason avatar
    12 posts
    Member since:
    Oct 2014

    Posted 26 Oct 2015 Link to this post

    I need to capture a multi page form in pdf format and then save it to the server with the record and not to the client. This is the code I wrote that send it to the client, how can I modify it to send it to the server instead

     

    root.options.set("pdf", {
    multiPage: 'true'
    });
    $('#formContainer .appPage').each(function (section) {
    kendo.drawing.drawDOM(this).then(function (group) {
    group.options.set("pdf", {
    margin: {
    left: "1cm",
    right: "1cm",
    top: "1cm",
    bottom: "1cm"
    }
    });
    root.append(group);
    });
    });

    kendo.drawing.pdf.saveAs(root, "App.pdf");

  2. Alexander Popov
    Admin
    Alexander Popov avatar
    1427 posts

    Posted 29 Oct 2015 Link to this post

    Hello Jason,

    Saving the files on the server is not supported out of the box, since Kendo UI is a client-side library. You can achieve the desired results by posting the dataURI to the server via Ajax request, then storing it there, either as a file or as a dataURI string.

    Regards,
    Alexander Popov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  3. Wyatt
    Wyatt avatar
    22 posts
    Member since:
    Aug 2012

    Posted 04 Feb 2016 in reply to Alexander Popov Link to this post

    Hi,

     

    do you have a rough example of this method?

     

    Thanks

  4. Wyatt
    Wyatt avatar
    22 posts
    Member since:
    Aug 2012

    Posted 04 Feb 2016 in reply to Wyatt Link to this post

    posting went well.

     

                $.ajax({
                    type: "POST",
                    url: "/home/pdfpost",
                    processData: false,  // tell jQuery not to process the data
                    contentType: false,  // tell jQuery not to set contentType
                    data: '{ "imageData" : "' + data + '" }',
                    contentType: 'application/json; charset=utf-8',
                    dataType: 'json',
                });

     

     

    the problem is creating the pdf file from the datauri in the controller.  any clues how to do that?

  5. Alexander Popov
    Admin
    Alexander Popov avatar
    1427 posts

    Posted 08 Feb 2016 Link to this post

    Hello,

    As mentioned previously, creating a PDF file on the server is not supported as Kendo UI is a client-side library. You could however, use third-party libraries that do that. Here is an example that you might find helpful:
    Regards,
    Alexander Popov
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
  6. Wyatt
    Wyatt avatar
    22 posts
    Member since:
    Aug 2012

    Posted 11 Feb 2016 Link to this post

     

     found a way to do it..

    kendo.drawing.drawDOM($(".pdf-content"))
          .then(function (group) {
              // Render the result as a PDF file
              return kendo.drawing.exportPDF(group, {
                  paperSize: "auto",
                  margin: { left: "1cm", top: "1cm", right: "1cm", bottom: "1cm" }
              });
          })
          .done(function (data) {
     
              $.ajax({
                  type: "POST",
                  url: publish + "/home/pdfpost",
                  processData: false// tell jQuery not to process the data
                  contentType: false// tell jQuery not to set contentType
                  data: '{ "imageData" : "' + data + '" ,"id": "' + self.customerGuid() + '"}',
                  contentType: 'application/json; charset=utf-8',
                  dataType: 'json',
              });
     
              
          });

     

    // controller (MVC) 

    imageData = imageData.Replace("data:application/pdf;base64,", "");
    byte[] bytes = Convert.FromBase64String(imageData);
     
    Stream stream = new MemoryStream(bytes);
     
    EmailMessage email = new EmailMessage(service);
     
    email.Attachments.AddFileAttachment("SALOR.pdf",stream);
  7. Ashish
    Ashish avatar
    5 posts
    Member since:
    Dec 2016

    Posted 20 Dec 2016 Link to this post

    Hello sir,
    i have problem save pdf server side but in local easy save pdf plz help me save pdf server side 
     {

      
                        done(function (dataURI) {
                            kendo.saveAs({
                                dataURI: dataURI,     
                                fileName: "test.pdf",
                               proxyURL: "/path/to/proxy",
                               forceProxy: true
                            });
                        });
     
    This function is used server side save pdf but it is can't working plz help me save the pdf server side plz send me with example
  8. Alexander Popov
    Admin
    Alexander Popov avatar
    1427 posts

    Posted 20 Dec 2016 Link to this post

    Hi Ashish,

    I am not sure I understand your question very well. Saving PDF files on the server is not supported, as Kendo UI is a client-side library and as such it does not have server-side part and filesystem handling capabilities.

    Regards,
    Alexander Popov
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top