You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by bu...@apache.org on 2006/07/14 19:42:47 UTC

DO NOT REPLY [Bug 40048] New: - When using AWTRenderer for printing of document incorrect imageable area is specified in java.awt.print.PageFormat

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=40048>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=40048

           Summary: When using AWTRenderer for printing of document
                    incorrect imageable area is specified in
                    java.awt.print.PageFormat
           Product: Fop
           Version: 0.92
          Platform: Other
        OS/Version: other
            Status: NEW
          Severity: major
          Priority: P2
         Component: awt renderer
        AssignedTo: fop-dev@xmlgraphics.apache.org
        ReportedBy: iistomin@ciklum.net


The AWTRenderer.getPageFormat(int) method returns incorrect PageFormat. The
PageFormat contains incorrect imageable area. According to source code imageable
area should be (0, 0, page-width, page-height) but result PageFormat contains
another values.

After analyzing of source code of PageFormat it was determined that
PageFormat.setPaper(Paper) method clones passed Paper and stores reference to
new instance. IMHO, the reason of the bug is that AWTRenderer.getPageFormat(int)
invokes PageFormat.setPaper(Paper) method BEFORE applying of imageable area to
the Paper and as consequence PageFormat clones Paper with default imageable
area. That  is, imageable area is applied to another (original, not cloned)
instance of Paper.

The correct code should look like this:

public java.awt.print.PageFormat getPageFormat(int pageIndex)
throws IndexOutOfBoundsException {
	        try {
	            if (pageIndex >= getNumberOfPages()) {
	                return null;
	            }
	    
	            PageFormat pageFormat = new PageFormat();
	    
	            Paper paper = new Paper();
	    
	            Rectangle2D dim = getPageViewport(pageIndex).getViewArea();
	            double width = dim.getWidth();
	            double height = dim.getHeight();
	    
	            // if the width is greater than the height assume lanscape mode
	            // and swap the width and height values in the paper format
	            if (width > height) {
	                paper.setImageableArea(0, 0, height / 1000d, width / 1000d);
	                paper.setSize(height / 1000d, width / 1000d);
	                pageFormat.setOrientation(PageFormat.LANDSCAPE);
	            } else {
	                paper.setImageableArea(0, 0, width / 1000d, height / 1000d);
	                paper.setSize(width / 1000d, height / 1000d);
	                pageFormat.setOrientation(PageFormat.PORTRAIT);
	            }

                    // Set Paper AFTER applying of imageable area.
	            pageFormat.setPaper(paper);

	            return pageFormat;
	        } catch (FOPException fopEx) {
	            throw new IndexOutOfBoundsException(fopEx.getMessage());
	        }
}

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

DO NOT REPLY [Bug 40048] - When using AWTRenderer for printing of document incorrect imageable area is specified in java.awt.print.PageFormat

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=40048>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=40048


jeremias@apache.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jeremias@apache.org




------- Additional Comments From jeremias@apache.org  2006-07-24 08:49 -------
*** Bug 38714 has been marked as a duplicate of this bug. ***

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

DO NOT REPLY [Bug 40048] - When using AWTRenderer for printing of document incorrect imageable area is specified in java.awt.print.PageFormat

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=40048>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=40048


jeremias@apache.org changed:

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




------- Additional Comments From jeremias@apache.org  2006-07-24 08:50 -------
Fixed: http://svn.apache.org/viewvc?rev=424966&view=rev

Thanks for the hint.

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