Beispiel #1
0
        private void Export(LocalReport Report, PageProps PageProps)
        {
            string deviceInfo = string.Format(
                @"<DeviceInfo>
                <OutputFormat>EMF</OutputFormat>
                <PageWidth>{0}in</PageWidth>
                <PageHeight>{1}in</PageHeight>
                <MarginTop>{2}in</MarginTop>
                <MarginLeft>{3}in</MarginLeft>
                <MarginRight>{4}in</MarginRight>
                <MarginBottom>{5}in</MarginBottom>
            </DeviceInfo>",
                PageProps.PageWidth,
                PageProps.PageHeight,
                PageProps.MarginTop,
                PageProps.MarginLeft,
                PageProps.MarginRight,
                PageProps.MarginBottom);

            Warning[] warnings;
            m_streams = new List <Stream>();
            Report.Render("Image", deviceInfo, CreateStream,
                          out warnings);
            foreach (Stream stream in m_streams)
            {
                stream.Position = 0;
            }
        }
Beispiel #2
0
        public virtual void Print(LocalReport Report, PageProps PageProps)
        {
            Export(Report, PageProps);

            if (m_streams == null || m_streams.Count == 0)
            {
                throw new Exception("Error: no stream to print.");
            }
            PrintDocument printDoc = new PrintDocument();

            if (!printDoc.PrinterSettings.IsValid)
            {
                throw new Exception("Erro: Não é possível localizar a impressora padrão.");
            }
            else
            {
                printDoc.PrintPage += new PrintPageEventHandler(PrintPage);
                m_currentPageIndex  = 0;
                printDoc.Print();
                MessageBox.Show("Recibo do pedido enviado para impressora com sucesso.", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }