ive been reading up on QR Codes a lot recently, I want to code my own generator with PHP. But i'm having trouble, as they are rather complicated, does anyone know of any tutorials for this sort of thing?
I found this, but I get stuck when trying to convert the result from page 3 to a 11-bit binary result. I'm also confused as to why "H" ASCII value is 17 on that table, but it is 72 on the ASCII table below...
The main issue i'm having is generating it, I was thinking about using a table for the pixels. I want to eventually be able to generate my own QR Code like the one below, but different text in the middle and different content:
I would suggest that you do NOT use tables for generating QR codes. This is way too much overhead for the browser, and if a browser renderes the box model that is off by 1 pixel, your whole image will be crap.
I would take a look at generating your images on the sever in php using GD2.
http://phpqrcode.sourceforge.net/
http://www.youtube.com/watch?v=sFVcOFmnZ9Y
If you really want to generate images inside the browser, you could probably get away with a HTML canvas tag.
If you want to add text I suggest you layer the text on-top using GD2. If you are using an SVG library I'm not exactly sure how to layer, but it should be simple. Here's an example of layering in GD2:
http://phpimageworkshop.com/
The thing to realize about QR codes is that they can store up to 30% redundant data. That means that you can "destroy" 30% of the code by layering an image on-top and it will still work. Here are some guides about customizing QR codes with logos etc:
http://blog.qr4.nl/post/QR-Code-Error-Recovery.aspx
http://mashable.com/2011/04/18/qr-code-design-tips/
There are many php classes and external libraries available to generate QR code using php. I have listed some of them below. You can refer these links.
http://phpqrcode.sourceforge.net/
http://www.phpclasses.org/package/6399-PHP-Generate-QR-Code-images-using-Google-Chart-API.html
http://qrcodescript.com/
Related
I need to generate a large PDF, 2480 pages to be exact.
Currently I am using indesign, and while the output is exactly what I want.
I would rather not be involved in the document creation process.
It takes 31 minutes for indesign to execute the data merge, generate the pdf, save the pdf, and to save the pdf.indd file. (I dont really need the pdf.indd file, but I would rather not have to recreate the data merge if something were to happen to the pdf)
I am hoping for a php, or similar solution. Currently my data is stored in MySQL.
The majority of the pdf is static text, with 19 dynamically driven text fields.
There is one image on the pdf, 75x100px # 72dpi.
The output needs to be exact, the pdf file is printed and cut in half at 4.25 inches.
I have tried TCPDF, while it is fast at generating upto 50 pages, after that it would rather die than give me an output. I have also played with mPDF, and found it to be, ..., not as friendly. I have also considered generating many small files and using some utility to merge the smaller pdf's into one large pdf. Though that seems like driving around the mountain.
Any thoughts would be helpful.
You certainly can create documents directly with PHP, but it can be difficult. One method is to use one of the various PDF classes to create the document, as you have found. Another is to create images (using ImageMagic, GD, etc.) and convert those to PDF. (This method is less efficient, as you are creating raster graphics making the whole PDF page one giant graphic.)
However, I think you should consider simply scripting InDesign. InDesign has the capability to read data in via XML and create the document. This way, the design of your document isn't dependent on your programming abilities and you can still have the power of programmatically creating the document.
When it comes to huge number of pages in PDF, LaTeX is always the best answer. Nothing can really handle huge PDF generation as fast, accurate and elegant as LaTeX.
Check this question to see how to retrieve your data from the database.
I'm trying to generate 3D isometric views of players' heads, but I'm not sure what kind of support PHP has for this type of operation, or of any external libraries that may be better suited.
Basically I need to take a net like this (here is a diagram showing what each portion is mapped to) and make a 3D head from it. I also need to include the 'head accessory' portions, which should be slightly larger/offset from the actual head.
Does anyone know how I should go about this?
Well first it will be a complex job in my view.
The http://www.minecraftwiki.net/images/0/01/Skinzones.png file you mentioned is flat, but you have to convert that in ISOMETRIC 3D look, so you have to distort the images
For example look at the images below
So you can see that 3D box image is created from the pieces of other images, the logic is to add perspective to the flat images and join them. but as it is 2D we will call it Image Distortion.
Unfortunately GD Library which comes bundled with PHP is not advanced enough to let you do such things.
You have to use some other library like Image Magic and this link is tutorial for using distort functions http://www.imagemagick.org/Usage/distorts/
Second big thing is the processing of the images, you can process the images live but it will consume lots of resources on server, so it is suggested that you use pre processed images, and not process them every time.
To generate the Isometric image you have to write the code your self, and it may need alteration on each image character depending upon the size of the image. But when you have written a code it will be easy.
My Suggestion is to write your own code once, then alter it for every character and save the processed images in a sprite and use them when you add play functionality.
check out this link as well
http://www.fmwconcepts.com/imagemagick/index.php
I want to generate PDF from a PHP file that includes HTML controls like textbox, and textarea. I attached CSS in the same. I tried FPDF, DOMPDF and TCPDF, but still I don't get exactly what I want. How do I pass HTML controls with PHP variables and CSS to these libraries?
mpdf is another option that you could try.
EDIT :
Found another solution for it, TCPDF is a FLOSS PHP class for generating PDF documents. Looks more dominating library.
"PRINCEXML" is a good library (not completely free now).
Others:
If your meaning is to create a PDF file from PHP, pdflib will help you (as some other suggested).
Else, if you want to convert an HTML page in PDF via PHP, you'll find
a little trouble outta here.. For three years I have been trying to do it as best as I
can.
So, the options I know are:
HTML2PS: same of DOMPDF, but this one convert first in .ps
(Ghostscript), then, in whatever format you need (PDF, JPEG, PNG). For
me it is a little better than dompdf, but I have the same speed problem.. Oh,
it has better compatibility with CSS.
Those two are PHP classes, but if you can install some software on the
server, and access it through passthru() or system(), have a look at
these too:
wkhtmltopdf: based on webkit (safari's wrapper), is really fast and
powerful... It seem like it is the best one (atm) for converting HTML pages to PDF on the fly, taking only two seconds for a three pages XHTML document
with CSS 2. It is a recent project. Anyway, the Google Code page is often
updated.
htmldoc: this one is a tank, it really never stops orcrashes... The project
seems to have died in 2007, but anyway if you don't need CSS compatibility
this can be nice for you.
** Thumbs Up For Strae.
If I understand your needs correctly I don't think any PHP-PDF class would do that.
Mostly you could insert only text and images to a PDF file, so if you would want something that looks like an HTML element you would need to insert it as an image.
Usually just putting HTML doesn't mean all your elements would stay intact in the PDF . (Different world, after all)
http://www.fpdf.org/ is the site having a great HTML-to-PDF class which work well. I am using it, but you have to first study its functionality and then start.
I want to overlap pictures, but it is not working and I need some help.
Here's the link to the page I'd like to convert:
http://9m9.com/innovative/sample/two.html
I want to convert this page to a PDF. You can see the small image overlapping the bigger one.
This is the page where you can click on a link that will convert the page to PDF.
http://citysoftsolutions.com/eclients/virtualtour/view_property_images.php?pid=9&uid=67
As you can see the image is placed behind the big image.
I'm using this converter script: http://mpdf.bpm1.com/
When I printed it using PrimoPDF driver it came out just fine. Last image was easily laid over. So there must be a bug with the script you're using.
What do I suggest?
If you'd like to convert your pages to PDFs "on the fly" I suggest you either
contact script creator and inform them of a bug in the script
use a different script (I'd check out this question that can help you)
If you'd like to just provide PDFs of your page I suggest you install a PDF printer driver (like PrimoPDF that I'm using) and print those pages yourself and use those.
I'm not working for Nitro PDF Software company nor am I related to them in any way. So this is not me advertising their products/services.
On a sidenote
Something's telling me that what you'd actually like to do is to create a PDF flyer/promo material or something. If that's actually what you're after I suggest you do that using some software that's meant for such a job. Microsoft Office Word will do, but you'll better off using some other. If it's a one page leaflet you could use Adobe Illustrator or CorelDraw. But if it's going to be an actual multipage document use something like Word or Adobe InDesign.
Word is probably something you can easily master. So go with that one.
Can I get some sample code in PHP for converting an html table to image
form(.gif,.jpg or any format)? I am using XAMPP on Windows.
Yes, the table is coming from the database.
The best way is to convert first in a .ps, then jpg, pdf, or whatelse you need.
I can suggest you 2 links:
html2ps
wkhtmltopdf
Tested both, and both works perfectly... html2ps is little slow (~30 sec for a 3 pages pdf, dunno about jpg) but more customizable.
Give them a look
you like to have an screenshot from an html-table / html-code?
Thats not possible with php only.
You need a webbrowser or an html-renderer and a program do make an screenshot.
look at
http://www.thumbshots.org/ (onlineservice)
or
http://www.intellitamper.com/webswoon/ (python tool.)
At first glance, that's quite a tall order. Here are some pointers:
You'll probably want to get cosy with the GD library
Where is this table coming from? If it's coming from your database originally, this would be easier to work with. Otherwise...
You'll need to get the remote page (I recommend curl)
Then you'll need to extract the table data
The complexity of the second step really depends on how similar each page and table is going to be. Regex is probably going to be useful though.
Hope this helps,
Tom
As DrFuture mentions, using php only is probably not the best way to go to convert a table into an image. I modified http://www.zubrag.com/scripts/website-thumbnail-generator.php to get it to convert my html into an image (put the html on another webpage and pass that url to the script). I would suggest going with the 'screenshot' route instead of GDI and other drawing tools.