Display Document (PDF) Like SCRIBD.COM [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 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;

Related

Image Upload to PDF on Webpage [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 6 years ago.
Improve this question
im new in Webdevelopment and I wanted to ask you ("THE EXPERTS") if you could guide me or give some hints how to do following Webpage:
I want to upload 3-5 Images, place them automatically horizontally on a PDF and let the user download the PDF. I don't want to store the images so after you reload the page the images should be gone.
Could you help me how to realize such webpage? Or atleast which way I should use? Jscript, html5, php etc...
Best regards
Machete
You are looking for a pdf-libary like FPDF.
Especially take a look at the Image() function (Documentation).
quick and dirty, create a php script that executes something like this on the shell:
convert image1.png image2.png image3.png output.pdf
you need to have imagemagick installed.
There are more elegant ways to do that.

Software testing a pdf is created correctly [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 written a REST application in laravel. It accepts a Json payload and creates a formatted pdf using this data.
Is it possible to write a test that checks the pdf has been generated correctly?
Edit:
Ideally I'd like to know the pdf is not corrupted, ie. Will open in a pdf reader.
Also it would be good to somehow check the content of the pdf. For example... does it contain the customers name?
Thanks.
Yes this is possible, given that the same JSON input always generates the same PDF.
You wouldn't really check the PDF file. PDF is a complex format, based on PostScript and some dark magic.
What you can do is generate a “sample” PDF once, then write a unit test that uses the same input data to generate a PDF file, then compare this to your sample.
This would look something like (just some example code):
$myPdf = $pdfGenerator->generatePdf();
$samplePdf = file_get_contents('/some/example/file.pdf');
// with PHPunit
$this->assertEquals(0, strcmp($myPdf, $samplePdf));
That's a bit dirty, but it does the job … if something in your PDF or JSON implementation changes, the unit test will make you aware of it.
It is important, however, that your PDF generator does not insert any “dynamic” data, such as date stamps. In that case, the PDF files could obviously never be identical.

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)

PDF generation from html pages [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
To generate pdf file from html page I have used libraries like MPDF , FPDF, DOMPDF etc.
In each pdf library I found following issues.
mpdf causes unnecessary page breaks
FPDF needs more writting. etc
When I used DOMPDF it worked fine but large table didn't expanded to next page and pdf broke without generating next pages.
Then I searched for another pdf library and I came to know about TCPDF.
SO I want to know what are the disadvantages of "TCPDF"?
A great alternative for PDF generation is wkhtmltopdf. It has a smooth integration and the result is awesome. You will have to install the binary into your server, though. If you're on a VPS or dedicated, this will not be a problem.
There's a PHP lib for using it, you can find it here: https://github.com/KnpLabs/snappy
Also, there's a nice solution for the large table problem you have. Maybe it can help you with another lib too, take a look here: https://code.google.com/p/wkhtmltopdf/issues/detail?id=566

reducing the size of generated pdf using FPDF [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 generating a pdf for every page using FPDF. Its working properly. But the main problem is with the file size. Some files have a size of more than 2Mb. I want to limit the size. How can I limit the size within 300 kb? Any help would be appreciated.
Typically PDFs are large because they contain large images or because they contain large fonts.
So the solution is typically to reduce the resolution of the images and to avoid the fonts getting embedded.
If FPDF will allow you to do this then this will likely solve your problem.
If not then you will need to post-process your PDF using another library to unembed the fonts and resample the images.
ABCpdf will do this using the ReduceSize operation. No doubt other libraries will allow something similar.
I work on the ABCpdf .NET software component so my replies may feature concepts based around ABCpdf. It's just what I know. :-)
The best way is to compress pdf file is that first you generate the pdf and then use any tool to compress the pdf file. As far as my experience is concerned, there is no other way to compress pdf file.

Categories