How to show report data in center of RDLC report? - c#

I am using RDLC to generate product receipt but facing issue with layout and design in RDLC.All my report contents are not coming in the center.
My page size is 7.30 centimeter and I want this content to be in center of the report
This is what I am trying to achieve(Expected Output) :
https://i.stack.imgur.com/eV8Mc.png
This is what I am getting :
Also my first table side border is cut as shown with red circle.
How do I make all my contents in center of the rdlc report ?
Updated : Print Layout setting of reportviewer with A4 size and Landscape:
This is what it looks like when I print receipt using Thermal Printer :
There are 2 receipt in above image : Original company generated receipt(right side) and the one generated by rdlc(Left one).
Left side : That receipt is generated by my winform application using RDLC report.As you can see there are lots of content that is cut(removed) in the receipt.
Right side : This is the original receipt and output I am trying to achieve and the red circle indicates things that are being cut(removed) in my reciept(Left one).As you can see BillNo,Date,Time,Title as well as both the table contents are cut(removed in my left side receipt).
I have measured the size of table in Original receipt and it is as below :
I have tried to set the size of table i.e 5.2 centimeter in my rdlc report but there is no such option available.
Update 2 : Based on my current RDLC setting this is what I have got :
I have manage to got the receipt size as per company original receipt but now only problem here is data is not coming in center and tables are being removed(cut).
Here is the Thermal Printer setting used for original receipt :
Based on above image,that is why I have kept report Width : 8cm and Height as 29.7 cm

Looking at your photo it seems that you have a 8cm receipt with 1.4cm left/right margin and 5.2 body.
So you can use this settings in Report > Report properties > Page setup:
paper size: custom
width: 8cm
left/right margin: 1,4cm
The body width must be 5.2cm and you could fill it without using margins.
This is the output with light blue body and white margins.

Related

Printer Prints with some white extra spaces on header using rdlc report

I am doing Winforms with RDLC report. My RDLC report show white space at the Top of the report . The size is exactly same as my header.
I also set ConsumeContainerWhitespace to True , but it still not helping
see Images

Print rdlc on thermal printer with unknown height

How can I use RDLC Reports to print a receipt with variable height? The height needs to be the sum of all elements inside the report. My report can grow and shrink in size.
My device info xml used inside the export method:
<DeviceInfo>
<OutputFormat>EMF</OutputFormat>
<PageWidth>6.5cm</PageWidth>
<PageHeight>10cm</PageHeight>
<MarginTop>0cm</MarginTop>
<MarginLeft>0cm</MarginLeft>
<MarginRight>0cm</MarginRight>
<MarginBottom>0cm</MarginBottom>
</DeviceInfo>
I've tried to sum the height of each item and set PageHeight to it but this doesn't work.
Here is a MSDN page where we can find a complete example.
You can set your height to a value bigger than what you think you'll be the highest possible height. The printer will stop printing at the end of the report because it'll only see blank space. See my report below:
This works every time with my report, the only downside is that you need to make sure the report real height will never be bigger than your fixed height. Also you could do some calculation and place your variable height inside the PageHeight like this:
double totalHeight = 0; //this will be your calculated height based on report elements
var sb = new StringBuilder();
var xr = XmlWriter.Create(sb);
xr.WriteStartElement("DeviceInfo");
xr.WriteElementString("OutputFormat", "EMF");
xr.WriteElementString("PageHeight", string.Format("{0}in", totalHeight));
xr.Close();
I recently found myself looking for help about this issue. I needed to print an RDLC report (Bill kind of report) to a thermal printer, but it got cut off at 11in (Letter size). After a lot of browsing and testing Paper sizes, Report sizes, Printer settings, etc. the one thing that fixed the problem was setting the Report height to the same Printer selected paper height (In my case, RollPaper 80x3276mm). It's pretty late, but hope this could help to save time to anyone in the same problem.

Programmatically resize an image in a report

My C# application generates a Crystal Report that contains many images with varying size, orientation, and aspect ratio. To make them appear correctly in the report, I use a white Square Canvas and center the image inside. This makes lot of wasted space:
Is it possible to resize each picture in the report to the appropriate size from C#? I have found a way to resize the images here, but I don't know if I can perform these steps from c#, especially when it comes to "Calculating and setting Width and Height to the proper number of twips."
I know the size of my image in C#, but can it be passed to and implemented in the report? Images are inside an xml file in base64 format.
Designer View:
Okay, i don't have a working solution but an idea that might help you ( and i hope it will )
I searched a programmatically way to do what you want, and i don't find anything. Unless the fact that you can manipulate your FieldObject with C#, it can't be used in your report.
So, i'll try to guide you with some screenshoots, but i am French and my screens will be in french, so sorry for the bad translations !
You can write a formula to change the display of your BinaryImage in your subreport. I just found a way to change the width of you data, not the height.
So, assuming my image is stored in "ARTICLE" table, and the name of the column is "ART_IMAGE". I put my data in the detail section and create a new formula, ignore the created formula, you need to access to the "formatting formulas" :
Here in my screen it is called "Formules de mise en forme". In the left you can see my simple report and on the right the formula panel, i clicked on my details section and i can see my only field.
Now right click on this field and create a new formatting formula :
A pop up is displayed, you'll need to choose something like that in english "
Adjusting the width" :
Now, you have to return the new width of your current image, a way to know what is the current width is to store it in a field in your database.
So if in your database you have a field for your image, and a field like image_width. In my example i have a field name ART_DIMENSION and i store the width of the image.
The tricky part is that this formula accept twips not inch or cm. For you information 1 inch = 1440 twips.
So in my example here is the formula :
So for each image to display, the width of my image will be the width stored in "ART_DIMENSIONS" ( with the good convert : inch to twips )
In your report design, with a formula like this which set the width dynamically for your image, you can set the section and your image object with a very small width. In this case your images will be displayed one by another because the section width will be edited for each image to display.
I tried to be very clear, hope it will help you, ask me any questions if you don't understand something.
Regards,

How to print Client Report Definition file (.rdlc) on A4 size in C#?

I am trying to print a report using C# Report Viewer Control.
By the way, I bumped into a problem.
I wanted my .rdlc file to be printed on A4 size. so I changed .rdlc file size with A4 size 210X297(mm) in the VS2010 designer. But the report viewer object that uses this .rdlc file automatically sets the margins on the paper. So the total size of the paper that will be printed was over A4 size.
I can't estimate the size of the margin.
Is there any way to estimate or control the size of the margin?
I have been searching for the last some days...
I need help. please give me a hand.
My platform is VS2010 / .Net 4.0 / C#
Thanks tezzo for your help. I appriciate it.
My problem was which I didn't know the fact that Report > Report properties > Page setup exists.
I could resolve my problem by your advice.
But I had what makes me confused. so I leave some aditional pictures.
I hope it is helpful to another person who encounters such a problem.
You have to click the point that the picture 1 expresses by the check sign. If you click the point that the picture 2 expresses by the check sign, you can not see such a properties window that have a Margins and a PageSize Property, which makes me confused.
When you reach here, you can follow tezzo's advice. then you can print rdlc file on A4 size.
I am first to write here. so I can't add any picture on it.
I link pictures.
< picture 1>
< picture 2 >
You can set paper size and margins in Report > Report properties > Page setup.
I usually use this settings:
paper size: A4
size: 21 x 29,7 (landscape: 29,7 x 21)
left/right margin: 1,3cm
bottom/top margins: 1,5cm
So the maximum width of report will be:
21 - (1,3*2) = 18,4cm
29,7 - (1,3*2) = 27,1cm (landscape)

Report file Print (Multiple objects) c#

I've been working on a project in C# which uses a RDLC report with an Excel file as its source.
My problem is that I have made a single rectangle on the report, and I want it to be printed multiple times on the page (i.e. On an A4 size paper, when I print it, I want 10 prints of the rectangle on the page [5 on left and 5 on right side of the page]).
I am getting 5 prints of the rectangle on the left side only. What should I do to get 10 prints (as described above)?
How can I use the Page Break functionality in the RDLC to accomplish this?

Categories

Resources