Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 241194

Summary: [Improve Report Layout Capabilities] Incorrect image size in generated pdf
Product: z_Archived Reporter: Ming Gu <gumingbj>
Component: BIRTAssignee: Birt-Report-inbox <Birt-Report-inbox>
Status: VERIFIED DUPLICATE QA Contact: Tianli Zhang <tzhang>
Severity: normal    
Priority: P1 CC: bxu, gumingbj, henning, hustlg, huxd, jonathanerlich, wangjunl, wenfeng.fwd, wyan
Version: 2.2.1Keywords: plan
Target Milestone: 2.5.0 M5   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
report project and pdf files generated by BIRT2.2.0 and BIRT2.2.1
none
birt 2.2.1 output
none
birt 2.2.2 output
none
patch for birt 2.2.2 none

Description Ming Gu CLA 2008-07-17 02:57:49 EDT
In both 2.2.1 and 2.2.2 version, BIRT can not process height and width
attribute of image correctly, and this defect does not exist in BIRT2.2.0.

This defect can be reproduced by folowing steps:
1. New a rptdesign file 
2. Insert a Text element into BODY
3. Set the content of Text as <img src="dist1.gif" height="456"  width="594" 
/>, 594*456 is the original size of "dist1.gif".
4. View report as pdf, the image size is not as we set before, and bigger than
594*456.

We do not insert the image into a html table, and we just insert it into 'Text'. The report project and the pdfs generated by BIRT are in attachment.
Comment 1 Ming Gu CLA 2008-07-17 02:59:58 EDT
Created attachment 107699 [details]
report project and pdf files generated by BIRT2.2.0 and BIRT2.2.1
Comment 2 Gang Liu CLA 2008-07-17 04:29:38 EDT
Created attachment 107704 [details]
birt 2.2.1 output

birt 2.2.1 output
Comment 3 Gang Liu CLA 2008-07-17 04:30:09 EDT
Created attachment 107706 [details]
birt 2.2.2 output
Comment 4 Gang Liu CLA 2008-07-17 04:53:32 EDT
I had checked out three version (2.2.0, 2.2.2 and 2.2.2)of birt, and previewed this report. it's the same for birt 2.2.0, but different in 2.2.1.
Please refer to my attachment. 
it seems the master page was changed in your second case, and it is generated in 2.2.2 instead of 2.2.1.

In birt 2.2.0, when the image size exceeds the page body size, it will be scaled to fit the page. so it looks smaller in 2.2.0 than 2.2.1. You can insert a large image to check this feature. but this behavior is not correct, BIRT should never change the user's setting. This bug had been fixed in 2.2.1. when the image size exceeds page size, it will be clipped.

Now i try to explain why this image looks bigger in PDF than in html.
In html, browser always use the screen resolution to display the image.
In PDF, birt2.2.x use 72 DPI to generate PDF file.
So if the screen resolution is 72 DPI, it looks the same.
if the screen resolution is 96 or 120 DPI, it looks bigger in pdf.

User want the same size in PDF and html, there are two choice:
1. set an absolute size (in, cm, pt etc) for image.
2. set resolution in PDF render option (This feature is not supported in birt2.2.x,  need add a patch to support.)

what is your suggestion?

Thanks
Comment 5 Hu Xiang Dong CLA 2008-07-17 06:51:25 EDT
About the feature in 2.2.0 that "when the image size exceeds the page body size, it will be scaled to fit the page", this is good feature to us, not sure why you think its a bug?
Can we pull that feature back? Or at least, provide some options and allow users to make their own decision?

And, is it feasible for BIRT to use current screen resolution when generating PDF? That's more reasonable than hard coded resolution.
Comment 6 Gang Liu CLA 2008-07-18 03:18:35 EDT
we can not use current screen resolution. For example, if user deploys report engine to a server and preview PDF report in another client, then birt use the screen resolution of server to generate PDF report. 

For the feature of scaling large image, please refer to bug #240805
Comment 7 Wenfeng Li CLA 2008-07-18 12:50:43 EDT
(In reply to comment #6)
> we can not use current screen resolution. For example, if user deploys report
> engine to a server and preview PDF report in another client, then birt use the
> screen resolution of server to generate PDF report. 
> For the feature of scaling large image, please refer to bug #240805

If the image is an image tag in the HTML text report item, how to set the max size property?   Are we going to have the DPI issue if the max size setting uses px as unit?

For 2.2.x, how about change the default dpi to 120 and also add a dpi setting for  the pdf emitter plugin?   

Comment 8 Wenfeng Li CLA 2008-07-18 13:06:55 EDT
(In reply to comment #5)
> About the feature in 2.2.0 that "when the image size exceeds the page body
> size, it will be scaled to fit the page", this is good feature to us, not sure
> why you think its a bug?

It is a bug since the image tag has size attributes, so BIRT engine would calculate the image size based on the size setting in the report.  The issue is the DPI used to calculate the size needs to be adjusted.  size = px / dpi.

For image report item (not html text item), birt can support scale to container to avoid clipping of image.   But since this is an image in a generic html text item, the scaling needs to be applied to the entire html div, which is not currently supported.   One possible solution is to add a setting of fit-to-container property on the entire html text item, if this setting is set to true, images in the html item will be scale to fit in the container width/size.  I suggest we add this feature in 2.5.   
Comment 9 Bingxue Xu CLA 2008-07-18 20:50:36 EDT
>If the image is an image tag in the HTML text report item, how to set the max
>size property?   Are we going to have the DPI issue if the max size setting
>uses px as unit?

whatever you did in BIRT 2.2.0 seems work fine, could you please do the smaething?

>For 2.2.x, how about change the default dpi to 120 and also add a dpi setting
>for  the pdf emitter plugin?   
 
We don't mind adding an extra setting at all. Please at least restore the working behaviour in 2.2.0 back into 2.2.2, making it an option is OK. This is a blocking bug for our application, i.e. show stopper.
Comment 10 Gang Liu CLA 2008-07-21 23:03:52 EDT
After discussing, we will make the following changes:
Add a render option to control the image layout behaviour. The default behavour is the same with 2.2.0, when image size exceeds the container size, it will be scaled to container size. And user also can change this option to make the image clipped.
Comment 11 Bingxue Xu CLA 2008-07-22 13:00:06 EDT
Thanks very much for the proposed change and really appreciated all the help and support from you in dealing with the PDF issues.
Comment 12 Bingxue Xu CLA 2008-08-04 03:26:35 EDT
As Gang Liu and I exchnage the proposal on this issue, a patch that can be applied to 2.2.2 which restores the same behaviour as in 2.2.0 with a new settting/option will be fine. 

Thanks very much for you help.
Comment 13 Gang Liu CLA 2008-08-04 23:00:06 EDT
Created attachment 109113 [details]
patch for birt 2.2.2
Comment 14 Gang Liu CLA 2008-08-04 23:01:09 EDT
add a patch on birt2.2.2 for this issue. The patch will restore the behavior of 2.2.0, image will be scaled if exceeding container size
Comment 15 Gang Liu CLA 2008-08-04 23:04:02 EDT
*** Bug 240468 has been marked as a duplicate of this bug. ***
Comment 16 Gang Liu CLA 2008-08-04 23:09:47 EDT
We should support a new property max-width on image item in next release.
none: if image size exceeds container width, the image will be clipped.
100%:  if image size exceeds container width, the image will be scaled to fit container.
Comment 17 Bingxue Xu CLA 2008-08-05 13:57:55 EDT
Hi Gang Liu,

Thanks very much for the patch and really apprciate your help, and we'll apply it and test it out with our application.
Comment 18 Wei Yan CLA 2008-08-24 23:11:50 EDT
set to 2.5 for remain task.
Comment 19 Ming Gu CLA 2008-10-20 21:28:42 EDT
Hi Gang Liu,

This patch works, and if the image width beyond the page width, the image width in pdf file can fit the page width.

But there is another issue: if an image height beyonds the page height, the image will be truncated in generated pdf file.

BIRT seems zoom the image to fit the page width, but if the height of the zoomed image beyond the page height, the image height will not fit the page height.

Comment 20 Ming Gu CLA 2008-10-20 21:34:27 EDT
Could you provided a patch to make the image height fit page height as image width.
Comment 21 Gang Liu CLA 2008-12-29 01:27:48 EST
Reassign to model team to add max-width property for image item first
Comment 22 Wei Yan CLA 2008-12-29 04:50:02 EST

*** This bug has been marked as a duplicate of bug 240805 ***
Comment 23 Tianli Zhang CLA 2009-01-20 01:32:23 EST
Verified.
Comment 24 Henning Theis CLA 2009-05-08 05:54:43 EDT
Is there a patch for 2.3.0 too?
Comment 25 Jonathan Mising name CLA 2009-07-03 15:59:36 EDT
Where can i find the new property on BIRT 2.5? i couldn't find it. 
Thanks
Comment 26 Tianli Zhang CLA 2009-07-10 19:37:44 EDT
Select image and go to Property Editor->Advanced you will find the Fit to container property.