I am going to resolve Issue of Font Displaying Box or Junk While Exporting Crystal report which Is created In Regional Language Like Marathi, Hindi ,Arabic. Most Issue Is because of The font .
This Article will helps Developers who are developing Crystal report in there Regional Language because there are not much Article on localizing Crystal report .
The Font Which We use while developing Report Should be there on Server
Where you are going to Deploy your application .
If font is not there then it will create Junk like Characters .
Tip: You Cannot use any font to develop Report you should use Unicode Font for it.
Main Step is install Font on Server or any Place Where you are Going to Deploy Application.
While export Crystal report in Language like English we do not get issue because
by Default that font is installed in your PC(Computer).
But While Developing Report In regional Language we face issues:
- Having fonts but there are not unicode that will be issue for displaying junk Characters.
- But will see report on your developing PC (Personal Computer) it look proper but will deploying on server it display junk.
What is Unicode Font ? Why to use them.
Unicode provides a unique number for every character,
- no matter what the platform,
- no matter what the program,
- no matter what the language
This line are Reference from site :
Here in this site you will see all details about Unicode font.
Here I am showing you steps how to Resolve this issue in few steps.
- Create New Application
- Step File → New → Project
- In Installed Template Select Web → ASP.NET Web Application.
- Add Name to it.
Here is Snapshots with Explanation for Creating New application.
- After creating Application Just add Webform and Name it .
- Add Crystal Report Viewer to Page to display report and Also adding Button to Export
to Crystal report in to Pdf.
Here I am providing code for of .aspx page.
- Crystal Report Viewer.
<form id="form1" runat="server">
<div style="text-align: center;">
<asp:Button ID="Button1" runat="server" Width="150px" Height="50px" Text="Export to Pdf" OnClick="Button1_Click" />
<div style="text-align: center;">
<asp:Button ID="Button1" runat="server" Text="Button" />
- Add CrystalReport
- Selecting reporting tools from installed templates
- After selecting you can see crystal report with visual C#
- Just select it and name it.
After this Just new Window will Popup for selection.
- In popup you will find 3 option to develop it.
- That Select Blank report.
- To Crystal-report I am just Binding Stored procedure.
- I have just Created table with Name DOIUsertemp.
- For storing charater of Unicode I have given datatype of it to Nvarchar.
In Table I have Marathi Inserted Unicode Values to display on Report.
[ One of Regional Language in India ]
Data. Create Table.
View of Table. [ This is Snapshot of Record in Table DOIUsertemp in Marathi.]
View of Stored procedure
[ Created Stored Procedure for get values from database and displaying on report ]
[ This is Snapshot of crystal report with store procedure Fields.]
- In this step I am going Dragging Fields on Report from Stored procedure.
- After Dragging fields on report i am going to show you how to select font.
- Select the Drag Field on Crystal-report .
- select Font From above Header which we want to use. (Regional Language Font and MustUnicode).
- For Marathi I am going to Select Mangal.
- You Can select your own Font according to your need.
[ This is Snapshot while Selecting in Marathi Font.]
[ This is Snapshot of Perview Crystal report in Marathi.]
- After that just save report.
- Now just We Need to write Code for Binding Report and Exporting Report .
- Binding Report on load.
Here I am Providing Code for Binding Crystal Report on Load Event.
protected void Button1_Click(object sender, EventArgs e)
SqlCommand cmd = new SqlCommand("Usp_GetUser", con); SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
DataTable datatable = new DataTable();
da.Fill(datatable); ReportDocument crystalReport = new ReportDocument();
CrystalReportViewer1.ReportSource = crystalReport;
crystalReport.ExportToHttpResponse(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, true, "PersonDetails");
Here is Output for Marathi Data after exporting report with no junk Character.
For Hindi Language.
Same Process is required for Developing Crystal in Hindi .
Also Just Change the Font to Hindi while Creating Report its
On button click use same Code used for Marathi to exporting report.
Done. For Demo in table I have Inserted Hindi Record.
View of Table. [ This is Snapshot of Record in Table DOIUsertemp in Hindi.]
Selecting Hindi Font .
[ This is Snapshot while Selecting in Hindi Font.]
Final Out put for Hindi Data after Exporting.
For Arabic Language.
Same Process is required for Developing Crystal in Arabic .
Also Just Change the Font to Arabic while Creating Report its Done.
Main point you can install any other font of Arabic and develop but Font must be Unicode. For Demo in table I have Inserted Arabic Record.
View of Table. [ This is Snapshot of Record in Table DOIUsertemp in Arabic.]
Selecting Arabic Font
[ This is Snapshot while Selecting in Arabic Font.]
Final Out put for Arabic Data.
On button click use same Code used For Exporting Marathi Crystal Report.
Completed My Solution.
Programmer For Sharing Knowledge and Gaining Knowledge
Making People Life Easy