0

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.

1
  • I know your question is old but I added an answer if you still need help or to help other people running into the same issue.
    – user6490459
    Commented Feb 21, 2018 at 11:39

2 Answers 2

0

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:

enter image description here

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();
1
  • Not working, still cut on 11 inch of page size, my Page Size is: 17.18 inch
    – Monzur
    Commented May 12 at 10:59
-1

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.

1
  • Hi, I have the same problem. I've tried to set PageSize in rldc viewer to 8cm x 327.6cm, also I've tried with 8cm x 20cm and the printer still wants to print/use the whole roll. (Body size in rlds viever is set to 6cmx15cm). Page size only affects for me only PDF view when the report is created, it doesn't affect print height... Commented Mar 9, 2021 at 12:43

Not the answer you're looking for? Browse other questions tagged or ask your own question.