Not using my font

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,


Thanks for using our products.

In order to use and embed the subset of TrueType font inside the resultant PDF document, please try using Pdf.SetUnicode(); method. I have tested the scenario while using following code snippet with Aspose.Pdf for Java 3.1.0 and I am unable to notice any issue. Can you please try using the following code and in case the problem still persists or you have any further query, please feel free to contact. We are sorry for your inconvenience.

[C#]
// create Pdf instance
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,


I am testing this scenario on both MAC and Linux environments and will share my findings shortly. We are sorry for your inconvenience.

We’ve tried Mac and Linux w/o success.

Hello Dave,


I have tested the scenario and I am able to reproduce the same problem. For the
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.

We
apologize for your inconvenience.

Hi -


Do you have an ETA. This is a pretty basic feature and a showstopper for us.

Dave

Hello Dave,


As we just have been able to notice this issue, we require a little time to investigate the reasons of this problem. Yes you are correct. This should not be happening on cross platforms. Nevertheless, we will try our level best to get this issue resolved, ASAP. Soon you will be updated with the status of correction.

Please be patient and spare us little time. We are really sorry for this inconvenience.

Hi -



I wanted to touch base and check on the status of this issue.



Thanks,

Dave

Hello Dave,


Thanks for your patience and sorry for delay in response.

You may consider using the following command to execute the code where you can specify the path where fonts are saved on your system.

java -Daspose.pdf.fontpath=/path/to/fonts -cp aspose.pdf.jdk14.jar;.test.Main

or you can call the following method and specify the path where fonts are placed on your system

pdf.setTruetypeFontDirectoryPath(…);

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,


Thanks for sharing the details.

I just have tested the scenario where I have tried using DejaVu TrueType font installed overRed Hat Enterprise Linux Client release 5.6 (Tikanga) where I have DejaVuSans.ttf installed over /usr/share/fonts/dejavu/ location and I have JRE with following configurations.

java version “1.6.0_21-rev"
Java™ Platform, Standard Edition for Business (build 1.6.0_21-rev-b10)
Java HotSpot™ Client VM (build 17.0-b19, mixed mode)

As per my observations, I have used the following code snippet with Aspose.Pdf for Java 3.1.0 and as per my observations, the font is being embedded inside the PDF file and contents are properly being displayed in DejaVu Sans font.

[Java]
// create Pdf instance
Pdf pdf = new Pdf();
// create section object
Section sec = pdf.getSections().add();

// create text object
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”);

Can you please try using the Pdf.SetUnicode(…) method. In case the problem still persists, please share some details regarding
JDK/JRE and Aspose.Pdf for Java version. We are really sorry for your inconvenience.

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.

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.
Hello Steve,

Please try using both methods as they indicate the font file being referenced and the location where fonts are installed on system. Please try using them and in case you still encounter any issue, please feel free to contact.

The crux of the issue surrounds usage of:


textInfo.setIsFontEmbeded(true);

If this is present, the PDF does not render with the requested font. If I remove that line, I see the font.

suggestions?

Hello Steve,


Thanks for sharing the details.

I have tested the scenario and have managed to reproduce the same problem that when calling TextInfo.setIsFontEmbeded with True argument, the font is not being used during PDF generation. We will further look into the details of this problem and will keep you updated on the status of correction. Please be patient and spare us little time. We are sorry for your inconvenience.

Besides this, as I have suggested earlier, please try using pdf.SetUnicode(); method and ignore TextInfo.setIsFontEmbeded() method.

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?