Hi -
I’m trying to set the font during pdf generation and I always get Times.
I’ve tried the following:
1.
TextInfo textInfo = new TextInfo();
textInfo.setTruetypeFontFileName(“Arial.ttf”);
textInfo.setIsFontEmbeded(true);
2.
TextInfo textInfo = new TextInfo();
textInfo.setFontName(“Arial”);
textInfo.setIsFontEmbeded(true);
3.
pdf.setDefaultFontName(“Arial”);
Thoughts?
Hello Dave,
Pdf pdf = new Pdf();
// create section object
Section sec = pdf.getSections().add();
// create text object
Text text = new Text(“Hello World in Arial Font…”);
// add text paragraph to paragrapbhs collection of section
sec.getParagraphs().add(text);
// set the font name for text object as Arial
text.getTextInfo().setFontName(“Arial”);
// include the font subset into resultant PDF file
pdf.SetUnicode();
// save resultant PDF document
pdf.save(“d:/pdftest/ArialFontText.pdf”);
Hi -
I tried that exact code on my Mac (OSX Lion) without success. Note, this is a web app.
This does work on Windows. The Mac environment seems to be the problem area. I have not tested Linux as of yet.
Dave
Hello Dave,
We’ve tried Mac and Linux w/o success.
Hello Dave,
sake of correction, I have logged it in our issue tracking system as PDFJAVA-33132. We
will investigate this issue in details and will keep you updated on the status
of a correction.
apologize for your inconvenience.
Hi -
Hello Dave,
Hi -
I wanted to touch base and check on the status of this issue.
Thanks,
Dave
Hello Dave,
java -Daspose.pdf.fontpath=/path/to/fonts -cp aspose.pdf.jdk14.jar;.test.Main
In the above code, you will specify where TrueType fonts are present on Unix/Mac system. In case you still face the same problem, please feel free to contact. We apologize for your inconvenience.
Did not work. I tried this in the past.
Pdf pdf = new Pdf();
pdf.SetUnicode();
pdf.setTruetypeFontDirectoryPath("/Library/Fonts");
…
TextInfo textInfo = new TextInfo();
textInfo.setFontName(“Arial”);
// tried the below line without success too
// textInfo.setTruetypeFontFileName(“Arial.ttf”);
textInfo.setIsFontEmbeded(true);
short colorPattern = 48;
textInfo.setColor(new Color(colorPattern, colorPattern, colorPattern));
textInfo.setFontSize(12);
Dave
Hello Dave,
Pdf pdf = new Pdf();
// create section object
Section sec = pdf.getSections().add();
Text text = new Text(“Hello World in DejaVu Sans Font…”);
// add text paragraph to paragrapbhs collection of section
sec.getParagraphs().add(text);
// set the font name for text object as Arial
text.getTextInfo().setFontName(“DejaVu Sans”);
text.getTextInfo().setTruetypeFontFileName(”/usr/share/fonts/dejavu/DejaVuSans.ttf");
pdf.setTruetypeFontDirectoryPath("/usr/share/fonts/dejavu/");
// include the font subset into resultant PDF file
pdf.SetUnicode();
// save resultant PDF document
pdf.save(“DejaVuSans.pdf”);
I will be taking over for Dave as the point person on this issue. We do use the Pdf.SetUnicode() call. It does not correct the issue. Are the text.getTextInfo().setTruetypeFontFileName(…) and pdf.setTruetypeFontDirectoryPath(…); calls required? The fonts were properly installed into the system.
Hello Steve,LyzaTechops:I will be taking over for Dave as the point person on this issue. We do use the Pdf.SetUnicode() call. It does not correct the issue. Are the text.getTextInfo().setTruetypeFontFileName(....) and pdf.setTruetypeFontDirectoryPath(...); calls required? The fonts were properly installed into the system.
The crux of the issue surrounds usage of:
Hello Steve,
We have pdf.SetUnicode() in our code. But as I indicated usage of the setIsFontEmbedded with a value of true is what is causing the issue. If I remove the line won’t our generated PDF’s no longer contain the embedded fonts? That means that if the user does not have the font specified installed the document will no longer look the same. Correct?
Hi
Steve,
<?xml:namespace prefix = o ns = “urn:schemas-microsoft-com:office:office” /><o:p></o:p>
Your
understanding is correct. If setIsFontEmbedded = true is remove from the code,
the generated PDF file will not contain the embedded fonts (That means if
the user does not have the specified font installed, the document will no longer
look the same). Please give us some time to fix your reported issue. We will
keep you posted regarding any updates via this forum thread.
Sorry
for the inconvenience,
Is this scheduled to be addressed? If so when?