This is a migrated thread and some comments may be shown as answers.

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

10 Answers 2198 Views
Drawing API
This is a migrated thread and some comments may be shown as answers.
Jason
Top achievements
Rank 1
Jason asked on 26 Oct 2015, 08:54 PM

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");

10 Answers, 1 is accepted

Sort by
0
Alexander Popov
Telerik team
answered on 29 Oct 2015, 08:46 AM
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!
 
0
Wyatt
Top achievements
Rank 1
answered on 04 Feb 2016, 06:30 PM

Hi,

 

do you have a rough example of this method?

 

Thanks

0
Wyatt
Top achievements
Rank 1
answered on 04 Feb 2016, 08:41 PM

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?

0
Alexander Popov
Telerik team
answered on 08 Feb 2016, 11:48 AM
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!
 
1
Wyatt
Top achievements
Rank 1
answered on 11 Feb 2016, 02:12 PM

 

 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);
0
Ashish
Top achievements
Rank 1
answered on 20 Dec 2016, 09:25 AM
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
0
Alexander Popov
Telerik team
answered on 20 Dec 2016, 12:42 PM
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.
0
David
Top achievements
Rank 1
answered on 27 Oct 2017, 09:02 PM
Wyatt could you show me what your parameters are for your controller or are you getting it out of the body of the request? I am sending it up as form data and getting the file stream but then cannot open the file after I put it on the server.
0
Dimitar
Telerik team
answered on 31 Oct 2017, 03:27 PM
Hello,

As noted by my colleague, saving PDF files on the server is not supported by Kendo UI, as it is a client-side library. Thus, it does not provide filesystem handling. It would be beneficial for the community, if Wyatt could share their solution.

Apart from Kendo UI, Telerik UI for ASP.NET MVC provides integration with Telerik Document Processing Library, which is capable of server-side operations. The following demos show PdfProcessing in action. And PdfProcessing documentation can be found here.

Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Charanpreet
Top achievements
Rank 1
Veteran
answered on 17 Apr 2021, 03:33 AM

Mission accomplished: Generate pdf and send to the server instead of the client.

Using Asp.net core webapi

1. Create a html page in wwwroot folder.

2. Load kendogrid using jQuery.

3. Next, from any controller or c# class , call this url and convert html page as string and pdf using some url to pdf library.

4. Save file to folder 

5. Using C# Mail class, send it as attachment.

 

 

Tags
Drawing API
Asked by
Jason
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
Wyatt
Top achievements
Rank 1
Ashish
Top achievements
Rank 1
David
Top achievements
Rank 1
Dimitar
Telerik team
Charanpreet
Top achievements
Rank 1
Veteran
Share this question
or