Automating HTML font embedding PHP backend - php

I understand that css3.0 supports the Font-Face tag, correctly in the latest Opera, Safari, and Firefox browsers, but that Internet Explorer still requires the microsoft .eot format.
Is there a reliable way to generate an eot file server side from a .ttf given that the hosting server may not be Windows?
I need the entire process automated, to provide a bit of background it is a print product website, part of the process involves designers building templates and uploading fonts for printable products, some of these have editable regions which are rendered to a customer as HTML form elements, however without providing the font it is impossible to provide an accurate real-time preview of the edit.
Flash and Javascript techniques wont work as the text is in a textarea or text input field and has to remain editable.
So I need a Font-Face linking to the ttf file for compatible browsers, and something else for i.e The question is, how to automate that something else for i.e.
Thanks

EOT files are a strange format. They are supposed to be locked down to a certain domain, to prevent copying, and the original conversion app is old and barely functioning.
The only way I can think of to automate TTF->EOT is to use the command line program ttf2eot found here. In PHP, you can use the function system() to run command line programs, assuming that your web host allows it.
I hope that helps you.

Related

Print a remote web page to pdf from php

I read a lot of topics about scripts that compute html and output pdf; I tried lots of them, and I am always disapointed in the results. Lots of them don't consider the external CSS, lots of them can't be executed from shared hosting (need to be installed in some unaccessible places, like DOMPDF), etc. Also, lots of the threads on the question are pretty old (most of them've been asked in 2010).
Question: Is there a simple way to cURL (from a php script) a remote web page and simply save a pdf of the "print" (like in css media print) version of the page, or even a jpeg, or a docx, or anything that "contains" the images and the styling for offline viewing? And more important, can it be free/open source?
All the web browsers do that with no effort. Once on the page, only press ctrl-p and there it goes (almost). Why is it so trivial to find a good script that can do this? Is there a way to emulate a browser, or what...?
Isn't it possible to cURL and force css media print, then take a snapshot of this?
The difficulty to find this seems very strange to me... I feel like it's a quite simple task.
Try to call wkhtmltox from PHP.
wkhtmltox/bin/wkhtmltopdf www.stackoverflow.com stackoverflow.pdf
This PHP library seems to work with wkhtmltox:
http://thejoyofcoding.org/php-wkhtmltox/
This might help:
http://davidbomba.com/php-wkhtmltox/

How to prevent user downloading font in Apache

Is there any way to not allow user to download font?
Usually if you want to download font, can find and open style file in HTML code and get source of font and enter in browser and can download it.
Any way exist to do not allow user which Could not do this? and font be safe in server?
No, it is completely impossible. That is fundamentally not how the Internet works.
If a browser can read a file from your server, so can any other piece of software.
Actually if you curtailed the use of your custom font to only some headlines and not the entire body of the page, you could convert text to SVG. The tool I'd recommend is Inkscape. Although Inkscape is a GUI tool, it has a powerful CLI which can be called programmatically.
This stackoverflow question has a full breakdown of how to do this.

Displaying word documents, excel sheet, power point in browser

Is there is any way to displaying world document,excel sheet and power point in browser with out downloading.
I assume that you are going to use php for this, so you can try checking some libraries such as PHPWord by Microsoft for example.
If you wish to only display the document content, it is possible to do using some scripting language such as php. Basically office 2007+ formats are zipped XML documents with changed extension. Make a simple word 2007+ document, save it and change extension from .docx to .zip, than you can extract it and see what it's made of. You can find a lot of details here. Now displaying content may be a little tricky. As mentioned, there are libraries out there to handle this, but how will they handle the documents, I am not really sure. Most of them are abandoned, PHPword is in beta since 2011.
There are some indications that Apache is working on cloud version of Open office, but there is no release date yet. Once done, you will have a full featured office suite web app.
If you feel really creative you could use cron job (or scheduled task if you like Windows) to open a document, take a screenshot and basically make .jpg or .png version of the document (works fine with short documents, longer ones may be problematic), displaying it in a browser without much complication. It is also possible to schedule export to .pdf - all browsers do have Adobe PDF plugins.
To sum up, using php for parsing simple documents should be fine, but getting complex docs to display properly, may be much more difficult task and possibly not worth your time. I would go for cron export to pdf, to preserve most if not all of the document's structure.

turn web page into an image on the fly?

I was wondering if there was any way of turning an entire HTML page into a png (or other kind of image?) I'm trying to create PDFs on the fly, but it's pulling across my styles as text, but I want the styles to stay the same as the page (cufon and all). Any help would be appreciated! :)
This doesn't look straightforward. The backend (PHP etc.) doesn't do rendering, layout. It merely generates content.
The layout and visual aspects of the website are done by your client (browser) and the backend has no way of accessing this.
However, given an HTML file, there are libraries that can render it into a PDF like Prince XML that seem to be capable of this.
The only way to generate an image identical, or even near, what a visitor sees in their browser when viewing your site is to launch a browser and take a screenshot. You need the browser's rendering engine to render the page. All the libraries you find to do it without a browser create something much different than what the visitor sees, and won't render cufon or other fancy things at all.
Companies that offer screenshot previews of a webpage now run many servers, each running many virtual PCs, each running a full operating system and real web browser. They have all those systems pulling jobs, opening the webpages in real browsers, taking screenshots and saving images. You won't replicate that with a little PHP script.
http://ipinfo.info/html/rendering_services.php
Turning web pages into images and PDFs is a royal pain using PHP. Solutions often require OS level scripting, fake printer drivers, or screen capturing, which can make for a rather fragile setup. I ran into the same issue a few years ago and started working on native PHP extension that leveraged the Gecko engine to render HTML to PDF, but never finished it.
The best answer I've seen doesn't quite turn a full web page into a PDF, but instead does XML to PDF. XEP by RenderX is the commercial tool Apple uses to produce developer documentation in many formats, including HTML and beautifully rendered PDFs, from an XML source. The great thing about using the XEP tool in conjunction with PHP is that PHP deals with XML very well, so you can pass generated XML to the XEP binary, let it do the conversion to PDF, then deal with the resulting PDF file in PHP.
consider building a regular PDF file that resembles your web page:
PHP::PDF - constructing using php.
PDF Reference - file structure.

Firefox jQuery Drag and Drop File Upload together with PHP

I am after a jQuery/PHP means of allowing a user to drag and drop files and then via PHP, upload one or more files to a specific directory on a Linux box.
I only have Firefox 3.6 as my base browser but can also move to FFox if need be.
Can use any HTML5 features as long as I'm using Firefox 3.6
Can someone possibly point me to any examples/sites where this process is demonstrated?
I have had a look at http://www.plupload.com/index.php but this does not work in IE6.
As mentioned, would like it to work in FFox only.
Looking for a solution that does this on IE 6 is really, really building a stall for a dead horse IMO.
It may perhaps be possible using some proprietary - and likely commercial - ActiveX or Java plug-in - I'm not sure. But why go through that, when native support is around the corner in HTML 5?
Firefox 3.6 is the one browser that at the moment provides best support for it, so I would recommend to target that for the moment, and other browsers as they catch up in functionality... Whatever you do, I would really not waste time trying to get stuff like this working in IE 6 except if there is a really, really compelling reason why that specific browser has to be supported.

Categories