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.
Related
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 want a simple html page that takes:
Name - user's time and date and set them in a single paged pdf then send it to a predefined email.
I am a newbie in php can you give me a simple example please?
You need external library. Click here, this pretty much give a good explanation on how to install and how to use the library.
Here is a good example
Use PDF_set_info to set information about the PDF and PDF_show for the actual content. Then if you wish to send it by email use the mail()function, click here for more information and examples.
FPDF is a great library for creating PDF Files. It is open-source (always a plus) and good for creating simple to complex PDF layouts.
You can also check out HTML2FPDF on sourceforge.
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 want to display some pdf file on my website, but I do not want people to download the file. like scribd.com that displays the document.
anyone can help me?
If you want to make sure your user cannot download the original PDF file you will have to convert it to something else before.
Scribd converts the PDF to HTML (with one image in the background that contains all non-text objects). I am not aware of any PDF to HTML parsers, so you would have to write your own. Due to the nature of PDF files, this will unfortunately not be easy (see this question for some more details: Convert PDF to HTML in PHP?)
If you are fine with relying on some external web service, you might try this: https://cloudconvert.org/pdf-to-html
As an alternative to parsing the PDF to HTML, you could also just output it as an image. This is much easier to achieve but also not very nice in terms of user experience. If you chose this method, the easiest way would be to use ImageMagick and Ghostscript (see https://stackoverflow.com/a/467805):
<?php
$im = new imagick('file.pdf[0]');
$im->setImageFormat('jpg');
header('Content-Type: image/jpeg');
echo $im;
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 making a web site where the site needs to keep the user files. My problem: I have a list of files ( docs, pdf, img, xml, excel ). I need to show the user each file's contents when they click a file from the list. I know how to work with img, but other file types I don't. I tried with flexpaper, but it supports only pdf.
My question is : Do you know any way to display any type of file or a library that supports all (or at least more) file types?
If it is important, I use in server side php(exectly yii ). Again one thing is important, the files need to be in my server.
Google doc viewer is support ( docs, pdf, excel ) files, other files e.g. image, xml browser native support,
For instance google doc viewer
<iframe width="100%" height="400" src="https://docs.google.com/viewer?url=http%3A%2F%2Fresearch.google.com%2Farchive%2Fbigtable-osdi06.pdf&embedded=true"></iframe>
Google Doc viewer
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)
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.