You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2009/12/20 16:07:46 UTC

DO NOT REPLY [Bug 48415] New: HSSFPicture.resize() works incorrectly if default font size changed

https://issues.apache.org/bugzilla/show_bug.cgi?id=48415

           Summary: HSSFPicture.resize() works incorrectly if default font
                    size changed
           Product: POI
           Version: 3.5-FINAL
          Platform: PC
        OS/Version: Windows Server 2003
            Status: NEW
          Severity: normal
          Priority: P2
         Component: HSSF
        AssignedTo: dev@poi.apache.org
        ReportedBy: gweii@hotmail.com


Test steps:

1.1 Use Excel to new an Excel workbook
1.2 Save and close the workbook as Book1.xls
1.3 Use POI to open Book1.xls and insert an image
1.4 Call HSSFPicture.resize()
1.5 Save and close Book1.xls

2.1 Use Excel to new an Excel workbook
2.2 Modify the default font size (For example, from 10 to 20)
2.3 Save and close the workbook as Book2.xls
2.4 Use POI to open Book2.xls and insert the same image used in the previous
test
2.5 Call HSSFPicture.resize()
2.6 Save and close Book2.xls

Then use Excel to open these two workbooks, you can see the same image in these
workbooks do NOT have the same size! The later one stretchs horizontally!

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 48415] HSSFPicture.resize() works incorrectly if default font size changed

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=48415

Yegor Kozlov <ye...@dinom.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WONTFIX

--- Comment #1 from Yegor Kozlov <ye...@dinom.ru> 2009-12-21 08:30:03 UTC ---
I'm re-posting my reply from poi-user:

HSSFPicture.resize() as well as XSSFPicture.resize() indeed work only for the
default font which is Arial 10pt for .xls and Calibri 11pt for .xlsx.

Excel uses a funny coordinate system to position graphic objects. X and Y axes 
are measured not in pixels but in units proportional to a character width of
the default font. To properly position and size an image POI needs to translate
the actual dimensions measured in pixels to columns and rows. This is the key
of the problem. At the moment POI performs this translation using hardcoded
constants obtained empirically for Arial 10pt and Calibri 11pt. It works OK in
most cases and also explains why HSSFPicture.resize() is 'off' if the default
font is changed.

Unfortunately it can not be easily fixed. To measure a custom font POI needs to
load it (i.e. the font must be physically available) and get the font metrics
using java.awt.* utilities. It will make the result machine dependent and
impossible to test.

I updated the javadocs on HSSFPicture.resize()  to reflect it. 

Yegor

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org