1

i want to convert my result HTML page to PDF in phone gap app and then want to share it with phone's native share window.anybody who already did this or have any idea, it would be great help as i stuck here from couple of weeks.

kendo.drawing.drawDOM($(".pdf-page"))
        .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) {
        // Save the PDF file
        kendo.saveAs({
            dataURI: data,
            fileName: "manual.pdf",
           // proxyURL: "//demos.telerik.com/kendo-ui/service/export",
            callback:alert("done 1")
        });
    });

its is working fine on PC but not working in android mobile app on which currently i am testing. if this works in mobile then can i use

window.plugins.socialsharing.share('Here is your PDF file', 'Your PDF', 'www/files/manual.pdf')

to share that pdf file

McVenco
  • 1,011
  • 1
  • 17
  • 30
Barry
  • 31
  • 1
  • 10
  • Is it useful http://stackoverflow.com/questions/20942623/which-can-replace-capturepicture-function/20963109#20963109 ? – lifeisfoo Aug 27 '15 at 18:49
  • i am working with html/java script app but still appreciate for your concern – Barry Aug 27 '15 at 20:39

2 Answers2

1

For Phonegap/Cordova apps:

You can use jsPDF library to create dpf file and Cordova file plugin to save pdf file locally and simply share it with using any Cordova share plugin.

Hope this link helps you saving pdf.

Community
  • 1
  • 1
user5091906
  • 166
  • 10
0

This is what we did:

<script>

    $(function () {
        $("#button0PDF").kendoButton();
        var button = $("#button0PDF").data("kendoButton");

        button.bind("click", function (e) {
            kendo.drawing.drawDOM("#divId", {
                forcePageBreak: ".page-break",
                //template: $("#page-template").html()

            })
            .then(function (group) {
                // Render the result as a PDF file
                return kendo.drawing.exportPDF(group, {
                    landscape: false
                });
            })
            .done(function (data) {
                // Save the PDF file
                kendo.saveAs({
                    dataURI: data,
                    fileName: "fileName.pdf",
                    proxyURL: "/API/Main/Post",
                });
            });
        });
    });

</script>

And the server side part:

public HttpResponseMessage Post([FromBody]FileData file)
        {
            var data = Convert.FromBase64String(file.Base64);

            var result = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StreamContent(new MemoryStream(data))
            };

            result.Content.Headers.ContentType = new MediaTypeHeaderValue(file.ContentType);

            result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
            {
                FileName = file.FileName
            };

            return result;
        }
Erick Lanford Xenes
  • 1,467
  • 2
  • 20
  • 34