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. How can I do that?
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. How can I do that?
You can retrieve data from DB by database service (http://devcenter.appery.io/documentat...)
And generate pdf from this data with any pdf library, e.g.
http://hayageek.com/generate-pdf-with...
Thanks I have no idea how to apply the hayageek script...do i make a new javascript and save it in one of the side folders?
Hi Alex,
Just click Create new / JavaScript. All the paths will be automatically added.
Do I copy and paste the whole thing into a Create new / JavaScript?
Which command or commands do I need to show a pdf that I have uploaded to the app?
//Create PDf
var doc = new jsPDF();
//Create Landscape PDF
var doc = new jsPDF('landscape');
//Saving docment using data-uri
doc.save('out.pdf')
//get the PDF buffer
doc.output()
//Set PDF properities
doc.setProperties({
title: 'PDF Title',
subject: 'This is the subject',
author: 'Ravishanker Kusuma',
keywords: 'pdf, javascript,geenerated',
creator: 'KRS'
});
//Set Font type,size & details
doc.setFont("times");
doc.setFontType("italic");
doc.setFontSize(16);
//Add text to pdf
doc.text(X,Y, 'This is courier bolditalic.'); //X,Y are the position
//Change Text color
doc.setTextColor(150);
//Adding a page
doc.addPage();
//Adding a Line
doc.setLineWidth(0.5);
doc.line(X1, Y1, X2, Y2); // horizontal line
//Draw Rectangle
doc.setDrawColor(0);
doc.setFillColor(255,0,0);
doc.rect(X1, Y1, WIDTH, HEIGHT, 'F'); //F is for Fill
doc.rect(X1, Y1, WIDTH, HEIGHT, 'D'); //D is for Draw
doc.rect(X1, Y1, WIDTH, HEIGTH, 'FD'); //FD is for Fill and Draw
//Draw Triangle
doc.setLineWidth(1);
doc.setDrawColor(255,0,0);
doc.setFillColor(0,0,255);
doc.triangle(X1, Y1, X2, Y2, X3, Y3, 'FD');//FD is for Fill and Draw
Hi Alex,
This example could match your needs: http://parall.ax/products/jspdf
Please try the following:
1) Read Database data to HTML component (you can hide it)
2) Add jspdf as custom JS to your app
3) Use the code from this example http://parall.ax/products/jspdf but replace:pre"#render_me"/preWith:pre"[name=htmlComponent]"/preWhere htmlComponent is an HTML component name.
I don't understand this answer...
Alex,
Could you please clarify what exactly is causing the difficulty for you?
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.
This is what I typed.
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_6').get(0), 15, 15, {
'width': 170,
'elementHandlers': specialElementHandlers
});