You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Florian Gumpinger <ve...@gmail.com> on 2021/04/29 06:07:00 UTC

using java.awt.Font

Hello!



I want to create a PDF file with text. The language of the text is
depending on the language-settings in the application. The application
supports many languages … also Chinese, Korean etc. So I cannot work with
one font. In the application i have now the font as java.awt.Font
available. Is there a way to use this direct? For example something like



          contentStream.setFont((PDFont) [java.awt.Font], 10);



or a way to create this with something similar like



          PDFont font = PDTrueTypeFont.loadTTF(doc, [java.awt.Font]);



?



Yours

Florian

Re: using java.awt.Font

Posted by Tilman Hausherr <TH...@t-online.de>.
Am 29.04.2021 um 08:26 schrieb Florian Gumpinger:
> Please excuse ... and another question ... what do you mean with "complex
> scripts (Indian, Arabic)" is not supported? Is there somewhere an info what
> is supported and what not?

Indian, Arabic, Thai replace glyphs based on the position. Arabic is 
right to left. There is no info (there was a warning in the past, but 
people got confused because the warning came also for normal fonts,  
because of the support of ligatures). If it looks crappy, then you'll 
know it isn't supported.

Chinese, Korean and Japanese is supported.

Tilman



>
> Yours
> Florian
>
> Am Do., 29. Apr. 2021 um 08:09 Uhr schrieb Tilman Hausherr <
> THausherr@t-online.de>:
>
>> Hi,
>>
>> See the EmbeddedMultipleFonts.java example in the source code download.
>> java.awt.Font is not supported, nor are complex scripts (Indian, Arabic)
>>
>> Tilman
>>
>> Am 29.04.2021 um 08:07 schrieb Florian Gumpinger:
>>> Hello!
>>>
>>>
>>>
>>> I want to create a PDF file with text. The language of the text is
>>> depending on the language-settings in the application. The application
>>> supports many languages … also Chinese, Korean etc. So I cannot work with
>>> one font. In the application i have now the font as java.awt.Font
>>> available. Is there a way to use this direct? For example something like
>>>
>>>
>>>
>>>             contentStream.setFont((PDFont) [java.awt.Font], 10);
>>>
>>>
>>>
>>> or a way to create this with something similar like
>>>
>>>
>>>
>>>             PDFont font = PDTrueTypeFont.loadTTF(doc, [java.awt.Font]);
>>>
>>>
>>>
>>> ?
>>>
>>>
>>>
>>> Yours
>>>
>>> Florian
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Re: using java.awt.Font

Posted by Florian Gumpinger <ve...@gmail.com>.
Please excuse ... and another question ... what do you mean with "complex
scripts (Indian, Arabic)" is not supported? Is there somewhere an info what
is supported and what not?

Yours
Florian

Am Do., 29. Apr. 2021 um 08:09 Uhr schrieb Tilman Hausherr <
THausherr@t-online.de>:

> Hi,
>
> See the EmbeddedMultipleFonts.java example in the source code download.
> java.awt.Font is not supported, nor are complex scripts (Indian, Arabic)
>
> Tilman
>
> Am 29.04.2021 um 08:07 schrieb Florian Gumpinger:
> > Hello!
> >
> >
> >
> > I want to create a PDF file with text. The language of the text is
> > depending on the language-settings in the application. The application
> > supports many languages … also Chinese, Korean etc. So I cannot work with
> > one font. In the application i have now the font as java.awt.Font
> > available. Is there a way to use this direct? For example something like
> >
> >
> >
> >            contentStream.setFont((PDFont) [java.awt.Font], 10);
> >
> >
> >
> > or a way to create this with something similar like
> >
> >
> >
> >            PDFont font = PDTrueTypeFont.loadTTF(doc, [java.awt.Font]);
> >
> >
> >
> > ?
> >
> >
> >
> > Yours
> >
> > Florian
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>
>

Re: using java.awt.Font

Posted by Tilman Hausherr <TH...@t-online.de>.
Am 29.04.2021 um 08:19 schrieb Florian Gumpinger:
> Sadly this does not help. I only have a java.awt.Font object and do not
> know from which font-file it comes from. So i cannot load this files. And i
> only have one font per PDF ... so i do not need to load multiple fonts at
> once ... but i need a hint how to solve this with java.awt.Font ... or a
> way how i can figure out the font-file to a java.awt.Font object ... Name
> of font does not help ... i tried already but the name of the font is not
> always like the filename.

Getting the name / location of an java.awt.Font is tricky and depends on 
the jdk version and it uses internal sun.* classes. You need to use the 
debugger, then cast to the actual object, see what methods are 
available, etc. I tried this years ago and after a few hours I had the 
file name.

You could try to use https://github.com/rototor/pdfbox-graphics2d . This 
is on top of PDFBox, we have nice contacts with the developer and he's 
great.

Tilman



>
> Yours
> Florian
>
> Am Do., 29. Apr. 2021 um 08:09 Uhr schrieb Tilman Hausherr <
> THausherr@t-online.de>:
>
>> Hi,
>>
>> See the EmbeddedMultipleFonts.java example in the source code download.
>> java.awt.Font is not supported, nor are complex scripts (Indian, Arabic)
>>
>> Tilman
>>
>> Am 29.04.2021 um 08:07 schrieb Florian Gumpinger:
>>> Hello!
>>>
>>>
>>>
>>> I want to create a PDF file with text. The language of the text is
>>> depending on the language-settings in the application. The application
>>> supports many languages … also Chinese, Korean etc. So I cannot work with
>>> one font. In the application i have now the font as java.awt.Font
>>> available. Is there a way to use this direct? For example something like
>>>
>>>
>>>
>>>             contentStream.setFont((PDFont) [java.awt.Font], 10);
>>>
>>>
>>>
>>> or a way to create this with something similar like
>>>
>>>
>>>
>>>             PDFont font = PDTrueTypeFont.loadTTF(doc, [java.awt.Font]);
>>>
>>>
>>>
>>> ?
>>>
>>>
>>>
>>> Yours
>>>
>>> Florian
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org


Re: using java.awt.Font

Posted by Florian Gumpinger <ve...@gmail.com>.
Sadly this does not help. I only have a java.awt.Font object and do not
know from which font-file it comes from. So i cannot load this files. And i
only have one font per PDF ... so i do not need to load multiple fonts at
once ... but i need a hint how to solve this with java.awt.Font ... or a
way how i can figure out the font-file to a java.awt.Font object ... Name
of font does not help ... i tried already but the name of the font is not
always like the filename.

Yours
Florian

Am Do., 29. Apr. 2021 um 08:09 Uhr schrieb Tilman Hausherr <
THausherr@t-online.de>:

> Hi,
>
> See the EmbeddedMultipleFonts.java example in the source code download.
> java.awt.Font is not supported, nor are complex scripts (Indian, Arabic)
>
> Tilman
>
> Am 29.04.2021 um 08:07 schrieb Florian Gumpinger:
> > Hello!
> >
> >
> >
> > I want to create a PDF file with text. The language of the text is
> > depending on the language-settings in the application. The application
> > supports many languages … also Chinese, Korean etc. So I cannot work with
> > one font. In the application i have now the font as java.awt.Font
> > available. Is there a way to use this direct? For example something like
> >
> >
> >
> >            contentStream.setFont((PDFont) [java.awt.Font], 10);
> >
> >
> >
> > or a way to create this with something similar like
> >
> >
> >
> >            PDFont font = PDTrueTypeFont.loadTTF(doc, [java.awt.Font]);
> >
> >
> >
> > ?
> >
> >
> >
> > Yours
> >
> > Florian
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>
>

Re: using java.awt.Font

Posted by Tilman Hausherr <TH...@t-online.de>.
Hi,

See the EmbeddedMultipleFonts.java example in the source code download. 
java.awt.Font is not supported, nor are complex scripts (Indian, Arabic)

Tilman

Am 29.04.2021 um 08:07 schrieb Florian Gumpinger:
> Hello!
>
>
>
> I want to create a PDF file with text. The language of the text is
> depending on the language-settings in the application. The application
> supports many languages … also Chinese, Korean etc. So I cannot work with
> one font. In the application i have now the font as java.awt.Font
> available. Is there a way to use this direct? For example something like
>
>
>
>            contentStream.setFont((PDFont) [java.awt.Font], 10);
>
>
>
> or a way to create this with something similar like
>
>
>
>            PDFont font = PDTrueTypeFont.loadTTF(doc, [java.awt.Font]);
>
>
>
> ?
>
>
>
> Yours
>
> Florian
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org