Script Renderer
This is an experimental online service based on PyPDFLib library in development. This library projects objective is to develop an opensource pdf rendering library which can support all complex scripts. It is in development and this service is not bug-free now.
Generate PDF of a wiki page
Convert Text to Image
Module Information
This module uses pango cairo python apis for rendering. To get this running , you should have python bindings of pango and cairo installed in your system. For PDF generation, the module uses PyPDFLib library. This module is in development and APIs are not stable or final.Bugs? Suggestions? Let us know!
If you see any bug in this application or you have any suggestion for improvement, just mail to pypdflib-dev@nongnu.org with details. You can also report the bug at PyPDFLib bug trackerPython API
You can use Silpa python APIs to renedr a custom text to any image format or PDF. After installing silpa, refer the following example for using the api. The text can be in any script, including Right to Left scripts.
from silpa.modules import render
render=render.getInstance()
#Render the text to SVG format. width=100, height= 200 pixels
render.render_text("Your text goes here", "svg", 100,200)
#Render the text to png format. width=100, height will be automatcally set based the content size
render.render_text("Your text goes here", "png", 100 ,0)
# Render the text to a PDF
render.render_text("Your text goes here", "pdf", 500 , 500)
The render_text method return the name of the generated image.(TODO: Make the path of the image configurable)
Python JSON RPC
You will require JSON RPC client from here: http://json-rpc.org/wiki/python-json-rpc
from jsonrpc import ServiceProxy
proxy = ServiceProxy("http://localhost/silpa/JSONRPC")
print s.modules.Render.render_text("Your text goes here", "svg", 100,200)
PHP JSON RPC
A sample PHP client to use the Silpa's JSON RPC service is given below.
define ('HOSTNAME', 'http://silpa.smc.org.in/JSONRPC');
$url = HOSTNAME;
// Open the Curl session
$session = curl_init($url);
// If it's a POST, put the POST data in the body
$postvars = '{"method": "modules.Render.render_text", "params": ["Your text goes here", "png", 100,100], "id":"jsonrpc"}';
curl_setopt ($session, CURLOPT_POST, true);
curl_setopt ($session, CURLOPT_POSTFIELDS, $postvars);
// Don't return HTTP headers. Do return the contents of the call
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
// Make the call
$json = curl_exec($session);
// The web service returns json. Set the Content-Type appropriately
header("Content-Type: application/json");
echo $json;
$obj = json_decode($json,false);
$result = $obj->{"result"};
echo $result;
curl_close($session);
The result will contain the image name. the image can be accessed by http://silpa.smc.org.in/Render?image=abcd.png
Wiki to PDF
The wiki2pdf method is accessible by the following JSON:
$postvars = '{"method": "modules.Render.wiki2pdf", "params": ["http://en.wikipedia.org/wiki/Kerala"], "id":"jsonrpc"}';