International characters not showing correctly in Java PDF exportGeneration of PDF from HTML with non-Latin characters using ITextRenderer does not workWhy does a Latin-characters-only Java font claim to support Asian characters, even though it does not?How to use CJK Fonts in iText with XMLWorker on Android?Why is executing Java code in comments with certain Unicode characters allowed?Merge fonts to generate multi locale PDF in JavaHTML to PDF using custom font (Identity-H)PDFBox support multiple character sets including CJKitext XMLWorkerFontProvider.DONTLOOKFORFONTS and generate multi language HTML pageGeneration of Telugu PDF from HTML using ITextRenderer does not getting exact characters?How to set a “backup” font
"It is what it is" in French
I have a domain, static IP address and many devices I'd like to access outside my house. How do I route them?
Why did NASA use Imperial units?
Who controls a summoned steed’s familiar?
Impact of throwing away fruit waste on a peak > 3200 m above a glacier
Is the statement "I/we am/are pressing charges" incorrect?
What is an Eternal Word™?
Why is DC so, so, so Democratic?
dos2unix is unable to convert typescript file to unix format
What happens if an IRB mistakenly approves unethical research?
Why is chess failing to attract big name sponsors?
Can I pay with HKD in Macau or Shenzhen?
Is the apartment I want to rent a scam?
Is it okay to paraphrase other authors' literature reviews?
Is there a way to factor age into the mass-luminosity relationship for stars?
Is it OK to accept a job opportunity while planning on not taking it?
The 50,000 row query limit is not actually a "per APEX call" as widely believed
Sextortion with actual password not found in leaks
How to correct errors in proofs of an accepted paper
How do I run a game when my PCs have different approaches to combat?
what to say when a company asks you why someone (a friend) who was fired left?
Can GPL and BSD licensed applications be used for government work?
Other than a swing wing, what types of variable geometry have flown?
Can 々 stand for a duplicated kanji with a different reading?
International characters not showing correctly in Java PDF export
Generation of PDF from HTML with non-Latin characters using ITextRenderer does not workWhy does a Latin-characters-only Java font claim to support Asian characters, even though it does not?How to use CJK Fonts in iText with XMLWorker on Android?Why is executing Java code in comments with certain Unicode characters allowed?Merge fonts to generate multi locale PDF in JavaHTML to PDF using custom font (Identity-H)PDFBox support multiple character sets including CJKitext XMLWorkerFontProvider.DONTLOOKFORFONTS and generate multi language HTML pageGeneration of Telugu PDF from HTML using ITextRenderer does not getting exact characters?How to set a “backup” font
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am trying to export chinese/japanese characters AND polish characters to a pdf. But only one of both works, not both, and I don't understand why.
Here is the program:
public class Japanese {
public static void main(String[] args) throws Exception
StringBuffer writer = new StringBuffer();
writer.append("<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1?DTD/transitional.dtd">n" +
"<html>n" +
"<head>n" +
"<META http-equiv="Content-Type" content="text/html; charset=UTF-8" />n" +
"<title>some title.</title>n" +
"n" +
"<style type="text/css">n" +
" .myDivn" +
" n" +
" font-family: "Noto Sans CJK TC Regular", Sans-Serif;n" +
" n" +
"</style>n" +
"</head>n" +
"<body> <div class="myDiv">" +
"Chinese: 百威英博雪津(三明)啤酒有限公司 <br />" +
"Japanese: 日本にほんでは、近頃ちかごろ多おおくの人ひとが保育園ほいくえん問題もんだいについて話はなしている。 <br />" +
"Polish: ąćęł <br />" +
"German: TüööäE_3STß <br />" +
"Hello World: 你好,世界 <br />" +
"n" +
" <br />n" +
"n" +
"END TEXTn</div>" +
"<br />n" +
"<br />n" +
"</body></html>");
String pdfContent = writer.toString();
ITextRenderer renderer = new ITextRenderer();
ITextFontResolver resolver = renderer.getFontResolver();
resolver.addFont("lib/NotoSans-Regular.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
resolver.addFont("lib/NotoSansCJKtc-Regular.otf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
renderer.setDocumentFromString(pdfContent);
renderer.layout();
FileOutputStream os = new FileOutputStream("output.pdf");
renderer.createPDF(os);
System.out.println("Finished");
The program above creates a pdf with correct japanese/chinese characters. For this, I leave this line as it is:
" font-family: "Noto Sans CJK TC Regular", Sans-Serif;n" +
But the polish characters are not shown, only the japanese/chinese. If I change the line above to:
" font-family: "Noto Sans", Sans-Serif;n" +
then the chinese/japanese are not shown, only the polish.
I would expect that with this line, both would be shown correctly:
" font-family: "Noto Sans", "Noto Sans CJK TC Regular", Sans-Serif;n" +
But only the polish characters are shown correctly. Here: https://www.google.com/get/noto/help/guidelines/ it is stated, that this is the correct way to achieve this:
font-family: "Noto Sans", "Noto Sans CJK JP", sans-serif;
So why is this not working?
I am using the following libraries:
- flying-saucer-core-9.0.8.jar
- flying-saucer-pdf-9.0.8.jar
- itext-2.1.7.jar
Any idea why this may be happening?
java itext flying-saucer
add a comment |
I am trying to export chinese/japanese characters AND polish characters to a pdf. But only one of both works, not both, and I don't understand why.
Here is the program:
public class Japanese {
public static void main(String[] args) throws Exception
StringBuffer writer = new StringBuffer();
writer.append("<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1?DTD/transitional.dtd">n" +
"<html>n" +
"<head>n" +
"<META http-equiv="Content-Type" content="text/html; charset=UTF-8" />n" +
"<title>some title.</title>n" +
"n" +
"<style type="text/css">n" +
" .myDivn" +
" n" +
" font-family: "Noto Sans CJK TC Regular", Sans-Serif;n" +
" n" +
"</style>n" +
"</head>n" +
"<body> <div class="myDiv">" +
"Chinese: 百威英博雪津(三明)啤酒有限公司 <br />" +
"Japanese: 日本にほんでは、近頃ちかごろ多おおくの人ひとが保育園ほいくえん問題もんだいについて話はなしている。 <br />" +
"Polish: ąćęł <br />" +
"German: TüööäE_3STß <br />" +
"Hello World: 你好,世界 <br />" +
"n" +
" <br />n" +
"n" +
"END TEXTn</div>" +
"<br />n" +
"<br />n" +
"</body></html>");
String pdfContent = writer.toString();
ITextRenderer renderer = new ITextRenderer();
ITextFontResolver resolver = renderer.getFontResolver();
resolver.addFont("lib/NotoSans-Regular.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
resolver.addFont("lib/NotoSansCJKtc-Regular.otf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
renderer.setDocumentFromString(pdfContent);
renderer.layout();
FileOutputStream os = new FileOutputStream("output.pdf");
renderer.createPDF(os);
System.out.println("Finished");
The program above creates a pdf with correct japanese/chinese characters. For this, I leave this line as it is:
" font-family: "Noto Sans CJK TC Regular", Sans-Serif;n" +
But the polish characters are not shown, only the japanese/chinese. If I change the line above to:
" font-family: "Noto Sans", Sans-Serif;n" +
then the chinese/japanese are not shown, only the polish.
I would expect that with this line, both would be shown correctly:
" font-family: "Noto Sans", "Noto Sans CJK TC Regular", Sans-Serif;n" +
But only the polish characters are shown correctly. Here: https://www.google.com/get/noto/help/guidelines/ it is stated, that this is the correct way to achieve this:
font-family: "Noto Sans", "Noto Sans CJK JP", sans-serif;
So why is this not working?
I am using the following libraries:
- flying-saucer-core-9.0.8.jar
- flying-saucer-pdf-9.0.8.jar
- itext-2.1.7.jar
Any idea why this may be happening?
java itext flying-saucer
add a comment |
I am trying to export chinese/japanese characters AND polish characters to a pdf. But only one of both works, not both, and I don't understand why.
Here is the program:
public class Japanese {
public static void main(String[] args) throws Exception
StringBuffer writer = new StringBuffer();
writer.append("<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1?DTD/transitional.dtd">n" +
"<html>n" +
"<head>n" +
"<META http-equiv="Content-Type" content="text/html; charset=UTF-8" />n" +
"<title>some title.</title>n" +
"n" +
"<style type="text/css">n" +
" .myDivn" +
" n" +
" font-family: "Noto Sans CJK TC Regular", Sans-Serif;n" +
" n" +
"</style>n" +
"</head>n" +
"<body> <div class="myDiv">" +
"Chinese: 百威英博雪津(三明)啤酒有限公司 <br />" +
"Japanese: 日本にほんでは、近頃ちかごろ多おおくの人ひとが保育園ほいくえん問題もんだいについて話はなしている。 <br />" +
"Polish: ąćęł <br />" +
"German: TüööäE_3STß <br />" +
"Hello World: 你好,世界 <br />" +
"n" +
" <br />n" +
"n" +
"END TEXTn</div>" +
"<br />n" +
"<br />n" +
"</body></html>");
String pdfContent = writer.toString();
ITextRenderer renderer = new ITextRenderer();
ITextFontResolver resolver = renderer.getFontResolver();
resolver.addFont("lib/NotoSans-Regular.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
resolver.addFont("lib/NotoSansCJKtc-Regular.otf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
renderer.setDocumentFromString(pdfContent);
renderer.layout();
FileOutputStream os = new FileOutputStream("output.pdf");
renderer.createPDF(os);
System.out.println("Finished");
The program above creates a pdf with correct japanese/chinese characters. For this, I leave this line as it is:
" font-family: "Noto Sans CJK TC Regular", Sans-Serif;n" +
But the polish characters are not shown, only the japanese/chinese. If I change the line above to:
" font-family: "Noto Sans", Sans-Serif;n" +
then the chinese/japanese are not shown, only the polish.
I would expect that with this line, both would be shown correctly:
" font-family: "Noto Sans", "Noto Sans CJK TC Regular", Sans-Serif;n" +
But only the polish characters are shown correctly. Here: https://www.google.com/get/noto/help/guidelines/ it is stated, that this is the correct way to achieve this:
font-family: "Noto Sans", "Noto Sans CJK JP", sans-serif;
So why is this not working?
I am using the following libraries:
- flying-saucer-core-9.0.8.jar
- flying-saucer-pdf-9.0.8.jar
- itext-2.1.7.jar
Any idea why this may be happening?
java itext flying-saucer
I am trying to export chinese/japanese characters AND polish characters to a pdf. But only one of both works, not both, and I don't understand why.
Here is the program:
public class Japanese {
public static void main(String[] args) throws Exception
StringBuffer writer = new StringBuffer();
writer.append("<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1?DTD/transitional.dtd">n" +
"<html>n" +
"<head>n" +
"<META http-equiv="Content-Type" content="text/html; charset=UTF-8" />n" +
"<title>some title.</title>n" +
"n" +
"<style type="text/css">n" +
" .myDivn" +
" n" +
" font-family: "Noto Sans CJK TC Regular", Sans-Serif;n" +
" n" +
"</style>n" +
"</head>n" +
"<body> <div class="myDiv">" +
"Chinese: 百威英博雪津(三明)啤酒有限公司 <br />" +
"Japanese: 日本にほんでは、近頃ちかごろ多おおくの人ひとが保育園ほいくえん問題もんだいについて話はなしている。 <br />" +
"Polish: ąćęł <br />" +
"German: TüööäE_3STß <br />" +
"Hello World: 你好,世界 <br />" +
"n" +
" <br />n" +
"n" +
"END TEXTn</div>" +
"<br />n" +
"<br />n" +
"</body></html>");
String pdfContent = writer.toString();
ITextRenderer renderer = new ITextRenderer();
ITextFontResolver resolver = renderer.getFontResolver();
resolver.addFont("lib/NotoSans-Regular.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
resolver.addFont("lib/NotoSansCJKtc-Regular.otf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
renderer.setDocumentFromString(pdfContent);
renderer.layout();
FileOutputStream os = new FileOutputStream("output.pdf");
renderer.createPDF(os);
System.out.println("Finished");
The program above creates a pdf with correct japanese/chinese characters. For this, I leave this line as it is:
" font-family: "Noto Sans CJK TC Regular", Sans-Serif;n" +
But the polish characters are not shown, only the japanese/chinese. If I change the line above to:
" font-family: "Noto Sans", Sans-Serif;n" +
then the chinese/japanese are not shown, only the polish.
I would expect that with this line, both would be shown correctly:
" font-family: "Noto Sans", "Noto Sans CJK TC Regular", Sans-Serif;n" +
But only the polish characters are shown correctly. Here: https://www.google.com/get/noto/help/guidelines/ it is stated, that this is the correct way to achieve this:
font-family: "Noto Sans", "Noto Sans CJK JP", sans-serif;
So why is this not working?
I am using the following libraries:
- flying-saucer-core-9.0.8.jar
- flying-saucer-pdf-9.0.8.jar
- itext-2.1.7.jar
Any idea why this may be happening?
java itext flying-saucer
java itext flying-saucer
asked Mar 26 at 15:14
eduedu
86 bronze badges
86 bronze badges
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55360556%2finternational-characters-not-showing-correctly-in-java-pdf-export%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55360556%2finternational-characters-not-showing-correctly-in-java-pdf-export%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown