I am try to give gujarati print on printer but it shows me square boxes on page like in following.
I had also print on console in netbeas but still result are same. I had also tried Java UTF-8 encoding and decoding using following code but not get expected output.
String s = "શ્રેષ્ઠ અહેવાલ એન્જિન ઉપલબ્ધ એફ";
byte arr[] = s.getBytes("UTF8");
System.out.println(new String(arr, "UTF-8"));
output:
i had used following code for print :
class print{
public static void main(Strng args[]){
try{
PrinterJob pj = PrinterJob.getPrinterJob();
pj.setPrintable(new BillPrintable(), BillPrintable.getPageFormat(pj));
pj.print();
catch(Exception e){}
}
class BillPrintable implements Printable {
public int print(Graphics graphics, PageFormat pageFormat, int pageIndex)
throws PrinterException {
int result = NO_SUCH_PAGE;
if (pageIndex == 0) {
Graphics2D g2d = (Graphics2D) graphics;
g2d.drawString("શ્રેષ્ઠ અહેવાલ એન્જિન ઉપલબ્ધ એફ", 0, 20);
result = PAGE_EXISTS;
}
return result;
}
public static PageFormat getPageFormat(PrinterJob pj) {
PageFormat pf = pj.defaultPage();
Paper paper = pf.getPaper();
double middleHeight = 10.0;
double headerHeight = 1.0;
double footerHeight = 1.0;
double width = convert_CM_To_PPI(8); //printer know only point per inch.default value is 72ppi
double height = convert_CM_To_PPI(headerHeight + middleHeight + footerHeight);
paper.setSize(width, height);
paper.setImageableArea(
0,
0,
width,
height - convert_CM_To_PPI(1)
); //define boarder size after that print area width is about 180 points
pf.setOrientation(PageFormat.PORTRAIT); //select orientation portrait or landscape but for this time portrait
pf.setPaper(paper);
return pf;
}
protected static double convert_CM_To_PPI(double cm) {
return toPPI(cm * 0.393600787);
}
}
}
so please help me to ride off this problem and thanks in advance.


Using above code I had solved issue and thanks @joni for your hint in comment regarding font.
issue was regarding font I had downloaded regional language font .ttf file and used it in project using above code.