How to generate texts as image in PDF - php

I am using dompdf to generate a PDF file. The PDF simply contains texts. I need the content of the PDF to show as an image instead of texts. I do not know where to start. Cannot find anything using Google. Any suggestions?
More info:
In the PDF I currently generated, I can select specific portion of texts by highlighting it using the mouse. In the PDF I should generate, I should not be able to select portion of texts because the texts is already an image. So the PDF I should generate contains an image, and the image contains the texts.

You could generate a png first using phpgd / ImageMagick then shove it through dompdf

Related

Get OMR code into a pdf file using PHP

We have a enveloping machine that is able to read optical character recognition codes (OMR). See: http://en.wikipedia.org/wiki/Optical_character_recognition
For that we want enrich our PDF output with such an OMR code. We use FPDF in PHP to generate our documents.
Is there a way to greate these codes maybe as a picture?
Thanks a lot!
Perhaps you could insert images into your PDF that your OMR enveloping machine could read.
If so, I can recommend this FPDF Script which writes out standard HTML which can include images into the PDF being created:
http://fpdf.org/en/script/script42.php
$pdf->WriteHTML("<img src="http://www.example.com/OMR_readable_image.gif">");
If you need to dynamically create images with page numbers, I can see a solution where you combine a circle background image with the page number text to create an image that you then use as your image source.
How to create an image dynamically:
http://www.php.net/manual/en/image.examples-png.php

saving a PNG image as vector PDF in php

Ive a script to generate an image using imagemagick in PHP, after designing i need to create a pdf to print and this pdf need to be like a vector one, even if we zoom in the content should be crisp, but my pdf is not so, can some one guide me how to achieve this?
Do i need to convert my final png as svg? or is it possible to make pdf with PNG as vector?

PHP Text Extract from Scanned PDF

I need help in Text Extract from Scanned PDF
Is it possible to extract or read the text from a scanned image or an pdf using PHP. If so how it can be done... I am able to read the text from a normal pdf but when it comes to scanned pdf,code is not working.

Can I make html table into image to embed into pdf

I have been reading about this but I have to do some thing. I have a table with diagonal text in the heading columns and horizontal text in the rows. I was able to make text diagonal using CSS rotation thing, table data is coming from db and I want to generate the same html into the pdf. I don't know who to write diagonal text in the pdf. The solution is to create an image of the visible html table with data and then store it and then make pdf and embed that image there. I have been reading the GD library but how can I make table in GD library I am stuck , Stack Overflow is the last resort. Please help.
try this ezpdf class http://www.ros.co.nz/pdf/readme.pdf. they got some sample code to rotate text and how to embed image into pdf.
example
for ($angle=0;$angle<360;$angle=$angle+20){
$r=rand(0,100)/100;
$g=rand(0,100)/100;
$b=rand(0,100)/100;
$pdf->setColor($r,$g,$b);
$pdf->addText(300+cos(deg2rad($angle))*40,300-
sin(deg2rad($angle))*40,20,$demotext,$angle);
{
$pdf->stream();
If you want to go directly from your HTML code to PDF, and if you need something entirely in PHP you can try dompdf. The 0.6.0 release will include CSS transform support.
For image generation in PHP you can use GD functions (fast) or iMagick (not so wide spread, docs are WorkInProgress, but you could do almost anything you can imagine with it).
GD should be enough.
A simple idea about making text diagonal would be to just rotate the image, once you output text from the db onto it.
Use wkhtmltoimage or wkhtmltopdf.
Do you need to do this only once or does this need to be an ondemand service? If not why not just load the html page take a screenshot and crop it down to the table?
Instead of trying to convert HTML directly to a PDF document, you might want to try a PDF library for creating the document directly in PHP. This way you will get more control over what the PDF looks like, and it may be a better solution that trying to convert your HTML output.
https://stackoverflow.com/questions/560583/which-is-the-best-pdf-library-for-php

How to convert specific no. of pages from a .pdf file to .png image using imagemagick

i am using Imagemagick for converting my .pdf file to .png images
but when i issue the command
$convert sample.pdf image.png
then it will convert all the pages of sample.pdf file to .png images but exactly i want to
convert a specific no. of pages(e.g. first 10 pages or page no.22 or 12 etc.)
then pleases suggest me a way to solve this issue.
and one more question is that:
when we view our .pdf files in google docs .pdf viewer then they are also in image format
but we can select and copy the text written on pages to the clipboard(simply select the text and press
Ctrl+c)
so how can i implement this so the users of my website can select the text form my images.
(there are already some discussion about it on stackoverflow but they are not very clear)
for i in {0..9} 11 21
do
convert "sample.pdf[$i]" "image_$i".png
done
Benoits answer is what you were looking for for slicing and converting a PDF in to images.
Alternatively you can use pdftk with the cat operation. This would get you the first 10 pages and generate a new sliced PDF for example.
pdftk YOUR.PDF cat 1-10 output SLICED.PDF
Regarding your second question about converting an image PDF to a PDF with text data the only way is to use a OCR tool like Tesseract for example.
The only problem is that those OCR tools are not always that exact. In other words sometimes they will not always be able to output what you read on that image.

Categories