星期四, 九月 25, 2008

Linux下编译带CJK文字的Java文件

直接编译很可能出错,指定encoding也有出错的可能性。
去掉LANG环境变量,却又意外惊喜,虽然不知道具体原因。

export LANG=
javac -classpath=A:B xxxx.java

iText

keywords:

Document is the object to which you’ll add content: the document data and meta-data.
Upon creating the Document object, you can define the page size, the page color, and the margins of the first page of your PDF document.

By default, a user unit corresponds with the typographic unit of measurement known as the point.
1 in = 2.54 cm = 72 points

When a document object is opened,  a lot of initializations take place in iText.
If you use the parameterless Document constructor and you want to change page size and margins with the corresponding setter methods, it’s important to do this before opening the document. Otherwise the default page size and margins will be used for the first page, and your page settings will only be taken into account starting from the second page.
That’s why you should always set the PDF version and add the metadata before opening the document.

When document.open() is invoked, the iText DocWriter starts writing its first bytes to the OutputStream. In the case of PdfWriter, a PDF header is written, and by default it looks like this:

%PDF-1.4
%âãÏÓ


adding content to the PDF document . There are three ways to do this:
    a:The easy way—Using iText’s basic building blocks
                        document.add(new Paragraph("Hello World"));

    b:As a PDF expert—Using iText methods that correspond with PDF operators and operands
                        PdfContentByte cb = writer.getDirectContent();
                        BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA,
                        BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
                        cb.saveState(); // q
                        cb.beginText(); // BT
                        cb.moveText(36, 806); // 36 806 Td
                        cb.moveText(0, -18); // 0 -18 Td
                        cb.setFontAndSize(bf, 12); // /F1 12 Tf
                        cb.showText("Hello World"); // (Hello World)Tj
                        cb.endText(); // ET
                        cb.restoreState(); // Q
    c:As a Java expert—Using Graphics2D methods and the paint method in Swing components
                        PdfContentByte cb = writer.getDirectContent();
                  Graphics2D graphics2D = cb.createGraphics(PageSize.A4.getWidth(),
                                                             PageSize.A4.getHeight());
                  graphics2D.drawString("Hello World", 36, 54);
                  graphics2D.dispose();
      (attention:On UNIX systems, may encounter X11 problems that prompt this error message: Can’t connect to X11 window server using xyz as the value of the DISPLAY variable. You can work around this issue by running the AWT in headless mode by starting the Java Virtual Machine (JVM) with the parameter java.awt.headless=true. Another solution is to run an X server. If you don’t need to display anything, a virtual X11 server will do.)


星期一, 九月 08, 2008

Compiling Software

1: How to compile
Software that comes in source form is often made available as a tarball-that is, it is archived into a single large file and then compressed with tar and gzip or bzip2, which often end in .tar.gz or .tar.bz2 or .tgz(contraction of .tar and .gz)

tar -xvzf kdirstat-2.2.0.tgz
tar -xvjf kdirstat-2.2.0.tar.bz2

To get a quick list of all the directories in a source tree
ls -l | grep drwx

To see what configure options come with a package
./configure --help

./configure

make (echo $PATH)

make install


the KDirStat executable is installed by default in /usr/local/kde/bin



2:How to run
<1>Running with Path Information
/usr/local/kde/bin/kdirstat

<2>Adding the Executable Directory to the Path
To make change during the current login session
export PATH = $PATH:/usr/local/kde/bin

To make the path change persist
~/.bash_profile

To make the path alteration system-wide
/etc/profile

<3>Linking to the Executable
ln -s /usr/local/kde/bin/kdirstat /usr/local/bin



3:Cleaning Up
make clean
OR
rm -rf kdirstat-2.2.0

RPM

1: Installing a New Package
rpm -ivh --force --nodeps packagename.rpm


2: Querying a Package
rpm -qa | grep -i 'name'

To find out which package a particular file belongs to
rpm -qf /dir/file

To find out the purpose of a package that is already installed
rpm -qi packagename

To find out what files are contained in a package
rpm -ql packagename

To identify information about and a list of files included in an uninstalled package
rpm -qilp packagename


3:Uninstalling a Package
rpm -e packagename


在线资料



System Management Tool
1:Webmin
http://yourservername:10000
Set the yourservername to be the name of the server as described by the Webmin installation message


2:redhat-config-packages


3:APT  non-RPM package manager used in other  distribution like Debian and Ubuntu
    Please note that these apt pages are obsolete. They were written in the days when yum didn't yet exist, when apt was the only decent dependency tool for rpm around. This has changed, you should really prefer yum over apt for rpm which is now unmaintained.
     <1>:Go to the http://freshrpms.net/apt/ to download the rpm package
     <2>:rpm -ivh
     <3>:apt-get update
     <4>:apt-get -f install
     <5>:apt-get install synaptic(Download an apt GUI manager) 

星期四, 九月 04, 2008

PHP の mbstring に関するメモ

http://www.asahi-net.or.jp/~wv7y-kmr/memo/php_mbstring.html