Month: January 2012

PHP: HTML to PDF

I’ve pretty much tried all the PDF libraries out there for saving HTML to PDF appropriately and correctly using PHP and came to a conclusion (continue reading). The one that worked the fastest and most efficiently was the HTML to PDF class on PHP Classes but eventually this EasySW remote HTML to PDF service in the HTML to PDF class stopped serving PDF files from HTML submissions as the Easy Software closed their business. I then tried several others and it seems like DomPDF is the most robust and thorough library, parsing all formatting, styling, etc. from the HTML into the PDF file. There are certain things which are not supported such as floats but overall the DomPDF library is great and very effective. Best is that you don’t have to rely on a 3rd party service shutting down, this runs inside your application. I’ll show you how to use DomPDF in PHP to generate PDF files from HTML code. 1. Download and Install 2. Code HTML to PDF 1. Download and Install Download and Install DomPDF Download DomPDF library from Google Code. Then install DomPDF with the installation instructions provided. 2. Code HTML to PDF Write your HTML to PDF code With the installation of DomPDF done, you can write a short bit of code to load HTML into the DomPDF class and render and stream/output the PDF...

Read More

Safari: Open links in new tab instead of new window

By default, Safari 5 will open links with a target _blank attribute in a new Safari window. I don’t like this as I prefer to browse in one window. Many of you might have the preference of opening links in a new instead of a new window. To do this, go to Safari > Preferences (or press Cmd + ,) and then go to the “Tabs” section and change the “Open pages in tabs instead of windows” to “Always” like...

Read More

PHP: URL inside Regex

Using special, regular expression characters in regular expressions require you to escape them in the regular expression pattern. I had an issue with dynamically getting an array of URLs from HREF attribute from links using PHP preg_match_all and then wanted to replace this array of URLs dynamically in a loop again with their Bit.ly links after using the Bit.ly API. Dynamically inserting a URL into a regular expression pattern doesn’t work but there is a way to make it work. Simply use preg_quote with a special, conditional delimiter. Here is the code: $u = "http://domain.com/path/to/file/"; $bitlink = "http://bit.ly/xYkswW"; $pattern = '/[\'"](' . preg_quote($u, '/') . ')[\'"]/si'; preg_replace($pattern, $bitlink,...

Read More

jQuery Cancel Other Ajax Requests

For some reason, you might be submitting Ajax requests to the same URL for the same purpose and returning the same results but it happens that there are multiple Ajax requests just being redundant. Possibly a user interface where a user is making multiple selections on a page, one after the other and running multiple Ajax requests at the same time, returning results in a different order than they were submitted could cause problems. The purpose of this article is to show you how you can assign an Ajax request with jQuery to a variable/object and then abort the request before the next one is submitted, keeping your Ajax clean and ensuring that the results returned was the last action submitted. First, you must create a variable/object for your Ajax request like this: var request = jQuery.ajax( type: "POST", url: "http://myurl", success: function(response) { //do things here... } ); With that done, you can easily abort this request with the abort() method like this: request.abort(); Hope this...

Read More

Pin It on Pinterest

Subscribe To Our Newsletter

Subscribe To Our Newsletter

Join our mailing list to receive the latest news and updates from our team.

You have Successfully Subscribed!