How to extract data from a PDF and store in MySQL - php

I have a PDF document that contains data that I would like to extract and store in a MySQL database. Could anyone give me some guidance or perhaps sample PHP code?

There's some basic code here for performing text extraction from a PDF. Might work for you. For commercial libraries, check out pdflib which I believe can do similar extraction.
Once you have the data, it's up to you to massage that into MySQL INSERT statements to create your database.

I often use the FPDF library to create PDF documents via a PHP script. Plenty of examples and documentation here: http://www.fpdf.org/

What do you wanna do ?
If you want to store the PDF in a MySQL database, i recommand you to store the pdf in a directory and the path to the pdf in the mysql database.
Or you can store file_get_contents($pathToThePDF) in the db but I don't think it's a good idea.
If you want to create with PHP a PDF with data from a MySQL db, i also use fpdf (like rascher) to do that and it works well + there are many example on the website.

Related

Send invoice PDF convert

I am making an app that creates an invoice.
It is created in HTML and PHP using different data from a database.
I need to create a function that converts the page into a PDF and send it to a client.
I can not store it on server as it would mean to create a few hundred everyday. I need something like "http://FreeHTMLtoPDF.com/?convert=".$strBillURL; but it's not working any more.
Many thanks if you can help me!
I prefer to generate PDF files using some library that converts HTML/CSS to PDF. One of the libraries that provides this and is very easy to use is mPDF:
https://github.com/mpdf/mpdf
I have no information regarding what type of PDFs you generate, but in my projects I tend to generate them on the fly from the data in the database and do not store them at all.
There are also other options available for converting HTML to PDF, like wkhtmltopdf, but they might require additional knowledge in set up: https://github.com/wkhtmltopdf/wkhtmltopdf

Insert at word file excel table

I need to generate Word document using PHP. I have html, save it as doc-file, but now I need to insert in this file excel table. How can I do it with html content, or I need some classes to do it?
There is an excellent PHP class for creating Excel documents. It is called php-export-data by Eli Dickinson, http://github.com/elidickinson/php-export-data.
Also you can check this stackoverflow question: Alternative for PHP_excel
However, this is some sort of advanced task, you better be prepared.

Get data from mysql and display in .epub format using php

I want to get data from mysql and display in .epub format using php, since am very new php (Codeigniter) & don't know about ePub (one of eBook format), please can some one help me to achieve this. What is the logic or the process need to follow.
Thanks in Advance.
You should output the data of the SQL database into XHTML files, and also keep record of which XHTML files you've written. With such output, you could use an EPUB creator tool manually or call it automatically. Since PHP is able to create zip files, all of this can be done within PHP. In case your question is still unsolved and you want such a PHP based EPUB creation software (or a workflow with a separate EPUB creator tool to call), just let me know, I would probably develop such a solution (licensed under GNU AGPL).

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"

PHP to Mesh 2 PDF'S Together or not?

I have an already pre-designed PDF, and I would like to fill the PDF with some database information. So I'm curious if I should save the PDF into JPG's and render them out with the data on top of the image and re-create a PDF.
Or is there a way to use the PDF already, and print data into the PDF that is already made?
I am trying to figure out the best solution to generating this type of PDF.
All thoughts would be greatly appreciated!
You can read about PHP's PDF library here: http://php.net/manual/book.pdf.php
PHP also recommends these alternatives:
http://www.fpdf.org/
http://www.tecnick.com/public/code/cp_dpage.php?aiocp_dp=tcpdf
http://php.net/manual/book.haru.php
PDF files support the use of interactive form fields, so the best method for adding information to a PDF from a database, is add form fields to your database and find a library that let's you fill out PDF forms programatically.
Rendering a PDF to an image just to write information on it and then converting it back to a PDF would mean that no text was selectable in the new PDF unless you OCR'd it, which isn't the most optimal way to do it.
After a bit more digging, I was able to use Zend PDF within the framework to update the PDF quite easily. It was my first time using the Zend Framework, and found it quite useful. I suggest anyone trying to manipulate PDF's use Zend.
Just my .02 though. I appreciate your pointers though that were given.

Categories