We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Problem with generating PDF with Hebrew in Java

Hello,

I’m trying to write a Hebrew text string to a PDF file.
The file gets written, but when I open it with Adobe Acrobat, I see that the string was not written.
When I try to write a string that has both Hebrew and English, the English text appears properly (but the Hebrew doesn’t).

I tried different ways to get around this problem, including some code I based on some .NET example I found (attached below). I couldn’t get it to work.

Any idea / Java sample / etc…?

Thanks!

------------------ Sample code that failed to work ---------------
com.aspose.pdf.elements.Pdf pdf = new com.aspose.pdf.elements.Pdf();

com.aspose.pdf.elements.Section section = pdf.getSections().add();

com.aspose.pdf.elements.Text text = new com.aspose.pdf.elements.Text(section);

com.aspose.pdf.elements.TextInfo textInfo = text.getTextInfo();

textInfo.setIsUnicode(true);

textInfo.setFontName(“hebrew”);

textInfo.setTrueTypeFontFileName(“c:\temp\hebrew.ttf”); // got this file from some message I found on your forum…

textInfo.setIsFontEmbedded(true); // I think that the font file wasn’t actually embedded, as the PDF file was the same as without this call (and quite small - ~2kb).

text.setTextInfo(textInfo);

com.aspose.pdf.elements.Segment segment = text.getSegments().add();

segment.setContent(“שלום עולם”);

section.getParagraphs().add(text);

java.io.FileOutputStream fos = new java.io.FileOutputStream(“c:\temp\pdf5.pdf”);

pdf.save(fos);

fos.close();

----------------------------------------------------------

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for considering Aspose.

I have tested the scenario and I am able to notice the problem. We are looking into the details of this issue and will keep you updated with the status of correction. We apologize for your inconvenience.


Hey,

Thank you for the quick reply.
Is there a different scenario that I can use (in Java) for correctly generating a Hebrew PDF?
If not, do you have an estimation for when you’ll have a fix or a workaround?

Thanks in advance,
Oz

Hi,

We are working over this issue and I have asked the development team to share the ETA for the resolution of this problem. We apologize for your inconvenience.