Javascript and PHP to generate "live" print preview - php

I want to be able to enter data and use Javascript onChange/onBlur/etc to render a "live" print preview; with page breaks. The ultimate goal is to have a PDF file that can be saved/emailed/etc that will be identical to the "preview". The data is to be stored in a MySQL database, I'm figuring AJAX to write it while entry.
Has anyone heard of a library (ideally free; purchase is an option) that can do this? If not, can you point me towards what can help me write something?

There are tons of PDF creation libraries for the PHP, you can easily google it.
http://www.fpdf.org/ for example

Related

Generate pdf report from sql database

I have written an app for an ipad that once used sends data to an sql server. I can access this data using a web page, currently using php but this is not fixed, and I would like to be able to then click a button on the web page and generate a pdf report from the data in the sql database.
I am not really sure where to start looking so any pointers much appreciated.
There are lot of libraries available.
http://www.fpdf.org/
https://github.com/dompdf/dompdf
Google it you can get lot more. Personally i have used fpdf.Its little bit difficult to implement but flexible.
You should retrieve de data you want to show from de database first and then create the .pdf file using a class like FPDF (http://www.fpdf.org/) or similar. *You can easily find it in google.
You wish to generate a PDF, you got some options:
http://php.net/manual/en/book.pdf.php Never used this
http://www.fpdf.org/ I used this one myself, works nice :)
And probably you'll be able to find loads more if you Google search for "PHP PDF library"

fill in PDF form using data in MySQL database

I am working on an online time card system to replace the paper time cards. What I have done is create a webpage in PHP that takes the time in and out along with job description and other values the user inputs and stores them in a MySQL database. Everything is working just fine.
What I would like to work on next is to take the information from the database for the specific user and week and have it fill in a PDF template file I have created from scanning the old paper time card and making it into a PDF form. I dont know if this is possible I have been researching it online and all I can come up with is how to generate a new PDF file. I am hoping someone here can point me to a source of information on how to do this.
Here is an example of exactly what I want to do http://try.fillpdf-service.com/
Hi congratulation for you about done the 1st step in time,
You can use very complete pdf generator php class TCPDF
It started in 2002, TCPDF is now one of the world's most active Open Source projects, used daily by millions of users and included in thousands of CMS and Web applications.
http://www.tcpdf.org/ for genarating your pdf what kind your want this class has very useful documnet and simple to use
Cheers,
Farzam
Take a look ath this
http://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/
It can be invoked as a command line tool and among the other functions let fill form fields, (on an already existing PDF you supply).
Maybe FPDF is quite old, but still good to handle for PDF generation. Just take a Template PDF (create as you like) and put the informations you want on it. You will have to place your data on the specific positions, see the tutorial section for a better understanding.
Another popular solution is to use Zend_PDF from well known Zend Framework, but I think FPDF would be a tick easier to work with if you are not very experienced.

Copying specific data from a website to excel

A friend of mine has asked me to figure out a way of getting information from a website and putting it into an excel file.
This is the website in question: http://www.manta.com/world/North+America/Canada/Newfoundland/grocery_stores--B619B/#Location
He wishes to have an excel file with a list of all the names, addresses and phone numbers of all the results of his search.
So far I'm stumped in coming up with an idea. I'm fairly new to internet programming.
I was thinking that maybe I could create a greasemonkey userscript which would search for all the required data on the page and at the click of a button open a pop-up which would have the data in CSV format which could then be copied and pasted into excel. However the phone numbers aren't on the search results page so I don't think this is possible.
My second thought was to create a webpage that would search that site and get all the required data, then provide a "Download data to Excel" option.
Are these ideas possible and how would I best go about doing them? Is there a better way?
Thanks!
This would be easier to answer if we know what languages you're familiar with.
Assuming windows this can be done using jscript or vbscript on WSH using WinHttpRequest , excel may be accessed via ActiveX. If you need a UI i would suggest HTA.

Insert data into PDF, filled in an online form, on submit action

First of all my apologies to all the people who think this question is a repeated one or they find a similar question to this.
I am working on a project in which I have an online form and some PDFs stored on the server.
Functionality
On the submit action I have to get the data from the form, fill it to the copy of PDF and finally download it.
Approach
I followed these steps to achieve this functionality:
Converted the pdfs to html with this http://www.pdfdownload.org/free-pdf-to-html.aspx online tool.
Embedded the html with form variables and regenerated the PDFs with this library / dompdf library.
Problem
The approach is a brute force one as the html generated are far away from the real ones. So lot of effort is wasted in adjusting the html.
The process is so slow and not reliable as most of the time I get memory error or some other issues.
I need to to automate this process. What I have found through searching is I should create an FDF file that contains my variable and pass it to the PDF using some library and then download it.
I am able to create the FDF file but missing any library in PHP (I found one in JAVA) that I can use to create the PDF and download it. One library that I found is pdf tool kit but that is a command line tool and I am not able to use it on the server at run time and download the PDF file.
Anybody having done this before please help.
(Sorry for this long post)
Thanks,
Madhup
Check out FPDI. It allows you to load some existing PDF, draw on it programatically, and output a new PDF. Which, if I read your question right, is what you're trying to do.
There's some example code here.

How can I convert my current page to pdf after some content dynamically added via AJAX?

I have found some libraries or web services in PHP that does the job. The problem is that the conversion is done when the page is fully loaded, I would like to convert the page to PDF after some content dynamically added via AJAX in onload event.
Thank you very much,
Omar
You could post back document.getElementsByTagName('html')[0].innerHTML to the server (possibly using AJAX) and generate a PDF from that.
When you add content with AJAX, that's only happening on the client's machine, so the server-side PHP conversion code will not work with it. You'll need to come up with a server-side method of including the dynamic content if you want to do the PDF creation on the server.
You could possibly implement an AJAX call that sent the page content/state back to serverside, after the dynamic contens is added, where it could be rendered as a pdf. You might not need all the page, depending on where this "dynamic content" is going to go.
Seems a bit messy, but without knowing the project it's hard to say whether there could be a cleaner method to do what you're trying to do.
This is a client-side requirement due to the Ajax situation. If they're using a Mac they can simply save as PDF but otherwise you have little control over what they can do.
What you can do however for a server-side implementation is keep a record of the page and all their AJAX requests since loading that page, and construct the HTML and PDF on the server from that record if it is requested. Of course this is not a simple task and quite overkill. You'd probably be better off having a different mechanism to create a server-side PDF report of a page other than turning HTML into PDF.
If your page can be updated solely on the client with no trip to the server, you'll have to post back up to your app. That way you'll have all the content and will not have rebuild, which would not be possible if there are client side only interactions.
Wow, thank you everyone I didn't know that this is comunity is so active. To answer Beepcake about the project:
When the page loads the app retrieves, from more than 40 servers, biological information via AJAX request, then a unique view is displayed where you can manipulate the graphic with many options.
So, the cool thing will be to print when the user makes his own version of the graphic. I think that the best solution is to POST the entire HTML with document.getElementsByTagName('html')[0].innerHTML as RoBorg has said and then generate the PDF with a library such as dompdf

Categories