0

Here is my code i work with:

set Dataset and parameter to RDLC report

private static int m_currentPageIndex;

report.DataSources.Add(new ReportDataSource("dsReceiptInfor", ReceiptInfor)); ReportParameter[] param = new ReportParameter[2];

param[0] = new ReportParameter("imgPath", FilePath); param[1] = new ReportParameter("BaseCurrencyFormat", BaseCurrencyFormat);

report.SetParameters(param);

Export(report);

Print();


Functions

--Export

    private static void Export(LocalReport report)
    {
     string deviceInfo =
          @"<DeviceInfo>
            <OutputFormat>EMF</OutputFormat>
            <PageWidth>8.5in</PageWidth>
            <PageHeight>11in</PageHeight>
            <MarginTop>0in</MarginTop>
            <MarginLeft>0in</MarginLeft>
            <MarginRight>0in</MarginRight>
            <MarginBottom>0in</MarginBottom>
        </DeviceInfo>";
            Warning[] warnings;
            m_streams = new List<Stream>();
            report.Render("Image", deviceInfo, CreateStream, out warnings);

            foreach (Stream stream in m_streams)
                stream.Position = 0;
     }

--Print

    private static void Print()
    {
        if (m_streams == null || m_streams.Count == 0)
            throw new Exception("Error: no stream to print.");

        PrintDocument PrintBill = new PrintDocument();
        PrintBill.PrintPage += new PrintPageEventHandler(PrintPage);
        PrintBill.PrinterSettings.PrinterName = PrinterName;
        PrintBill.PrintController = new StandardPrintController();
        m_currentPageIndex = 0;
        PrintBill.Print();
    }

--PrintPage

    private static void PrintPage(object sender, PrintPageEventArgs ev)
    {
        try
        {
            Metafile pageImage = new Metafile(m_streams[m_currentPageIndex]);

            //Adjust rectangular area with printer margins.
            Rectangle adjustedRect = new Rectangle(
                0,
                0,
                765,
                ev.PageBounds.Height);
            //Draw a white background for the report
            ev.Graphics.FillRectangle(Brushes.White, adjustedRect);

            
            // Draw the report content
            ev.Graphics.DrawImage(pageImage, adjustedRect);

            // Prepare for the next page. Make sure we haven't hit the end.
            m_currentPageIndex++;
            ev.HasMorePages = (m_currentPageIndex < m_streams.Count);
        }
        catch (Exception ex)
        {

        }
        
    }

When the data print (PageHeight > 11 inch) it will cut. Could you tell me how to print long as the paper. thanks for your attention :)

1 Answer 1

0

after long time i have searching the answer but still not found. So i have found one solution without coding. in Printer setting we can change printer preference :

Paper source --> Document (cut). Done

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.