| Author |
Message |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 17/08/2010 00:35:49
|
chstapfer
Joined: 18/06/2010 09:49:03
Messages: 8
Offline
|
ICEpdf-core 4.1.0 cannot determine the font name (Times-Roman) of the font contained in the attached PDF correctly. Instead of the correct name, which is "Times-Roman", font.getName() gives me the nonsensical generic label "FontName".
Why is it, that ICEpdf cannot determine the real name of the font while Acrobat Reader, for example, can do it?
| Filename |
FontName-Test.pdf |
Download
|
| Description |
ICEpdf cannot determine the name of the font (Times-Roman) contained in this file. Why? |
| Filesize |
4 Kbytes
|
| Downloaded: |
56 time(s) |
|
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 17/08/2010 15:05:07
|
patrick.corless
Joined: 26/10/2004 00:00:00
Messages: 1097
Online
|
Just poked around the code a bit an there appears to be a bug in org.icepdf.core.pobjects.fonts.ofont.Font.java and FontDescriptor.java which is responsible for the "fontName" value.
The value will effect font substitution in a small percentage of files. The good news is that the fix is very easy. http://jira.icefaces.org/browse/PDF-204
Can you give more information on how you plan to use the font name? Do you want the font name as specified in the PDF or do you want the name of the font used to render the content?
|
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 17/08/2010 23:21:24
|
chstapfer
Joined: 18/06/2010 09:49:03
Messages: 8
Offline
|
patrick.corless wrote:
Just poked around the code a bit an there appears to be a bug in org.icepdf.core.pobjects.fonts.ofont.Font.java and FontDescriptor.java which is responsible for the "fontName" value.
The value will effect font substitution in a small percentage of files. The good news is that the fix is very easy. http://jira.icefaces.org/browse/PDF-204
Can you give more information on how you plan to use the font name? Do you want the font name as specified in the PDF or do you want the name of the font used to render the content?
Thank you for your reply!
I use the font name to generate XAML from the PDF. XAML does the font rendering all by itself. All I need to tell it is where the font file happens to be (I can do that if I get the right font name). This works for many of the PDF files that I want to convert (I have already converted hundreds of PDF documents this way: those are documents of a database of math exercises with worked solutions - where each exercise / solution is a separate document). Especially it works with PDFs that I have created with the help of pdftex and pdflatex (tools of the TeX family) and the public fonts that are distributed along with TeX. It does not always seem to work with PDFs that refer to certain fonts, like Times, and/or (possibly) PDFs that have not been generated by pdftex/pdflatex.
I certainly would like to get the font name as defined in the PDF, since, as I wrote, my program does not have to bother about rendering fonts at all. Admittedly, my application is rather special. Therefore, I certainly would not recommend that you modify the behavior of ICEpdf in a direction that suits my PDF to XAML converter, but with which you do not feel comfortable yourself.
Thanks,
Christian
|
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 18/08/2010 07:48:00
|
patrick.corless
Joined: 26/10/2004 00:00:00
Messages: 1097
Online
|
Good to hear that your making good progress on your project. For some reason even when I correct the basefont name issue we end up changing the base font to what ever font name was found on the system. As a result you'll have to query the font dictionary again to get the original base font name. The snippet would look like this.
Code:
Hashtable dictionary = font.getEntries();
if (entries.containsKey("BaseFont")) {
Object o = entries.get("BaseFont");
if (o instanceof Name) {
basefont = ((Name) o).getName();
}else if (o instanceof Name){
basefont = (String) o;
}
}
|
|
|
 |
![[Post New]](/JForum/templates/default/images/icon_minipost_new.gif) 18/08/2010 09:20:14
|
chstapfer
Joined: 18/06/2010 09:49:03
Messages: 8
Offline
|
patrick.corless wrote:
The snippet would look like this.
Code:
Hashtable dictionary = font.getEntries();
if (entries.containsKey("BaseFont")) {
Object o = entries.get("BaseFont");
if (o instanceof Name) {
basefont = ((Name) o).getName();
}else if (o instanceof Name){
basefont = (String) o;
}
}
Thank you very much for this snippet.
It is quite possible that I (or, rather, my converter) can even live with the font name that your modification is going to deliver. Although, if it's strongly dependent on the system on which the converter is running, that would perhaps not be so great. In that case I would likely try to take advantage of the basename lookup that you have suggested.
|
|
|
 |
|
|