Friday, December 26, 2008

Khmer Unicode with Crystal Report in C# Application

I use VS2008 to test Khmer Unicode rendering in Crystal Report.

I. Prepare Crystal Report Render well in report design
First you have to make the crystal report in design time possible to write or view Khmer Unicode

1.1. Copy usp10.dll (version1.465.4001.0) to C:\Program Files\Business Objects\Common\2.8\bin


















1.2. Change fonts setting
in Crystal Report, at VS2008, create a crystal report and go to Crystal Reports --> Design --> Default Setting --> Go to Fonts Tab, change all element to Kh System

II. View Crystal Report with VS Crystal Report Viewer,
Khmer Unicode is not rendering well.
(Under research)

III. View Crystal Report with Crystal Report View
It's working very well for me to view Crystal Report with Khmer Unicode characters on form.
Here is the process...

3.1. On design time, add COM control of Crystal Report ActiveX Report Viewer Control of Business Objects; from my pc, it's a dll at: C:\Program Files\Business Objects\Common\2.8\bin\ crviewer.dll












3.2. Add Reference in the project of craxddrt.dll



















3.3. Create Crystal Report
and write some code in Khmer Unicode and save it to some where, my example in folder bin/Debug

3.4. Coding to call the report to view in the control:


CRAXDDRT.Application crxApp = new CRAXDDRT.Application();
CRAXDDRT.Report crxReport = new CRAXDDRT.Report();
crxReport = crxApp.OpenReport(Application.StartupPath
+ "/KhmerUnicodeTest.rpt", null);
this.axCrystalActiveXReportViewer1.ReportSource=crxReport;
this.axCrystalActiveXReportViewer1.ViewReport();

3.5. Here is the result display












DOWNLOAD: Sample Project: TestCrystalReportViewer

IV. View Crystal Report by export directly to PDF
It works very well, just have issue with font size.
We just call Crystal Report Object and then export it to disk, here is the coding:


private void btnPrintCrystal_Click(object sender, EventArgs e)
{
CrystalKhmerUnicode rptCrystal = new CrystalKhmerUnicode();
rptCrystal.SetParameterValue("txtReportTitle","Hello World");
rptCrystal.SetParameterValue("txtTitle", txtTitle.Text);
rptCrystal.SetParameterValue("txtArticle", txtArticle.Text);
rptCrystal.ExportToDisk(ExportFormatType.PortableDocFormat, "./KhmerUnicode.pdf");
MessageBox.Show("Now report exported to current folder: KhmerUnicode.pdf");
// Direct open pdf report
System.Diagnostics.Process.Start("./KhmerUnicode.pdf");
}

Enjoy,
Happy New Year 2009!
Metrey,

Thursday, December 25, 2008

Wanna to write Khmer Unicode on coding in VS2005 or VS2008?

In fact, I know many people should already know it but I suppose to post here that maybe help others to search for.

I want to write Khmer Unicode text in coding in Visual Studio 2005 or 2008, maybe need to assign value or declare parameter in Khmer etc. So we need to make the editor know Khmer Unicode first.

After your PC running well with Khmer Unicode, please follow this instruction to make it possible to write Khmer on your code:

In Visual Studio option: Tools --> Options --> at Environment, Fonts and Colors set font to: Kh System, then it works.

See screens:













Here, after change, what I can write:

Tuesday, December 23, 2008

Khmer Unicode works now with Adobe CS3

Very good news for us, Khmer, that we have now the fonts that work with Adobe CS3.
It's easy to configure as in fact, we just install new fonts from Khmer OS (I'm not sure yet where is the source of this font), but you can download here: Khmer Unicode Supported CS3.

There are fonts:
  • Kh-Battambang
  • Kh-Bokor
  • Kh-Content
  • Kh-Fasthand
  • Kh-Freehand
  • Kh-Kangrey
  • Kh-Koulen
  • Kh-KoulenL
  • Kh-Metal-Chrieng
  • Kh-Muol
  • Kh-Muol-Pali
  • Kh-Siemreap
  • Kh-System

The right font view as:
















See how to do it:

1. Install fonts: Start -> Control Panel -> Fonts -> Install New Fonts -> Select Kh fonts to install















2. On Adobe Photoshop CS3, select a Kh font (Ex: Kh System)
Here Example:












Note: any font name in group of Kh font will be Ok with CS3, these fonts also can use well with embedded for website without needed usp10.dll, I'll test it first.

Monday, December 22, 2008

Write a string to the specific line or position in the written file in java

I got doubt on this point almost 2 hours to seek how can I write a string to a file at the position, I want.

Let me try to explain my issue that would help others who will have the same:
I extracted the data from database and write it to a file, I have so many queries for one group of lines, the layout of the file is:


1 line header
many lines detail


On the header, it's the summary of all lines in detail, it's in one query and I need to write first line of the header and a group of lines for detail to prevent OutOfMemory Exception at run time (As my file can have data around 1000 MB or much more than this).
One day, I got a request on my dev to modify a rule at the header that i need to count all lines of detail and put in in the header line in one position (position 27),
1. I don't want to execute count all queries of detail to find the record as we can count it when each query extract data so that we can reduce some cost of performance issue.
2. And we should not keep all lines of detail in StringBuffer or String or in list or map and after finish iterate them to write into file from header and then the details (this way we can count the record lines till queries of detail finished and then add it to header as normal), this solution for sure, we will meet OutOfMemory Exception for hug amount of data.
3. So the only solution to write the lines of header and details as normal but try to integrate the record count value to the header line in written file which should not rewrite the new file by read from the written file (performance issue!)..

With solution 3/ above, I got the way with RandomAccessFile functionality: Seeking the byte position of records and after the position integrate the value we prefer.
As my file is fixed length file, and the field to add is at position 27 so the end position of it is 26, here is example:

file.txt: 1 line header and 12 lines of detail:
000000000005400000221020080 98136
...

I need to add value: 12 to the position 27, here is the code:


/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
RandomAccessFile reReadWriteFile = null;
try {
reReadWriteFile =
new RandomAccessFile("file.txt", "rw");
} catch (FileNotFoundException e) {
System.out.println("Error: " + e.getMessage());
throw e;
}

try {
// To search on 26 bytes of field total detail lines
// at header line
reReadWriteFile.seek(26);
reReadWriteFile.writeBytes("12");
reReadWriteFile.close();
} catch (IOException e) {
System.out.println("Error: " + e.getMessage());
throw e;
}
}


After execute, file.txt: will be

0000000000054000002210200812 98136
...

Hope it helps you!
Metrey,

Learning Tip: API of RandomAccessFile

Thursday, December 18, 2008

Flex build 3.0.194161 not working with Eclipse 3.4 solution

First I install flex (build: 3.0.194161) to use with Eclipse 3.2.1, it’s working fine.

I wan to use my existing flex plugin with Eclipse 3.4, I got problem as describe in this post.

I wanna to try to use both eclipse with the same flex plugin, with Eclipse 3.4 I try to install Flex plugin by Software Updates but I could not.

I found the solution on the net, thanks to Tekool.net

I have removed the Flex plugin and then re-install the flex plugin, point to Eclipse 3.4 and Proceed it with Caution










After done, download the patch provided in Tekool.net (Direct download here)
Replace the plug-in of the patch into Eclipse plug-in of Flex Plug-in









And at Eclipse start up add parameter -clean: eclipse.exe -clean
Or from the Flex launcher add this parameter too:
eclipse.exe -clean -showlocation -vm ...

It's working for me now.

Add external extension to Eclipse 3.4

I got wonder when I try to find place to add External Extension in Eclipse 3.4 because it doesn't have the URL as: Help -> Software Updates -> Manage Configurations as Eclipse 3.2.x

On the net, I found the solution, here it is:
Go to: Help -> Software Updates : One windows will come up
On Tab Available Softwares, Click on Add Site and Then Choose Locale Button to browse for the plug-in to add
Finally Click Install

See the screen shot:

Thursday, November 13, 2008

Software Development and Logging

Beside understanding programming language and programming model etc. We must know how to manage the message from the development for user, for developer etc. We called logging.

To manage log, we have many ways according to programming language and platform.

Normally, most of the developers neglect on logging during development parse and starting to expect the log files when an issue happens. That's why log management becomes very important for software development that we need to spend time to manage it as much as possible during development parse.

Log Management proceed into 4 levels:
1. Debug : this is a developer logging level. Should use it for any technical test or technical information that not requires to understand the business process.
2. Info : This is user logging level. Use it to describe the business process or information.
3. Warning: This log level is to focus on not mandatory missing element.
4. Error : Use this log level in case of technical or functional error.

There are many tools or add-on tool to help handling for various log management: (but I would suppose for open source project one, Apache)
- log4j : For Java
- log4Net : For MS DotNet
- log4PHP : For PHP
- log4plsql : For PL/SQL or SQLPlus of Oracle

Thursday, October 23, 2008

My brief...

Yes, the topic is layout here...

I am gonna to prepare some articles variously in IT fields through my research and experience..

I hope it would help many people and also to keep myself interesting in those research..