Print pdf with web application [closed] - php

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I've seen a couple of topics about this problem - The ability to print through a browser.
Unfortunately the only working solution for me was printing with an iframe.
the problem with iframe is that the browser actually hangs quite a bit when the page loads which is a good annoyance.
Is there any other way I can print a file? Should I display it as a html and print it or keep it pdf and use pdfjs to get it in canvas and print?
All of these though don't allow me to set print options, because I'm trying to send it to a label printer it requires specific dimensions.
Thanks in advance,
Sincerely,

The way I solved this is by installing wkhtmltopdf on my server. Since I use a dynamic page with Javascript to add content I send the whole html page to my php wich stores the html file in a temporary folder on my server and then I use wkhtmltopdf to create the pdf. Once thats done my ajax request opens op that new pdf file. and done you can print that pdf.
Its the best solution I found to print out with pdf files, the problem with other things is that you can't get rid of that extra clutter on the top and footer of the webpages.
Greetings
Ezeky

In the case of an HTML page :
as described here, you can specify css rules for the media type print in your css file. This will be applied when requesting for a print in your browser.

Related

How to save data from phpmyadmin database to pdf? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have a database on phpmyadmin. Then I have a website with some products. When user clicks on a specific product, he gets some details about that product. Those details are pulled from the database.
My question is: Is it possible to create a pdf file with the specific details about that product, so the user can download it?
So, the options i know are:
DOMPDF : php class that wrap the html and build the pdf. Works good, customizable, based on pdflib, if i remember right it takes even some CSS. Bad news: slow when the html is big or many complex.
this is a tutorial to follow :http://www.sitepoint.com/convert-html-to-pdf-with-dompdf/
HTML2PS: same of DOMPDF, but this one convert first in .ps (ghostscript), then, in whatever format you need (pdf, jpg, png). For me is little better then dompdf, but have the same speed problem.. oh, better compatibility with css.
Those two are php classes, but if you can install some software on the server, and access it throught passthru() or system(), give a look to these too:
wkhtmltopdf: based on webkit (safari's wrapper), is really fast and powerfull.. seem like is the best one (atm) for convert on the fly html pages to pdf, taking only 2 seconds for a 3 pages xHTML document with CSS2. Is a recent project, anyway, the google.code page is often updated.

retrieve a web page without images [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I am writing a web scraper for a specific site using PHP.
I use file_get_contents function to retrieve web pages.
some pages have images and images are also retrieved with the page.
In my case I don't want images to be there. (I want text only)
my question is, is it possible to retrieve pages without images? if so how?
additional info: I have checked the source of the page. there base tag is defined inside head tag and pointing to the same url.
Edit: I just notice images are base64 encoded.
It is not possible to "retrieve" the page with the images not included. You would need to parse/scrub the contents after retrieving it.
Inline with a previous comment, one method (of several) is this way if you simply need the image tags removed:
$data=file_get_contents();
preg_replace("/<img[^>]+>/i", "(image) ", $content);
echo $content;

Print Automatic PDF from folder [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I wanted to print pdf which i generate from FPDF in PHP automatically from server's folder.
Is there any way to automatically print PDF from a printer connected to the server from a specified folder?
Or to print the pdf generated in a device accessing that server, from that server's default printer.
We do this, albeit in a slightly hacky way. Here are the steps:
Generate the PDF with FPDF and save it to a location on disk
On the page that has loaded (or from another page) we have an iframe. With JavaScript we set the frame's location to that of the PDF
Again use JavaScript to print the iframe.
Note: our method has us confirm the print dialogue button before it prints. This is possibly something you can set with your printer settings.
If you want to just print without that hassle, there are ways to directly connect to your printer from PHP, but the only one I know of is via a PECL extension, and I think that's Windows only.
Use the fpdf print plugin to print the pdf,Please check this link here each time you open this pdf, it will open the print popup.

How to download a full HTML page as pdf using DOMPDF? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I used dompdf to download a receipt that is initially in HTML format. But as soon as it gets converted, the orientation and the format gets distorted. Is there way to download an HTML page as pdf with the same height and width as the HTML page?
No there is not. Every html->pdf tool are different. some doesnt allow css some allow html5 but very bad. some allow gif etc. lots of variations. You shouldnt look for a tool that render the html page and convert to pdf. You should find something like view the page and get its screenshots of it and print as pdf. because today's complex html pages are just too overwhelming for html->pdf tools. Those tools are made for html coders to create fancy pdfs.
Try to search browser plug-ins. If you find one you can automatize the process via linux konsole. (fire-fox, maybe chrome too not sure though)

Separate php logic from html document and maintain functionality [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'm having a bit of trouble wrapping my head around this problem.
I have an image map that I can click which sends various GET requests to my PHP script. My PHP script receives these GET requests and search through my MySQL Database to retrieve the appropriate information. My client is re-directed to this PHP page.
This all works and is great, but I need to incorporate Jquery for other functionality. So, I can't use a standalone PHP script.
My solution to this is use my imagemap to open up a HTML file instead, and use an include statement to incorporate my current PHP file.
However, I don't know how to include the PHP file if I need the GET requests created by clicking the image map.
How can I click on my image map, and be re-routed to a HTML page that displays the same information available from the GET requests in my PHP? I want to do this without creating multiple html files for such a small difference of one variable.
should try to use ajax-javascript to combine the php request with the javascript request and then redirect using the combined info.

Categories