Tareq Alam

i have promises to keep and miles to go before i sleep – Robert Frost

multivalent: java tool to compress pdf September 30, 2008

Filed under: Ubuntu, java — tareqalam @ 9:59 am
Tags: , , ,

here i am describing how I have used multivalent
help link: http://multivalent.sourceforge.net/Tools/pdf/Compress.html
download link: http://sourceforge.net/project/showfiles.php?group_id=44509
to install:
1. place the attached jar file to anywhere in server
2. in terminal ype: sudo vi /etc/environment this will open a file something like this:
PATH=”/usr/local/sbin:/usr/

local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games”
LANG=”en_US.UTF-8″
CLASSPATH=”:/home/tareq/projects/itext/iText-2.1.3.jar:/home/tareq/projects/itext/Multivalent20060102.jar:”

add the class path like the example here this /home/tareq/projects/itext/ path can be anywhere
3. restart the server
4. now run the python script placing it to the correct place or you can test in terminal just type java tool.pdf.Compress path_to_pdf_file

hope this works

 

install skype in ubuntu September 25, 2008

Filed under: Linux, Ubuntu, important links — tareqalam @ 10:21 am
Tags: , ,

Got this from ubuntu forum:

Skype Repository

  1. Add the Skype repository*: deb http://download.skype.com/linux/repos/debian/ stable non-free

  2. Reload or update the package information
  3. Install the skype package.

 

R and Rpy September 21, 2008

Filed under: Linux, Ubuntu, python — tareqalam @ 1:14 pm
Tags: , , , ,

R is a strong language. And there is a way in python with that R can be used that is called Rpy http://rpy.sourceforge.net/

its easy to install. here I will show you an example to create simple graphics using rpy

from rpy import *

def create_simple_bar_chart(file_name,size=5,bottom=1,left=0.5,top=0,right=0):
if bottom>left:
graphics_width = size+bottom;
graphics_height = size+bottom;
if left>bottom:
graphics_width = size+left;
graphics_height = size+left;
if left==bottom:
graphics_width = size+left;
graphics_height = size+left;

r.pdf(file_name,graphics_width,graphics_height,paper=”a4″,pagecentre=r.F)
r.par(omi=r.c(bottom,left,top,right))
r.par(pty = “s”)
r.plot(r.table(r.rpois(150,7)),ylab=”hospital”,xlab=”patient”, type = “h”, col = “red”, lwd=10,main=”number of patients per hospital”)
r.dev_off()

def create_hist_with_R(file_name,size=5,bottom=1,left=1,top=0,right=0):
x = [24,60,18,63,32,47,88,64,72,87,100,16,37,46,50,\
64,11,45,77,35,38,39,84,90,6,87,25,67,51,71,52,\
98,57,5,65,75,8,68,35,75,95,29,50,44,30,1,92,93,\
56,56]

if bottom>left:
graphics_width = size+bottom;
graphics_height = size+bottom;
if left>bottom:
graphics_width = size+left;
graphics_height = size+left;
if left==bottom:
graphics_width = size+left;
graphics_height = size+left;

r.pdf(file_name,graphics_width,graphics_height,paper=”a4″,pagecentre=r.F)
r.par(omi=r.c(bottom,left,top,right))
r.par(pty = “s”)
#r.plot(r.table(r.rpois(100,5)),xlab=”frequency”, type = “h”, col = “red”, lwd=10,main=”rpois(100,lambda=5)”)
r.hist(x, xlab=”frequency”, ylab=”count”, main=”histogram example using R”, col=’cyan’)
r.dev_off()

def create_simple_bar_chart_rainbow(file_name,size=5,bottom=1,left=0.5,top=0,right=0):
if bottom>left:
graphics_width = size+bottom;
graphics_height = size+bottom;
if left>bottom:
graphics_width = size+left;
graphics_height = size+left;
if left==bottom:
graphics_width = size+left;
graphics_height = size+left;

r.pdf(file_name,graphics_width,graphics_height,paper=”a4″,pagecentre=r.F)
r.par(omi=r.c(bottom,left,top,right))
r.par(pty = “s”)

r.plot(r.cos, -r.pi, 2*r.pi,col=r.rainbow(20),ylab=”biologic”,xlab=”total”,main=”Test Data”)

r.dev_off()
def draw_pie_chart(file_name,size=5,bottom=1,left=0.5,top=0,right=0):
if bottom>left:
graphics_width = size+bottom;
graphics_height = size+bottom;
if left>bottom:
graphics_width = size+left;
graphics_height = size+left;
if left==bottom:
graphics_width = size+left;
graphics_height = size+left;

r.pdf(file_name,graphics_width,graphics_height,paper=”a4″,pagecentre=r.F)
r.par(omi=r.c(bottom,left,top,right))
r.par(pty = “s”)

r.pie(r.rep(1, 24), col = r.rainbow(24), radius = 0.9,main=”test pie chart”)

r.dev_off()

draw_pie_chart(“rgraphics_pie.pdf”,5,1,1,0,0)

create_hist_with_R(“rgraphics_hist.pdf”,5,1,1,0,0)

create_simple_bar_chart(“rgraphics_bar.pdf”,4,5.5,0.5,0,0)

 

iText: how to add the jar file in the class path of linux and windows September 21, 2008

ON UBUNTU

I am using IText to one of my projects its a nice technology for creating maniulating pdfs. Here I want to discuss how to add the jar file in the class path of linux.

first download the jar file from http://www.lowagie.com/iText/download.html here.

Now in linux system (I have tried in ubuntu) place the jar file inside any folder suppose named itext.

to set the class path open terminal window type sudo gedit /etc/environment

the environment file is something like this :

PATH=”/usr/local/Java/jdk1.6/bin:.:/usr/local/sbin:/usr/local/bin:

/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11″
LANG=”en_AU.UTF-8″
LANGUAGE=”en_AU:en”
JAVA_HOME=”/usr/local/Java/jdk1.6″
CLASSPATH=”/usr/local/Java/jdk1.6/lib:.”

Add the path_to_your_itext_jar_file at the line CLASSPATH like this

CLASSPATH =”usr/local/Java/jdk1.6/lib: path_to_your_itext_jar_file:.”

then you better restart the system. To test wheather iText is working or not. try this simple code  example:

class HelloWorld{

public static void main(){

Document document = new Document();

PdfWriter.getInstance(document, new FileOutputStream(“HelloWorld.pdf”));

document.open();

document.add(new Paragraph(“Hello World”));

document.close();

}

}

save this file as HelloWorld.java

then in terminal type>> javac HelloWorld.java

then type>> java HelloWorld

now see a pdf is created in the directory where the java file is located.

ON WINDOWS (XP)

Right Click on My Computer Icon. Click Properties.

if there is aleready a variable named CLASSPATH then select and press edit and type the path

of iText.jar file. Suppose the jar file is in d:\itext\iText.jar . add in the value section

d:\itext\iText.jar;

If there is no variable named CLASSPATH the create one by pressing new

classpath

see the above image and try

When you save by press ok it will show here:

createclasspath

Hope this helps ..

Thanks