Page 2 of 3

Generate PDF from client side from user input

Posted: Thu Apr 17, 2014 9:36 pm
by Illya Stepanov

Hi Ken -

About Q2 - Test you application on the device.
Add next row:
precodealert(fileSystem.root.fullPath);/code/pre
after the row:
precodeconsole.log(fileSystem.root.fullPath);/code/pre
and you will see where your just created the file.


Generate PDF from client side from user input

Posted: Mon Apr 21, 2014 3:08 am
by Ken6798251

Hello Illya,

I trust you had a great easter holiday.

The error code that I get is "LocalFileSystem not defined."

I need help defining it as I do not understand the document as listed in

http://docs.phonegap.com/en/3.0.0/cor...

Is there a tutorial as to how to do this? I've been searching but to no avail

Thanks in advance


Generate PDF from client side from user input

Posted: Tue Apr 22, 2014 12:03 am
by Illya Stepanov

Hi Ken,

Please follow recommendations that Alena gave you. For example: in Alena's code there is no LocalFileSystem object. But you getting error with this object in browser.

If after trying of these recommendation you still stuck with this issue, please share your app with us.

Alena's recommendations below:

Q1 - yes, do all you need. But you should make sure if you connect jspdf correctly.

Run your app in the browser without frame.

Open console. And type there following code:

console.log(jsPDF);

And run this code. Should return a long function. If you have error this means you have problem with including jspdf to your app.

Q2 - you should get this file in the root of the FS. Please try to find here file "test.pdf".

Q3 - to get generated pdf onto the page you should:
ol
liAdd HTML component, set dimensions for it "auto" and "auto"./li

liFill component HTML with following code:

code<iframe width="100%" height="500px" id="pdfOutContainer"></iframe>/code/li

liModify your button click event handler with following code:
precode
console&#46;log("generating pdf&#46;&#46;&#46;");
var doc = new jsPDF();
doc&#46;text(20, 20, 'HELLO!');
doc&#46;setFont("courier");
doc&#46;setFontType("normal");
doc&#46;text(20, 30, 'This is a PDF document generated using JSPDF&#46;');
doc&#46;text(20, 50, 'YES, Inside of PhoneGap!');
var pdfUriString = doc&#46;output('datauristring');
console&#46;log(pdfUriString);
var pdfOutContainer = jQuery("#pdfOutContainer");
pdfOutContainer&#46;attr("src", pdfUriString);/code/pre/li
/ol
After you clicked on the button you will get your PDF in the browser if it supports.

//Note: this code below cancels generating pdf for save it in the file. To generate file you should use your code.

Regards.


Generate PDF from client side from user input

Posted: Mon May 05, 2014 7:17 am
by Ken6798251

Hello and many thanks for all the guidance. I have managed to show the PDF in the browser as instructed above.

I have come to realize that the output on the PDF has to be positioned item by item. As such propagating a huge form with lots of inputs will be very tedious and time consuming. Is there a faster way to use Grid component to print out the information (perhaps as displayed on the screen?)

Please advice?


Generate PDF from client side from user input

Posted: Mon May 05, 2014 8:42 am
by Evgene Karachevtsev

Hello Ken,

Such code will help you to get all cells in grid:

code $("[name='mobilegrid_2'] tr td")&#46;each(function (i, cell) {

}); /code


Generate PDF from client side from user input

Posted: Wed Aug 20, 2014 9:19 pm
by R2R

I'm trying to do the same thing, so starting with #1 - I've looked in the "dist" folder and there is no jspdf.source.js file. There are two files there:

jspdf.debug.js
jspdf.min.js


Generate PDF from client side from user input

Posted: Thu Aug 21, 2014 1:00 am
by Yurii Orishchuk

Hi R2R,

You can use one of these files you like.

This is the same code. One of these is full and other one is minified.

Regards.


Generate PDF from client side from user input

Posted: Thu Aug 21, 2014 2:13 pm
by R2R

Hello, I'm following this thread to try to achieve the same action - create a PDF from an appery.io form I created and have the option to email the pdf to anyone from my device. I'm on Q1 above and have uploaded jspdf.min.js file to my app. I've run my app in a browser, and typed "console.log(jsPDF);" in the js console. The error I receive is:

Image

Image


Generate PDF from client side from user input

Posted: Thu Aug 21, 2014 10:03 pm
by obullei

Hello!

You can use one of these files you like.

This is the same code. One of these is full and other one is minified.


Generate PDF from client side from user input

Posted: Mon Aug 25, 2014 3:08 pm
by R2R

Hello, I'm struggling to make any progress to add the functionality described in this thread. I don't need to display the PDF on the screen, but I do want to send the PDF to an email as an attachment. So here are my questions:

1) For each checklist (see example image below) do I need to collect the checked/unchecked items in a database collection? For example, "Buyer_Confirm_collection"? This means, if I have 15 checklists, I would need to create 15 collections, is that correct?

2) How do I generate a PDF to include the data in a PDF? I can worry about the formatting later. So, when I click the button in the upper right corner (see image below), I want to send an email with a PDF attachment to the user that is logged in. My built-in collection already contains the email (which is also the username) in the built-in User collection.

If you're able to help me out, you don't need to describe the entire process in detail - let's go step-by-step, so what's the first thing I need to do?

Thank you!

Image