How can I size imageboxes to the image dimensions in Crystal Reports? - crystal-reports

How can I size imageboxes to the image dimensions in Crystal Reports?
i am doing a project in tat i having 3 type of image with different size from db how can i set image

i found the answer here
To make the image resize properly, you must perform the following steps in order:
Set the image's EnableCanGrow to true
Calculate and set Width and Height to the needed size
Set the image's EnableCanGrow to false
Fill the DataSet's image object with data
Continue with normal report processing.
If you get these items in the wrong order, or skip an item, you will
find that Crystal Reports scales the image in unexpected and unrecoverable ways.

I had this issue. I managed to solve it by File > Report Options > Retain Original Image Color Depth. For some reason Crystal sees the altered background colour as part of the image so when you resize it it doesn't alter the background. By removing the background it gets you around this issue in some instances.

Related

How to set max height of a picture in crystal report?

Is it possible to set maximal height of a picture in crystal report and preserve original ratio of a picture?
If can grow is disabled, every picture is streched or shrinked to default picture object size, if is enabled, I'm losing limits of picture size.
I'm using crystal reports for VS 2013 (13.0.5)
Actually I solved this problem for Visual Basic 5.0 and Crystal Reports 6.0 (Seagate version). You asked the newer version but maybe this gives you an idea to solve the problem or it may help some other guys searching an answer for their problems.
Before you assign the report source you can change the height of the picture:
Set crxFieldObject = Report.Sections.Item("D").ReportObjects.Item(269)
crxFieldObject.Height = theNewHeight
CRViewer1.ReportSource = Report
CRViewer1.ViewReport
PS: After you assign the report source you can not change the height property. Below code does NOT work:
Private Sub Section3_Format(ByVal pFormattingInfo As Object)
Picture1.Height = theNewHeight 'this code does NOT work
End Sub
In this code:
.Sections.Item("D")means the Detail Section of the report and
.Item(269) means the Picture Object. After you insert an OLE Object you can check the item number with a small code such as:
aa = Report.Sections.Item("D").ReportObjects.Count
For i = 1 To aa
Set crxFieldObject = Report.Sections.Item("D").ReportObjects.Item(i)
bb = crxFieldObject.Name
If Mid(bb, 1, 7) = "Picture" Then
crxFieldObject.suppress = False 'You can put a BreakPoint here to check the value of i
End If
Next i
Hope it helps
The answer is No. I did many tests and researches and I didn't found any way to control the height and, without controlling the height, it's not possible to fit an arbitrary image in the object box and keep is ratio at the same time.
Looks like it's and old problem.
But if all your images are limited to the same dimensions, like you have set your limits to 500x500, so you can have, for example, images that do 500x200, 500x500, 250x500, etc., there's a way to do it.
The object box needs to have the same ratio as your limits. In my example, 500x500, the ratio is 1:1 (square) so your object box needs to be square also. You need to check Can grow and, in the Image tab, set the size exactly like the object box's size. You also have to set the bitmap image size (right-click on the box, choose Bitmap Image Object then Modify) to the image limits (500x500).
Perhaps too late, but when you right click on picture -> shaping of the object
You've a checkbox "modular size", uncheck it and put manually the size you want on Image tab.

Advanced image scaling in JasperReports

I need to include many images of unknown origin in a report. I have no idea what the images might be: portrait or landscape fotos, large or small, or even something with an atypical shape, like a 400x80 logo.
I'd like to scale down images with the following rule: proportionally downscale until the larger side is 200. And resulting image shouldn't take more space than needed (i.e. 1000x600 should be downscaled to 200x120, not to 200x200), so that there are no unneeded blank margins around non-square images.
Is what I need possible with JasperReports?
EDIT:
To clarify: "real size" mode is almost what I need. However, I don't see a way to limit height of resulting image. As a result, if the image I want to print is a portrait foto (or has even larger height compared to width), generated PDF looks ugly; in this case I would prefer to somehow downscale it to a smaller width.
I solved the Problem of resizing images of various sizes to a fixed size with "RetainShape" by writing an ImageResizer, based on the idea of the ImageTransformer from https://stackoverflow.com/a/39320863/8957103 , using https://github.com/rkalla/imgscalr for scaling the image.

how to fit content of reports so that we can print it on A4 size

I have created a report in ssrs 2008 r2.It is larger then the normal A4 size .So when i export the report in word i see it clearly but when i see print preview of the report in to the word its contents get cut from the right end.I think it is due to report size. Is there any way so that we can fit the content at the time of export in to the ms word so that user can clearly take a print out in A4 size.
The only way to do this is to physically decrease the size of your report when building it as there is no auto size capability in report builder.
Right click and properties on the grey back ground. Then change the size and orientation as required.
Then click on the white body and ensure the properties bar is open. Expand the size properties option and set the size of your report to reflect the previous selection.
Also don't forget to set the margins as this will effect the amount of printable space on your report.
Lastly ensure you alter the size of you fonts and report parts to fit on the size required.
I'd love to see an automatic sizing feature in the report builder for exporting.
This is because your report content size is greater than the report size.
Report size for an A4 page is 8.5*11 inch,if your content is greater than the report size then it will move the columns to the next .
Adjust the Size of each Tablix which should be less than your report size.
Select Tablix to view properties.
expand the size option and adjust width and height accordingly.
Thanks
Just increase height and width of paper size in Report builder properties. Doesn't have any sense but it works for me.
In Report Builder in the Report Properties change the width of the report so that it exceeds the width of your data. Exporting to both Word and PDF will mean that it fits the page width. You can also adjust the height so that the report fills your desired paper size.

iReport - Dynamic images or image height

having an issue with iReport/JasperReports and not sure the best way to tackle it. The report is a typical order detail style report with each line item enumerated with attributes like quantity, description, name, price, etc.
However, the problem I would like to solve revolves around displaying optional pictures as part of the line item description. Each line item could have N number of detailed pictures - think of it as multiple images of a product (like under the car hood, the wheels, interior, exterior, etc). The number of images is displayed at run time.
How can I include these dynamic images? I could create placeholders for 9 images, and hide if they aren't passed in, but that would leave blank space for the line items that don't have that many images. I could even combine all of the misc images into one bigger image before I passed to the report, but I still have the sizing issue.
Can't seem to figure out how to have dynamic sizing on the band, while still allowing multiple optional images.
Any ideas out there?
To solve your issue with blank space. You can set the band to not print when there is no data (would require 1 band for each picture/item. Or each component has a property 'Remove Line When Blank' which will compact the space if there is no data/images to show on that horizontal space.

Jasper Reports image and text mix

I want to write a jasper reports application. It has to arrange an image and a text such that they will be appropriately placed. This is what I want.
I get images and texts from a web service, so I can fetch image size on runtime. If its width is bigger the text should be below, and vice versa. I tried setting width option by a parameter, but it did not work.
How can i do it?
Correct: You cannot set the image width using a parameter.
The quickest solution is probably like this:
Determine what your maximum width is. Then use a 'Print when expression' to display either the picture-next-to-text layout or the picture-above-text layout. Your report will have 2 image elements and 2 text elements, but you'll choose which one to display based on the image size.
An alternative would be to investigate something like Dynamic Jasper. That's a project designed to dynamically generate the .jrxml on the fly, so it has the ability to modify the width similar to what you're describing.