Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

Generate PDF from client side from user input

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.

Ken6798251
Posts: 0
Joined: Thu Apr 10, 2014 4:38 am

Generate PDF from client side from user input

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

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

Generate PDF from client side from user input

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.

Ken6798251
Posts: 0
Joined: Thu Apr 10, 2014 4:38 am

Generate PDF from client side from user input

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?

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Generate PDF from client side from user input

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

R2R
Posts: 0
Joined: Wed May 07, 2014 7:24 pm

Generate PDF from client side from user input

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

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Generate PDF from client side from user input

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.

R2R
Posts: 0
Joined: Wed May 07, 2014 7:24 pm

Generate PDF from client side from user input

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

obullei
Posts: 0
Joined: Thu Jun 05, 2014 12:17 am

Generate PDF from client side from user input

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.

R2R
Posts: 0
Joined: Wed May 07, 2014 7:24 pm

Generate PDF from client side from user input

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

Return to “Issues”