cancel
Showing results for 
Search instead for 
Did you mean: 

The characters display error when export PDF file?

Former Member
0 Kudos

Dear all,

I am facing with the problem when i used CR4E vs 2.0 to design crystal report and used JRC to show report. I key-in on report with unicode font to display the VietNamese language. When i exported my report to PDF file then characters can't display right. Some characters change to "?" symbol.

The font i use when key-in the character is Arial.

Please help me to solve this problem or explain for me to got others way.

Thank you so much

Tuan Pham

Accepted Solutions (0)

Answers (1)

Answers (1)

ted_ueda
Employee
Employee
0 Kudos

The "?" indicates it's a character encoding issue, and not a Font issue.

Does the issue happen only with PDF, or with all output formats?

What is the datasource character encoding?

Sincerely,

Ted Ueda

Former Member
0 Kudos

Dear Ted Ueda,

The issue posted only with PDF format file when exported. I used to POJO datasource.

I tried to converting method from native2ascii to encoding UTF-8 string. The string is displayed on report when runtime is fine. But when i export to PDF format file is the issue posted.

Best Regards,

Tuan Pham

ted_ueda
Employee
Employee
0 Kudos

So specific to the characters that convert to '?', what Unicode-encoding (in the form \u1234) do they appear when you do the native2ascii conversion?

Sincerely,

Ted Ueda

Former Member
0 Kudos

Dear Ted Ueda,

The "?" is appeared when i use "ሴ" on report. I think its not the problem at there.

a) The stream i want to display on report in VietNammese is "Công ty Bảo hiểm Hàn Quốc".

b) The stream is converted with UTF8-encoding is "C\u00f4ng ty Bảo hiểm H\u00e0n Quốc".

c) The stream is display on reported at the run-time is "Công ty B?o hi?m Hàn Qu?c".

You see the different bwt the stream a) and c). I hope you can find this problem and help me solve it.

Thank you for your information.

Best Regards,

Tuan Pham

ted_ueda
Employee
Employee
0 Kudos

I need to know the Unicode encoding so I can try an reproduce the issue.

By the way, the ሴ isn't UTF-8, it's Java String Unicode escape sequence.

I placed the String "C\u00f4ng ty Bảo hiểm H\u00e0n Quốc" and it exports to PDF with String "Công ty Bảo hiểm H..." just fine. Note that I'm using CR4E2.0 Service Pack 1 - download is the first post in this forum.

If Service Pack 1 doesn't resolve, then the missing characters (i.e., ô is ok but ả is not) indicates something transformed to ANSI character encoding from Unicode.

Another thing - if you look at the Document Properties in Adobe Reader and look up Fonts, does it indicate ANSI encoding? CR4E2.0 doesn't use character encoding, since it subsets (embeds) the font glyphs. Previous versions use ANSI encoding for PDF export.

Sincerely,

Ted Ueda

Former Member
0 Kudos

Dear Ted Ueda,

I'm using Crystal Reports for Eclipse Version: 2.0.1.r566 (Service Pack 1) i have just updated from site through Sofware Updates menu from Eclipse editor.

I tried to do some advances from you. I have seen that:

a) " Document Properties in Adobe Reader, look up Fonts is ok but encoding is ANSI".

b) When i replace the string UTF8 encoding with orginal Vietnames string and export to PDF file the issue still posted.

I think the coding should be change when we export to PDF. Some main coding to export PDF below, could you please checking the issue?

[[[

//Export report and obtain an input stream that can be written to disk.

//See the Java Reporting Component Developer's Guide for more information on the supported export format enumerations

//possible with the JRC.

ByteArrayInputStream byteArrayInputStream = (ByteArrayInputStream)reportClientDoc.getPrintOutputController().export(ReportExportFormat.PDF);

//Release report.

reportClientDoc.close();

//Use the Java I/O libraries to write the exported content to the file system.

byte byteArray[] = new byte[byteArrayInputStream.available()];

//Create a new file that will contain the exported result.

File file = new File(EXPORT_FILE);

FileOutputStream fileOutputStream = new FileOutputStream(file);

ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(byteArrayInputStream.available());

int x = byteArrayInputStream.read(byteArray, 0, byteArrayInputStream.available());

byteArrayOutputStream.write(byteArray, 0, x);

byteArrayOutputStream.writeTo(fileOutputStream);

//Close streams.

byteArrayInputStream.close();

byteArrayOutputStream.close();

fileOutputStream.close();

System.out.println("Successfully exported report to " + EXPORT_FILE);

]]]

Thank you for your advances

Best Regards,

Tuan Pham

ted_ueda
Employee
Employee
0 Kudos

Did you update your runtime? CR4E 2.0 doesn't use ANSI encoding in PDF, but subsets the font glyphs.

It sounds like you're still using CR4E 1.0 or older runtime.

Sincerely,

Ted Ueda

Former Member
0 Kudos

Dear Ted Ueda,

Thank you very much for your help, I tried sample reports with the new CR4E SP1 the result the same your sound. I solved it.

Thanks again.

Tuan Pham

Former Member
0 Kudos

Dear Ted Ueda,

I'm using Crystal Reports for Eclipse Version: 2.0.1.r566 (Service Pack 1) i have just updated from site through Sofware Updates menu from Eclipse editor.

I tried to do some advances from you. I have seen that:

a) " Document Properties in Adobe Reader, look up Fonts is ok but encoding is ANSI".

b) When i replace the string UTF8 encoding with orginal Vietnames string and export to PDF file the issue still posted.

I think the coding should be change when we export to PDF. Some main coding to export PDF below, could you please checking the issue?

[[[

//Export report and obtain an input stream that can be written to disk.

               //See the Java Reporting Component Developer's Guide for more information on the supported export format enumerations

               //possible with the JRC.

               ByteArrayInputStream byteArrayInputStream = (ByteArrayInputStream)reportClientDoc.getPrintOutputController().export(ReportExportFormat.PDF);

               

               //Release report.

               reportClientDoc.close();

ByteArrayInputStream is = new ByteArrayInputStream(Charset.forName("UTF-16").encode(byteArrayInputStream.toString()).array());

                 writeToFileSystem(is, EXPORT_OUTPUT);              

               //Use the Java I/O libraries to write the exported content to the file system.

               byte byteArray[] = new byte[byteArrayInputStream.available()];

               //Create a new file that will contain the exported result.

               File file = new File(EXPORT_FILE);

               FileOutputStream fileOutputStream = new FileOutputStream(file);

               ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(byteArrayInputStream.available());

               int x = byteArrayInputStream.read(byteArray, 0, byteArrayInputStream.available());

               byteArrayOutputStream.write(byteArray, 0, x);

               byteArrayOutputStream.writeTo(fileOutputStream);

               //Close streams.

               byteArrayInputStream.close();

               byteArrayOutputStream.close();

               fileOutputStream.close();

               

               System.out.println("Successfully exported report to " + EXPORT_FILE);

]]]

This one using for Persian language purpose but whenever export pdf format error showing need solution   ??????????

Former Member
0 Kudos

Hi Ted,

We are using crystal report viewer 11. While exporting crystal report pdf for persian language we are facing an issue, the characters are displaying wrongly ????. Even we are using persian rpt file.

In viewer it is displaying properly. But while exporting PDF it shows wrongly ???.

Kindly help us to fix the issue ASAP.