Print Crystal Report with Khmer Unicode in C# Application

This step use to Microsoft Visual Studio.NET 2005, and it’s rendered well with Khmer Unicode.

  1. Copy usp10.dll into Business Object Location (ex: C:\Program Files\Common Files\Business Objects\2.7\Bin\)
  2. Go to Visual Studio.NET 2005 with Design View, and right click on ToolBox Panel -> Select Choose Items. After that    Select COM Components Tab -> Click on Browse Button and Select on crviewer.dll in Business Object Location
  3. Add Reference Project, You go into Business Object Location select craxddrt.dll .
  4. Create a new Crystal Report
  5. Go to Coding View and code like below:

Preview Crystal Report in Crystal ActiveX Report Viewer

CRAXDDRT.Application crxApp = new CRAXDDRT.Application();
CRAXDDRT.Report crxReport = new CRAXDDRT.Report();
crxReport = crxApp.OpenReport(Application.StartupPath
 + "/KhmerUnicodeTest.rpt", null);
CRAXDDRT.DatabaseTable crxdt = crxReport.Database.Tables[1];
crxdt.SetLogOnInfo("[Server Name]", "[Database Name]", "[User Name]", "[Password]");
crxReport.ParameterFields.GetItemByName("[ParameterName]", "[SubReportName]").AddCurrentValue(val);
crxReport.OpenSubreport("[SubReportName]").ParameterFields.GetItemByName("[ParameterName]", "").AddCurrentValue(val);
this.axCrystalActiveXReportViewer1.ReportSource=crxReport;
this.axCrystalActiveXReportViewer1.ViewReport();

Auto Print with Default Printer

CRAXDDRT.Application crxApp = new CRAXDDRT.Application();
CRAXDDRT.Report crxReport = new CRAXDDRT.Report();
crxReport = crxApp.OpenReport(Application.StartupPath
 + "/KhmerUnicodeTest.rpt", null);
foreach (CRAXDDRT.DatabaseTable crxdt in crxReport.Database.Tables)
{
 crxdt.SetLogOnInfo("[Server Name]", "[Database Name]", "[User Name]", "[Password]");
}
crxReport.SelectPrinter("", "<Printer Name>", "");
crxReport.PrintOut(false, 1, true, 1, 200);

How to show “Printer Dialog”

CRAXDDRT.Application crxApp = new CRAXDDRT.Application();
CRAXDDRT.Report crxReport = new CRAXDDRT.Report();
crxReport = crxApp.OpenReport(Application.StartupPath
 + "/KhmerUnicodeTest.rpt", null);
foreach (CRAXDDRT.DatabaseTable crxdt in crxReport.Database.Tables)
{
 crxdt.SetLogOnInfo("[Server Name]", "[Database Name]", "[User Name]", "[Password]");
}

PrintDialog diag = new PrintDialog();
if (diag.ShowDialog() ==  DialogResult.OK)
{
   crxReport.SelectPrinter("", diag.PrinterSettings.PrinterName, "");
   crxReport.PrintOut(false, 1, true, 1, 200);
}

Notation: If you use Visual Studio 2008 for Project Development, you need Merge Module to install all client. It’s called CRRedist2008_x86.zip (Crystal Report Basic 2008 Run Time Package)

Reference Code from http://computer-experience.blogspot.com/2008/12/khmer-unicode-with-crystal-report-in-c.html

15 comments

  1. chaky · July 27, 2010

    Thank you.

  2. Savada Sin · February 21, 2011

    That’s cool! I having a problem with directly print out. Thanks for your sharing!

  3. Pingback: Print Crystal Report with Khmer Unicode in C# Application « Savada Sin (BK)
  4. traiter une fissure anale · August 26, 2014

    What’s up mates, how is the whole thing, and what you desire to say concerning this article,
    in my view its really amazing designed for me.

  5. news · September 7, 2014

    The production, in tthe eighteenth century that stressed on strong emotions simon and garfunkle such as As
    You Like It.

  6. car rental rajasthan · October 7, 2014

    The manual can be printed out too should you choose to read it away from your computer.

    A recent study done by The Journal of Veterinary Behavior
    involved two training schools, one that used the old school type of forceful training, while one used
    a force-free method of training. Educating your dog could help save his
    or her life one day.

  7. putlocker · October 14, 2014

    Hello, i feel that i noticed you visited
    my website tthus i came to return the desire?.I’m attempting to to find issues
    to improve my web site!I guesss itss ok to use a few of your ideas!!

  8. vireak · December 24, 2014

    I tried to compile a setup file for the software. However it does not work for the client pc that we setup. I did install Crystal Report Basic 2008 Run Time Package, but still not work.
    Please help

  9. Soungeng Hy · March 31, 2016

    i got an error at this line:
    crxReport.SelectPrinter(“”, “”, “”);
    it alerts message that: “Attempted to divide by zero”

    • sochinda · March 31, 2016

      Hello Soungeng Hy,

      what’s Windows version you use?

      • Soungeng Hy · April 5, 2016

        Hi, thank for reply. The previous error i have fixed(it’s because I set printer to No printer, after i choose one of existing it work). I used window 7 64 bit

  10. Soungeng Hy · April 5, 2016

    Hi, thank for reply. The previous error i have fixed(it’s because I set printer to No printer, after i choose one of existing it work).

    Now i have other problem, in toolbox – reporting section it not show axCrystalActiveXReportViewer control, even I add it again from COM Component.

    Could you tell me some tip to fix the problem?
    Thanks in advance,
    Sou Ngeng

  11. Soungeng Hy · April 5, 2016

    i forget to add message error:
    Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))

  12. Soungeng Hy · April 8, 2016

    i try reinstall visual studio 2008, then it work.

    Now I have other error, I connect crystal report on other computer(server) and it keep asking for username/password to connect to database. I use ODBC connection i have set username/password already both computer client and server(store database and report).
    Please help! Thanks in advance

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s