Alex Van Name
Posts: 0
Joined: Mon Jun 30, 2014 7:36 pm

Creating PDF documents using DATABASE

the other problem is the zip file for the javascript makes many folders and i dont know which ones to use to make the javascript

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

Creating PDF documents using DATABASE

Hello Alex,

Could you please clarify one question. First you wrote
[quote:]I would like to use Database data that a user has entered to then spin the information back to the user in a new format as a PDF file or other downloadable file that can be printed.[/quote]
And after that
[quote:]I want to have my app with some pre-loaded pdf files. I want the user to be able to click on a page and have that page show a pdf to the user.[/quote]
Would you kindly let me know what do you want to get?

Alex Van Name
Posts: 0
Joined: Mon Jun 30, 2014 7:36 pm

Creating PDF documents using DATABASE

I did want to accomplish both tasks.

The most recent question was my latest concern, since i am still trying to figure out how to use the database in another help question.

I thought it would be easier to display pdfs pre made....but ideally i would like to do both.

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

Creating PDF documents using DATABASE

Hello Alex,

Could you please look at these links, they should be useful:
https://getsatisfaction.com/apperyio/...
https://getsatisfaction.com/apperyio/...
https://getsatisfaction.com/apperyio/...
By the way there are a lot of topics on this forum, where opening of pdf files was discussed, you may search for answer there: https://getsatisfaction.com/apperyio/...
If you'll have some specific question, please do not hesitate to ask

Alex Van Name
Posts: 0
Joined: Mon Jun 30, 2014 7:36 pm

Creating PDF documents using DATABASE

Thank you, I will read these.

Alex Van Name
Posts: 0
Joined: Mon Jun 30, 2014 7:36 pm

Creating PDF documents using DATABASE

After reading all these entries, I am still lost.

I know this is my problem, but I appreciate all help.

I tried something simple.

I imported all the jsPDF scripts and I made a page with a button to run the following script:
==================================================
var doc = new jsPDF();

// We'll make our own renderer to skip this editor
var specialElementHandlers = {
'#editor': function(element, renderer){
return true;
}
};

// All units are in the set measurement for the document
// This can be changed to "pt" (points), "mm" (Default), "cm", "in"
doc.fromHTML($(name='HTML_thing).get(0), 15, 15, {
'width': 170,
'elementHandlers': specialElementHandlers
});
===================================================
I get the following errors from the browser developer window

ReferenceError: require is not defined loginScreen.js:2813
GET http://debug.appery.io/ws/target/t-11... [HTTP/1.1 200 OK 5349ms]
GET http://debug.appery.io/ws/target/t-11...

Request URL: http://debug.appery.io/ws/target/t-11...
Request Method: GET
Status Code:
Request Headers 16:51:34.000
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:30.0) Gecko/20100101 Firefox/30.0
Referer: http://appery.io/app/view/5f5520b4-24...
Origin: http://appery.io
Host: debug.appery.io
DNT: 1
Content-Type: text/plain
Connection: keep-alive
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8

=======================================================

This part "GET http://debug.appery.io/ws/target/t-11..." keeps repeating. What is wrong?

Alex Van Name
Posts: 0
Joined: Mon Jun 30, 2014 7:36 pm

Creating PDF documents using DATABASE

I can't get the simple example to work...

:(
//So simple
var doc = new jsPDF();
doc.setFontSize(22);
doc.text(20, 20, 'My First PDF');
doc.addPage();
doc.setFontSize(16);
doc.text(20, 30, 'This is some normal sized text underneath.');

Alex Van Name
Posts: 0
Joined: Mon Jun 30, 2014 7:36 pm

Creating PDF documents using DATABASE

ok folks, I was able to print a "label" using the javascript

I realized that I had to fix several errors in the code, but thanks to the javascript editor, i just added a lot of semicolons(;) and did some minor tweaks to make the code work

I also learned that you do NOT need to have your js filename ending with *.js, that really screws up the app.

The only thing left is to figure out how the user can save this final print out as a pdf and as a single, but long database item for future printing.

I opened the pdf I generated on my phone, but I get a message at the bottom of the screen that says

"data:application/pdf;base64,JVBERiOx..."

I can also just view the pdf on an ipad, I cannot save or print it from the ipad. I would like to be able to save the pdf that is generated.

I am ok with this. I would like to give the user options to email this pdf to someone.

Are these things difficult to do?

Alex

PS Thank you for your help.

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

Creating PDF documents using DATABASE

Hi Alex,

You can use following code to store document to the file:

pre

var doc = new jsPDF();
doc.text(20, 20, 'Hello world.');
doc.save('Test.pdf');

/pre

Also jspdf has "output" method which has "type" parameter to coтfigure output string to the needed format.

See details about it here:

http://mrrio.github.io/jsPDF/doc/symb...

Regards.

Alex Van Name
Posts: 0
Joined: Mon Jun 30, 2014 7:36 pm

Creating PDF documents using DATABASE

thanks Yurii,

I will experiment with this feature.

Return to “Issues”