Developer Tools
|
Office Productivity Applications
|
Platform-Agnostic APIs
|
Home | Online Demos | Downloads | Buy Now | Support | About Us | News | Working Together | Contact Us
One of our PDFOne (for Java) users wrote to us:
I am trying to create a simple PDF with the text "Mére". The problem is that my pdf does not contain this text, but "M(some characters)re." The same thing happens with all French characters. I want to know if there is a way to create the pdf correctly.
I had faced a similar problem with Classic ASP and the solution then was to switch to Unicode in the text editor. So, I tried a similar approach with Eclipse. I also used a font that supported French characters. And, it worked!
In Eclipse, go the Project menu, select Properties » Info » Text File Encoding » Other » UTF-8. You can choose any of the other available Unicode options too, but you should be careful when do this. Your existing code might become unreadable. If it does happen that way, then switch back to your original setting. You might be able to get back your original code.)
Now, Eclipse will able to store non-English text without any problem. To try it, write some non-English text to a PDF document using methods such as PdfDocument.WriteText()
.
Here is some sample code. I copied the non-English text from news reports. I have no idea what they mean. Pardon moi.
import java.io.IOException; import com.gnostice.pdfone.PDFOne; import com.gnostice.pdfone.PdfDocument; import com.gnostice.pdfone.PdfException; import com.gnostice.pdfone.PdfWriter; import com.gnostice.pdfone.encodings.PdfEncodings; import com.gnostice.pdfone.fonts.PdfFont; public class Write_Non_English_Text_To_PDF { static { PDFOne.activate("your-pdfone-activation-key", "your-pdfone-product-key"); } public static void main(String[] args) throws IOException, PdfException { PdfDocument doc = new PdfDocument(); PdfFont fontArial = PdfFont.create("C:\\WINDOWS\\Fonts\\ARIAL.TTF", // font file 10, // font size PdfEncodings.UTF_16BE, // font encoding PdfFont.EMBED_SUBSET); // font embedding PdfFont fontLatha = PdfFont.create("C:\\WINDOWS\\Fonts\\latha.ttf", 10, PdfEncodings.UTF_16BE, PdfFont.EMBED_SUBSET); PdfFont fontArialUnicodeMS = PdfFont.create("C:\\WINDOWS\\Fonts\\ARIALUNI.TTF", 10, PdfEncodings.UTF_16BE, PdfFont.EMBED_SUBSET); PdfFont fontSimHei = PdfFont.create("C:\\WINDOWS\\Fonts\\simhei.ttf", 10, PdfEncodings.UTF_16BE, PdfFont.EMBED_SUBSET); PdfFont fontTunga = PdfFont.create("C:\\WINDOWS\\Fonts\\Tunga.ttf", 10, PdfEncodings.UTF_16BE, PdfFont.EMBED_SUBSET); PdfFont fontMangal = PdfFont.create("C:\\WINDOWS\\Fonts\\mangal.ttf", 10, PdfEncodings.UTF_16BE, PdfFont.EMBED_SUBSET); PdfFont fontKartiga = PdfFont.create("C:\\WINDOWS\\Fonts\\Kartika.ttf", 10, PdfEncodings.UTF_16BE, PdfFont.EMBED_SUBSET); String strFrench = "On leur promettait l'enfer. Mais les Bleus n'ont pas flanché."; String strRussian = "С мая по август на территории Кировской области были "; String strNihongo = "日々の試合、世界意識を サッカー日本代表チーム"; String strMandarin = "多元文化教學 開啟學童大視野"; String strKannada = "ಮಳೆಯ ಹನಿಗಳೊಡನೆ"; String strHindi = "अंग्रेजी का आसमान"; String strMalayalam = "പൈലറ്റുമാരുടെ പണിമുടക്ക് ഗള്ഫ് യാത്രക്കാര് വലയുന്നു"; String strTamizh = "அட்லாண்டாவில் தமிழர் அமைப்பு நடத்திய மருத்துவ முகாம்"; doc.writeText(strFrench, fontArial, 150,50); doc.writeText(strRussian, fontArial, 150,100); doc.writeText(strNihongo, fontArialUnicodeMS, 150,150); doc.writeText(strMandarin, fontSimHei, 150,200); doc.writeText(strKannada, fontTunga, 150,250); doc.writeText(strHindi, fontMangal, 150,300); doc.writeText(strTamizh, fontLatha, 150,350); doc.writeText(strMalayalam, fontKartiga, 150,400); doc.setOpenAfterSave(true); doc.save("Write_Non_English_Text_To_PDF.pdf"); doc.close(); } }
And, here is the PDF output.
French and Russian strings look all right. So, European users should do fine.
Asian users will have to go through a trial-and-error process to find the best font for their language. I got Hindi, Kannada, Chinese and Japanese working all right after trying default fonts installed with Windows and some downloaded from the Internet. Tamil and Malayalam are only ones that are holding out.
---o0O0o---
Our .NET Developer Tools | |
---|---|
Gnostice Document Studio .NETMulti-format document-processing component suite for .NET developers. |
PDFOne .NETA .NET PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, and bookmark PDF documents in .NET applications. |
Our Delphi/C++Builder developer tools | |
---|---|
Gnostice Document Studio DelphiMulti-format document-processing component suite for Delphi/C++Builder developers, covering both VCL and FireMonkey platforms. |
eDocEngine VCLA Delphi/C++Builder component suite for creating documents in over 20 formats and also export reports from popular Delphi reporting tools. |
PDFtoolkit VCLA Delphi/C++Builder component suite to edit, enhance, view, print, merge, split, encrypt, annotate, and bookmark PDF documents. |
Our Java developer tools | |
---|---|
Gnostice Document Studio JavaMulti-format document-processing component suite for Java developers. |
PDFOne (for Java)A Java PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, bookmark PDF documents in Java applications. |
Our Platform-Agnostic Cloud and On-Premises APIs | |
---|---|
StarDocsCloud-hosted and On-Premises REST-based document-processing and document-viewing APIs |
Privacy | Legal | Feedback | Newsletter | Blog | Resellers | © 2002-2024 Gnostice Information Technologies Private Limited. All rights reserved. |