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,

25 comments:

  1. hi thanks your post that give knowledge. but but problem when create this project as package that it have error

    ReplyDelete
  2. Hi Ing,
    What errors you have? Can you describe it so that I can try to help? It can be different VS version usage etc.

    ReplyDelete
  3. Well done Metrey!
    It works perfectly.
    Thanks a lot for sharing.

    ReplyDelete
  4. It run properly, Thanks for your posting but could you tell me how to set parameter value to report and bound it from dataset.

    thanks in advance

    Savada Sin (savadasin@gmail.com)

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete
  6. Hi
    thank for your pasting this problem ,put when I package it and running it on another machine
    thate alert the message box System.Runtime.InteropServices.COMException (0x80040154) how can I solve this problem

    thank in advance
    mala(tml.developer@gmail.com)

    ReplyDelete
  7. Hey! I successfully use what u told. But then I have another problem. When the report is loaded, it appears to ask for refresh/change the sever name! (we use in different computer).Thanks for help.

    ReplyDelete
  8. Hi! Thank for your posting. but i still got problem with when i change crystal report location at run time. may u give some advise ? (sokheng.siv@gmail.com)

    ReplyDelete
  9. How about in Microsoft Report (the one in VS)?
    At runtime it won't render Khmer Unicode correctly.
    Any one know how to fix this?

    ReplyDelete
  10. @Prasart: Microsoft Report not yet support unicode; hope we can find a solution

    ReplyDelete
  11. how to change several databases for one crystal report at runtime in C# coding

    ReplyDelete
  12. Hi! Bong Metrey.
    i have problem with Khmer Unicode with Crystal Report. i had done successul with ur forum with it.it can render and preview successful, but one more problem is that: when i try connect data from sql 2005 and drag field in crystal report, when render project it always alert me to input password of user sa in sql 2005 unless i had input it when connect to sql 2005 already.
    so,the problem is should not show to input password again when render crystal report.
    thx in advance.

    ReplyDelete
  13. Hello . i m nt able to download this project..

    ReplyDelete
  14. Hi,

    There is CRAXDDRT in VS 2008, but I develop with VS 2010. what can I do?

    ReplyDelete
  15. Hi, thank for your post. It works well for me when I follow you but I have got other problem. The problem is that in the report, it doesn't have tool to export data to other application like word or excel.
    Could you show me how to make it work? Thank you in advance.

    ReplyDelete
  16. Your article is using CRAXDDRT.dll and CRViewer.dll which is not the pure .net framework. It is an ActiveX that we used to deal with in VB 6. What about if we need a pure .net application? How can we render Khmer unicode?

    Thanks,

    ReplyDelete
  17. thank it good for me.

    ReplyDelete
  18. how about Ms report viewer in VS 2008 ? can any 1 know how to fix khmer unicode with it te ?

    ReplyDelete
    Replies
    1. you can't use report of vb.net you must use crystal report with business object.any problem please go to(setha.info)

      Delete
  19. I have problem for display my crystal reports in VS2008 it doesn't display well if I use align justify.Can you help please?(visothchhim@gmail.com)

    ReplyDelete
  20. is any one help me I want to access Anu Script Telugu words into crystal report

    ReplyDelete
  21. I have a problem, I have stored telugu words in Access Database,typed with anu script manager, when I try to access in crystal report, it is showing junk values.

    ReplyDelete
  22. public CRAXDDRT.Application crxApp = null;
    public CRAXDDRT.Report crxReport = null;
    crxApp = new CRAXDDRT.Application();
    crxReport = new CRAXDDRT.Report();
    crxReport = crxApp.OpenReport(_retportPathAndName);
    crxReport.DiscardSavedData();
    crxReport.Database.Tables[1].SetLogOnInfo(".", "DBLibrary", "sa",
    "123456");
    crxReport.Database.SetDataSource(dt,null); this.axCrystalActiveXReportViewer1.ReportSource = crxReport;
    this.axCrystalActiveXReportViewer1.ViewReport();

    ////////////////////////////////////////
    my code above it working to show khmer unicode in crystal reports
    for i open first time but for second time it has error at
    "crxReport.Database.SetDataSource(dt,null);"
    i don't know why it was generated error like this.
    Error Message " Attempt to read or write Protected Memory This is often an indicating that other memory is corrupt"
    please help me.i can not solve this problem.

    best regards

    ReplyDelete
  23. Dear all, I no longer maintenance this blog this topic is now move to blog: http://osify.com/2008/12/khmer-unicode-with-crystal-report-in-c-application/#.Ug8PrH8iyR4

    Any specific question, you can ask me at: http://ask.osify.com/

    ReplyDelete

Note: Only a member of this blog may post a comment.