You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Hesham Gneady <he...@gmail.com> on 2019/01/06 09:26:27 UTC

Getting font size of letters

Hello ,

 

In this PDF sample:

https://www.dropbox.com/s/9kpm0jmb6h3mrhy/Font%20Size%20Sample.pdf?dl=0

 

When it try to get the font sizefor any letter it always returns 1.0, using
this code:

public class PDFTextStripperExtender extends PDFTextStripper {

@Override

             public void processTextPosition( TextPosition text )  {

                        System.out.println( "- " + text + ": Font Size: " +
text.getFontSize(); 

            }

}

 

I've also tried "text.getFontSizeInPt()". It returns better values, but
they're not right when compared to Adobe Acrobat font size values.

 

What's the reason for that? And can I get the real size of fonts for each
letter somehow?

 

Best regards,

Hesham 

 



---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

Re: Getting font size of letters

Posted by Tilman Hausherr <TH...@t-online.de>.
Am 06.01.2019 um 18:03 schrieb Hesham Gneady:
>
> Dear Tilman,
>
> Thank you for this. I have tried the DrawPrintTextLocations.java 
> example on 3 PDFs, and I see that the best way to get the display font 
> size for letters in any PDF is by using “text.getXScale()”. Am I right?
>

Yes


Tilman


> I have tried this on the 3 PDFs and it returned right results.
>
> Best regards,
>
> Hesham
>
> --------------------------------------------------------------------------------------------------
>
> Included Message:
>
> The font size is really 1. There are other things that influence the 
> display size, see the javadoc of getFontSizeInPt(). See also the 
> DrawPrintTextLocations.java example.
>
> Tilman
>
> Am 06.01.2019 um 10:26 schrieb Hesham Gneady:
>
>     Hello ,
>
>       
>
>     In this PDF sample:
>
>     https://www.dropbox.com/s/9kpm0jmb6h3mrhy/Font%20Size%20Sample.pdf?dl=0
>
>       
>
>     When it try to get the font sizefor any letter it always returns 1.0, using
>
>     this code:
>
>     public class PDFTextStripperExtender extends PDFTextStripper {
>
>     @Override
>
>                   public void processTextPosition( TextPosition text )  {
>
>                              System.out.println( "- " + text + ": Font Size: " +
>
>     text.getFontSize();
>
>                  }
>
>     }
>
>       
>
>     I've also tried "text.getFontSizeInPt()". It returns better values, but
>
>     they're not right when compared to Adobe Acrobat font size values.
>
>       
>
>     What's the reason for that? And can I get the real size of fonts for each
>
>     letter somehow?
>
>       
>
>     Best regards,
>
>     Hesham
>
>       
>
>     ---
>
>     This email has been checked for viruses by Avast antivirus software.
>
>     https://www.avast.com/antivirus
>
>
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient&utm_term=icon> 
> 	Virus-free. www.avast.com 
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient&utm_term=link> 
>
>
> <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>



RE: Getting font size of letters

Posted by Hesham Gneady <he...@gmail.com>.
Dear Tilman,

 

Thank you for this. I have tried the DrawPrintTextLocations.java example on
3 PDFs, and I see that the best way to get the display font size for letters
in any PDF is by using "text.getXScale()". Am I right?

I have tried this on the 3 PDFs and it returned right results.

 

 

Best regards,

Hesham

 

----------------------------------------------------------------------------
----------------------

Included Message:

 

The font size is really 1. There are other things that influence the display
size, see the javadoc of getFontSizeInPt(). See also the
DrawPrintTextLocations.java example.

 



 

Tilman

 

Am 06.01.2019 um 10:26 schrieb Hesham Gneady:

Hello ,
 
 
 
In this PDF sample:
 
https://www.dropbox.com/s/9kpm0jmb6h3mrhy/Font%20Size%20Sample.pdf?dl=0
 
 
 
When it try to get the font sizefor any letter it always returns 1.0, using
this code:
 
public class PDFTextStripperExtender extends PDFTextStripper {
 
@Override
 
             public void processTextPosition( TextPosition text )  {
 
                        System.out.println( "- " + text + ": Font Size: " +
text.getFontSize(); 
 
            }
 
}
 
 
 
I've also tried "text.getFontSizeInPt()". It returns better values, but
they're not right when compared to Adobe Acrobat font size values.
 
 
 
What's the reason for that? And can I get the real size of fonts for each
letter somehow?
 
 
 
Best regards,
 
Hesham 
 
 
 
 
 
---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
 

 


Re: Getting font size of letters

Posted by Tilman Hausherr <TH...@t-online.de>.
The font size is really 1. There are other things that influence the 
display size, see the javadoc of getFontSizeInPt(). See also the 
DrawPrintTextLocations.java example.


Tilman

Am 06.01.2019 um 10:26 schrieb Hesham Gneady:
> Hello ,
>
>   
>
> In this PDF sample:
>
> https://www.dropbox.com/s/9kpm0jmb6h3mrhy/Font%20Size%20Sample.pdf?dl=0
>
>   
>
> When it try to get the font sizefor any letter it always returns 1.0, using
> this code:
>
> public class PDFTextStripperExtender extends PDFTextStripper {
>
> @Override
>
>               public void processTextPosition( TextPosition text )  {
>
>                          System.out.println( "- " + text + ": Font Size: " +
> text.getFontSize();
>
>              }
>
> }
>
>   
>
> I've also tried "text.getFontSizeInPt()". It returns better values, but
> they're not right when compared to Adobe Acrobat font size values.
>
>   
>
> What's the reason for that? And can I get the real size of fonts for each
> letter somehow?
>
>   
>
> Best regards,
>
> Hesham
>
>   
>
>
>
> ---
> This email has been checked for viruses by Avast antivirus software.
> https://www.avast.com/antivirus
>