| text2PNG.com | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Get the Code (hosted):
Need to integrate text2PNG Hosted Solution with your web application? Try our Fonts API for easier fonts selection.
Fonts API
Browser Support:Currently we support all browsers that can display PNG transparency with the following limitation:
Including the Script:You can include the text2PNG script by adding the script tags to the head section (between the <head> and </head> tags). If your website uses secure connection, replace the http to https
<script type="text/javascript" language="javascript" src="http://www.text2png.com/text_script.js"></script>
<script type="text/javascript" language="javascript">
text2png.onLoad = function(){
// on of the replace functions below
};
</script>
Replace http with https for secure pages.
After you've added the script tags to your page, use on of the following replacement functions to replace your text to PNG images. Each of these functions take any number of variables and the PNG options (optional). - Examples
The full script (unpacked) can be found at http://www.text2png.com/text_script_full.js
text2png.replace()This function will take either the elements or the elements' id value. Each element html value (innerHTML) will be replaced by the PNG image. Note that this function will strip all the HTML tags and remove the child elements. Use this function to replace a specific elements only.Example: (Hello World Example)
Script:
text2png.onLoad = function(){
text2png.replace('header'); // or text2png.replace(document.getElementById('header'));
};
HTML:
<div id="header">Hello World</div>
text2png.replaceTags()This function works the same way as text2png.replace() except it replace all the elements with the given tag name. For example, you can use this function to replace all the <h1> and <h2> tags in the page.Example: (Replace Tags Example)
Script:
text2png.onLoad = function(){
text2png.replaceTags('h1', 'h2');
};
text2png.replaceAll()The replaceAll function is a safe an easy way to replace all the HTML child nodes of the parent elements. It skips any text nodes or elements that don't support innerHTML attribute. This function can be used to replace a navigation or a list of headlines.Example: (Replace All Example)
Script:
text2png.onLoad = function(){
text2png.replaceAll('nav', document.getElementById('list'));
};
HTML:
<div id="nav">
Menu: <!-- will NOT be changed -->
<a href="#">Home</a> <!-- will be changed -->
<a href="#">Contact us</a> <!-- will be changed -->
</div>
<div id="list">
The following is a list of headlines: <!-- will NOT be changed -->
<div>First Headline</div> <!-- will be changed -->
<div>Second Headline</div> <!-- will be changed -->
</div>
Options:The text2PNG script support different styles and options for each image. You can set most of the options using CSS rules for the HTML elements. However, some options must be set using the option variable.The precedence of the options is as the following:
var opt = {option:value,
option:value,
option:value,
option:value};
Notice that the last option does NOT have a comma "," after it. This is important for your options to work in IE.
Most of the options are self explanatory, but here is a complete list with the description.
Examples:The following are a few examples that illustrate how to use the text2PNG script. To view the code, right click on the window and select "View Source".
Script:
text2png.onLoad = function(){
text2png.replace('opacity_txt', {opacity:35});
text2png.replace('multi_line_example' {font:'arial black', font-size:14, black:1});
};
HTML:
<div style="font-family:'Kunstler Script', arial; font-size:16pt; color:#000066;">
Div text using Script Font
</div>
<span id="multi_line_example">
Multi line example<br />
the text lines are trimmed.<br />
And it can handle special HTML characters like ©
</span>
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| © Copyright 2008, text2PNG.com | Terms of use | NoGray Web Design Project | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||