protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                using (MemoryStream ms = new MemoryStream())
                {
                    PrintableComponentLink pcl = new PrintableComponentLink(new PrintingSystem());

                    ASPxGridViewExporter export = (ASPxGridViewExporter)Session["exporter"];
                    export.Styles.Header.Wrap = DevExpress.Utils.DefaultBoolean.True;
                    export.MaxColumnWidth     = 180;
                    pcl.Component             = export;
                    pcl.Margins.Left          = pcl.Margins.Right = 10;

                    pcl.Landscape = true;
                    pcl.CreateDocument(false);
                    pcl.PrintingSystem.Document.AutoFitToPagesWidth = 0;

                    pcl.ExportToPdf(ms);
                    WriteResponse(this.Response, ms.ToArray(), System.Net.Mime.DispositionTypeNames.Inline.ToString());
                }
            }
            catch (Exception ex)
            {
                cm.log.Error("Kontrolka : generowanie pdf :" + ex.Message);
            }
        }
Пример #2
0
 protected void ASPxMenu1_ItemClick(object source, DevExpress.Web.MenuItemEventArgs e)
 {
     if (e.Item.Name == "ExportXLSItem")
     {
         ServerGridViewExporter.ExportXlsToResponse("DailyMemoryUsed.xls");
     }
     else if (e.Item.Name == "ExportXLSXItem")
     {
         ServerGridViewExporter.ExportXlsxToResponse("DailyMemoryUsed.xlsx");
     }
     else if (e.Item.Name == "ExportPDFItem")
     {
         //ServerGridViewExporter.Landscape = true;
         using (MemoryStream ms = new MemoryStream())
         {
             PrintableComponentLink pcl = new PrintableComponentLink(new PrintingSystem());
             pcl.Component    = ServerGridViewExporter;
             pcl.Margins.Left = pcl.Margins.Right = 50;
             pcl.Landscape    = true;
             pcl.CreateDocument(false);
             pcl.PrintingSystem.Document.AutoFitToPagesWidth = 1;
             pcl.ExportToPdf(ms);
             WriteResponse(this.Response, ms.ToArray(), System.Net.Mime.DispositionTypeNames.Attachment.ToString());
             //ServerGridViewExporter.WritePdfToResponse();
         }
     }
 }
        private void btOnizleEpostaGonder_Click(object sender, EventArgs e)
        {
            gridView5.ViewCaption = "Gün Sonu " + ilktarih.Text + " - " + sontarih.Text;
            gridView5.OptionsView.ShowViewCaption = true;
            PrintableComponentLink printableLink = new PrintableComponentLink(new PrintingSystem());

            printableLink.Component = gcGunSonuOzet;
            printableLink.Landscape = true;
            printableLink.PaperKind = System.Drawing.Printing.PaperKind.A5Rotated;
            printableLink.CreateDocument(Printing);

            string dosyaadi = DB.exeDizini + "\\gunsonu.pdf";

            printableLink.ExportToPdf(dosyaadi);

            //ShowRibbonPreviewDialog(printableLink);
            //System.Diagnostics.Process process = new System.Diagnostics.Process();
            //process.StartInfo.FileName = filePath;
            //process.Start();

            DB.epostagonder(lUEKullanicilar.EditValue.ToString(), "Gün Sonu Raporu", dosyaadi, "Gün Sonu Raporu");
            formislemleri.Mesajform("E-Posta Gönderildi.", "S", 200);
            printableLink.Dispose();

            gridView5.OptionsView.ShowViewCaption = false;
        }
Пример #4
0
        protected void _print(object sender, EventArgs e)
        {
            using (MemoryStream ms = new MemoryStream())
            {
                PrintableComponentLink pcl = new PrintableComponentLink(new PrintingSystem());
                //listaBieglych.Columns[0].Visible = false;

                ASPxGridViewExporter1.FileName = "Wykaz biegłych";
                pcl.Component = ASPxGridViewExporter1;

                pcl.Margins.Left = pcl.Margins.Right = 50;
                pcl.Landscape    = true;
                pcl.CreateDocument(false);
                pcl.PrintingSystem.Document.AutoFitToPagesWidth = 1;
                pcl.ExportToPdf(ms);
                WriteResponse(this.Response, ms.ToArray(), System.Net.Mime.DispositionTypeNames.Inline.ToString());
            }
            //  ASPxGridViewExporter1..GridView = ASPxGridView2;

            /*PxGridViewExporter1.PrintSelectCheckBox = true;
             * ASPxGridViewExporter1.Landscape = true;
             *
             *
             * ASPxGridViewExporter1.Landscape = true;
             *
             * ASPxGridViewExporter1.WritePdfToResponse();
             */
            //listaBieglych.Columns["Column"].Visible = true;
        }
Пример #5
0
        protected void EventSettings_ItemClick(object source, DevExpress.Web.MenuItemEventArgs e)
        {
            if (e.Item.Name == "ExportXLSItem")
            {
                if (startDate.Value != "")
                {
                    ServerGridViewExporter.FileName = "EventsHistory" + "_" + startDate.Value;
                    ServerGridViewExporter.WriteXlsToResponse();
                }
                else
                {
                    ServerGridViewExporter.FileName = "EventsHistory" + "_" + DateTime.Now.ToString();
                    ServerGridViewExporter.WriteXlsToResponse();
                }
            }
            else if (e.Item.Name == "ExportXLSXItem")
            {
                if (startDate.Value != "")
                {
                    ServerGridViewExporter.FileName = "EventsHistory" + "_" + startDate.Value;
                    ServerGridViewExporter.WriteXlsxToResponse();
                }
                else
                {
                    ServerGridViewExporter.FileName = "EventsHistory" + "_" + DateTime.Now.ToString();
                    ServerGridViewExporter.WriteXlsxToResponse();
                }
            }
            else if (e.Item.Name == "ExportPDFItem")
            {
                if (startDate.Value != "")
                {
                    ServerGridViewExporter.FileName = "EventsHistory" + "_" + startDate.Value;
                    //ServerGridViewExporter.WriteXlsxToResponse();
                }
                else
                {
                    ServerGridViewExporter.FileName = "EventsHistory" + "_" + DateTime.Now.ToString();
                    //ServerGridViewExporter.WriteXlsxToResponse();
                }

                ServerGridViewExporter.Landscape = true;
                using (MemoryStream ms = new MemoryStream())
                {
                    PrintableComponentLink pcl = new PrintableComponentLink(new PrintingSystem());
                    pcl.Component    = ServerGridViewExporter;
                    pcl.Margins.Left = pcl.Margins.Right = 50;
                    pcl.Landscape    = true;
                    pcl.CreateDocument(false);
                    pcl.PrintingSystem.Document.AutoFitToPagesWidth = 1;
                    pcl.ExportToPdf(ms);

                    WriteResponse(this.Response, ms.ToArray(), System.Net.Mime.DispositionTypeNames.Attachment.ToString());
                    //ServerGridViewExporter.WritePdfToResponse();
                }
            }
        }
Пример #6
0
        private void btnExport_Click(object sender, EventArgs e)
        {
            SetPrintStyle();
            string filePath            = "Test.pdf";
            PrintableComponentLink pcl = new PrintableComponentLink(new PrintingSystem());

            pcl.Component = this.schedulerControl1;
            pcl.CreateDocument();
            pcl.ExportToPdf(filePath);
            // Use the code below to open the file in an associated application.
            if (File.Exists(filePath))
            {
                System.Diagnostics.Process process = new System.Diagnostics.Process();
                process.StartInfo.FileName = filePath;
                process.Start();
            }
        }
Пример #7
0
        private void btnExportPdf_Click(object sender, EventArgs e)
        {
            string FileName = mTempPath + @"\" + GenRendom() + ".pdf";

            mlink = new PrintableComponentLink()
            {
                PrintingSystemBase = new PrintingSystemBase(),
                Component          = xList,
                Landscape          = true,
                PaperKind          = PaperKind.A4,
                Margins            = new Margins(20, 20, 50, 20),
            };
            mlink.CreateMarginalHeaderArea += link_CreateMarginalHeaderArea;
            mlink.ExportToPdf(FileName);

            //xList.ExportToPdf(FileName);
            System.Diagnostics.Process.Start(FileName);
        }
        Stream GetPdfStream()
        {
            MemoryStream ms       = new MemoryStream();
            IWorkbook    workBook = SpreadsheetExtension.GetCurrentDocument("Spreadsheet");

            workBook.SaveDocument(ms, DocumentFormat.Xlsm);
            ms.Position = 0;
            Workbook docServer = new Workbook();

            docServer.LoadDocument(ms, DocumentFormat.Xlsm);
            ms.Position = 0;
            PrintableComponentLink link = new PrintableComponentLink(new PrintingSystem());

            link.Component = docServer;
            link.ExportToPdf(ms);
            ms.Position = 0;

            return(ms);
        }
 protected void ASPxButton2_Click(object sender, EventArgs e)
 {
     using (MemoryStream ms = new MemoryStream())
     {
         PrintableComponentLink pcl = new PrintableComponentLink(new PrintingSystem());
         pcl.Component = ASPxGridViewExporter3;
         pcl.Margins.Left = pcl.Margins.Right = 0;
         pcl.Margins.Top = 50;
         pcl.Landscape = true;
         pcl.CreateDocument(true);
         pcl.PrintingSystem.Document.AutoFitToPagesWidth = 1;
         PageHeaderFooter phf = pcl.PageHeaderFooter as PageHeaderFooter;
         phf.Header.Content.Clear();
         //phf.Header.Content.AddRange(new string[] { leftColumn, middleColumn, rightColumn });
         phf.Header.LineAlignment = BrickAlignment.Far;
         pcl.ExportToPdf(ms);
         WriteResponse(this.Response, ms.ToArray(), System.Net.Mime.DispositionTypeNames.Attachment.ToString());
     }
 }
Пример #10
0
        protected void Button_Click(object sender, EventArgs e)
        {
            PrintableComponentLink link = new PrintableComponentLink(new PrintingSystem());

            link.Component = Exporter;
            using (MemoryStream ms = new MemoryStream()) {
                int height = 20;
                link.CreateReportHeaderArea += (s, args) => {
                    args.Graph.DrawString("Report Header Text", Color.Empty, new RectangleF(Point.Empty, new SizeF(args.Graph.ClientPageSize.Width, height)), BorderSide.Top);
                    args.Graph.DrawRect(new RectangleF(new Point(0, height), new SizeF(args.Graph.ClientPageSize.Width, height)), BorderSide.Top, Color.Empty, Color.Empty);
                };

                link.CreateReportFooterArea += (s, args) => {
                    args.Graph.DrawRect(new RectangleF(Point.Empty, new SizeF(args.Graph.ClientPageSize.Width, height)), BorderSide.Bottom, Color.Empty, Color.Empty);
                    args.Graph.DrawString("Report Footer Text", Color.Empty, new RectangleF(new Point(0, height), new SizeF(args.Graph.ClientPageSize.Width, height)), BorderSide.Bottom);
                };

                link.CreateDocument(false);
                link.ExportToPdf(ms);
                WriteDataToResponse(ms.ToArray(), ExportType.PDF);
            }
        }
Пример #11
0
        private void printChart_Click(object sender, EventArgs e)
        {
            PrintingSystem         exportChart = new PrintingSystem();
            PrintableComponentLink chartLink   = new PrintableComponentLink(exportChart);

            chartLink.Component = this.inventoryChart;
            PageHeaderFooter header = new PageHeaderFooter(new PageHeaderArea(
                                                               new string[] { "Inventory report", "", "Printed on [Date Printed][Time Printed]" },
                                                               new Font("Verdana", 12.0f),
                                                               BrickAlignment.Far), null);

            chartLink.PageHeaderFooter = header;

            System.IO.Stream chartDocStream;
            if (this.inventoryChart.Series["ProductUnits"].Visible)
            {
                this.inventoryChart.Annotations[0].Visible = false;
            }
            chartLink.CreateDocument();
            if (this.inventoryChart.Series["ProductUnits"].Visible)
            {
                this.inventoryChart.Annotations[0].Visible = true;
            }
            SaveFileDialog saveChartDialog = new SaveFileDialog();

            saveChartDialog.Filter           = "PDF files (*.pdf)|*.pdf";
            saveChartDialog.FilterIndex      = 1;
            saveChartDialog.RestoreDirectory = true;

            if (saveChartDialog.ShowDialog() == DialogResult.OK)
            {
                if ((chartDocStream = saveChartDialog.OpenFile()) != null)
                {
                    chartLink.ExportToPdf(chartDocStream);
                    chartDocStream.Close();
                }
            }
        }
        protected void ASPxButton1_Click(object sender, EventArgs e)
        {
            PrintableComponentLink link = new PrintableComponentLink(new PrintingSystem());

            link.Component = ASPxGridViewExporter1;
            using (MemoryStream ms = new MemoryStream())
            {
                link.CreateDocument(false);
                BrickEnumerator brickEnum = link.PrintingSystem.Document.Pages[0].GetEnumerator();
                float           maxWidth  = 0;
                while (brickEnum.MoveNext())
                {
                    maxWidth = maxWidth > brickEnum.CurrentBrick.Rect.X + brickEnum.CurrentBrick.Rect.Width ? maxWidth : brickEnum.CurrentBrick.Rect.X + brickEnum.CurrentBrick.Rect.Width;
                }
                float freeSpace = (link.PrintingSystem.Document.Pages[0]).PageSize.Width - maxWidth;
                if (freeSpace > 600)
                {
                    link.Margins.Left = (int)(freeSpace / 6);
                    link.CreateDocument(false);
                }
                link.ExportToPdf(ms);
                WriteDataToResponse(ms.ToArray(), ExportType.PDF);
            }
        }
Пример #13
0
        private void exportSatis(string dil, bool eMail = false)
        {
            int tstID = (int)tstGridView.GetFocusedRowCellValue(colTSTIDt);

            rprTklfTableAdapter.Fill(teklifDataSet.RPR_TKLF, tstID, dil);
            TeklifDataSet.RPR_TKLFRow rprTklfRow = (TeklifDataSet.RPR_TKLFRow)teklifDataSet.RPR_TKLF.Rows[0];
            string tklfTE = "Teklif";

            if (dil == "T")
            {
                colORGf.Caption     = "Çıkış";
                colDSTf.Caption     = "Varış";
                colBRMf.Caption     = "Birim";
                colTRNTIMEf.Caption = "Transit Süre";

                colSKDY.Caption  = "KDV%";
                colSDVZf.Caption = "Para Birim";

                colSFYTf.Caption  = "Fiyat";
                colSFYT1f.Caption = "Min";
                colSFYT2f.Caption = "-45";
                colSFYT3f.Caption = "+45";
                colSFYT4f.Caption = "+100";
                colSFYT5f.Caption = "+250";
                colSFYT6f.Caption = "+300";
                colSFYT7f.Caption = "+500";
                colSFYT8f.Caption = "+1000";

                colSFYTE.Caption  = "Fiyat";
                colSFYT1E.Caption = "Min";
                colSFYT2E.Caption = "-45";
                colSFYT3E.Caption = "+45";
                colSFYT4E.Caption = "+100";
                colSFYT5E.Caption = "+250";
                colSFYT6E.Caption = "+300";
                colSFYT7E.Caption = "+500";
                colSFYT8E.Caption = "+1000";
            }
            else
            {
                tklfTE              = "Tender";
                colORGf.Caption     = "Origin";
                colDSTf.Caption     = "Destination";
                colBRMf.Caption     = "Unit";
                colTRNTIMEf.Caption = "Transit Time";

                colSKDY.Caption  = "%VAT";
                colSDVZf.Caption = "Currency";

                colSFYTf.Caption  = "Rate";
                colSFYT1f.Caption = "Min";
                colSFYT2f.Caption = "-45";
                colSFYT3f.Caption = "+45";
                colSFYT4f.Caption = "+100";
                colSFYT5f.Caption = "+250";
                colSFYT6f.Caption = "+300";
                colSFYT7f.Caption = "+500";
                colSFYT8f.Caption = "+1000";

                colSFYTE.Caption  = "Rate";
                colSFYT1E.Caption = "Min";
                colSFYT2E.Caption = "-45";
                colSFYT3E.Caption = "+45";
                colSFYT4E.Caption = "+100";
                colSFYT5E.Caption = "+250";
                colSFYT6E.Caption = "+300";
                colSFYT7E.Caption = "+500";
                colSFYT8E.Caption = "+1000";
            }

            if (colG9.GroupIndex == 0)
            {
                tsfGridView.CollapseAllGroups();
                //tsfGridView.OptionsView.ShowFooter = true;
                tsfGridView.OptionsPrint.ExpandAllGroups = false;
                tsfGridView.OptionsPrint.PrintFooter     = true;
                //tsfGridView.OptionsPrint.AutoWidth = false;
                tsfGridView.OptionsPrint.AutoWidth = true;
            }
            else
            {
                tsfGridView.ExpandAllGroups();
                //tsfGridView.OptionsView.ShowFooter = false;
                tsfGridView.OptionsPrint.ExpandAllGroups = true;
                tsfGridView.OptionsPrint.PrintFooter     = false;
                //tsfGridView.OptionsPrint.AutoWidth = false;
                tsfGridView.OptionsPrint.AutoWidth = true;
                //tsfGridView.BestFitColumns();
            }

            RichEditDocumentServer richServer = new RichEditDocumentServer();

            richServer.RtfText = rprTklfRow.ALTNOT;
            //richServer.Document.AppendText(" SENER");
            if (!rprTklfRow.IsDTYNOTNull())
            {
                if (string.IsNullOrEmpty(richServer.Text))
                {
                    richServer.RtfText = rprTklfRow.DTYNOT;
                }
                else
                {
                    richServer.Document.AppendRtfText(rprTklfRow.DTYNOT);
                }
            }

            tsfGridView.OptionsPrint.RtfReportFooter = richServer.RtfText;
            tsfGridView.OptionsPrint.RtfPageFooter   = rprTklfRow.FOOTER;


            PrintingSystem         ps   = new PrintingSystem();
            PrintableComponentLink link = new PrintableComponentLink(ps);

            link.Component = tsfGridControl;

            link.PaperKind      = System.Drawing.Printing.PaperKind.A4;
            link.Landscape      = false;
            link.Margins.Left   = 10;
            link.Margins.Right  = 10;
            link.Margins.Top    = 10;
            link.Margins.Bottom = 10;

//            tsfGridView.OptionsPrint.RtfPageHeader =
            tsfGridView.OptionsPrint.RtfReportHeader =
                rprTklfRow.USTNOT
                .Replace("@TSTID@", rprTklfRow.TSTID.ToString())
                .Replace("@FIRMA@", rprTklfRow.FIRMA)
                .Replace("@TLPTRH@", rprTklfRow.TLPTRHS)
                .Replace("@TKLTRH@", rprTklfRow.TKLTRHS)
                .Replace("@GCRTRH@", rprTklfRow.GCRTRHS)
                .Replace("@ROT@", rprTklfRow.ROT)
                .Replace("@MOT@", rprTklfRow.MOT)
                .Replace("@PTM@", rprTklfRow.PTM)
                .Replace("@DTM@", rprTklfRow.DTM)

                .Replace("@HORGS@", rprTklfRow.HORGS)
                .Replace("@HDSTS@", rprTklfRow.HDSTS)
                .Replace("@MORGS@", rprTklfRow.MORGS)
                .Replace("@MDSTS@", rprTklfRow.MDSTS)

                .Replace("@MALCINSI@", rprTklfRow["MALCINSI"].ToString())
                .Replace("@INFO@", rprTklfRow.INFO);

            link.CreateDocument();

            if (eMail)
            {
                if (string.IsNullOrWhiteSpace(rprTklfRow.EMAILS))
                {
                    XtraMessageBox.Show("eMail adresi bulunamadı", "eMail Teklif", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    return;
                }

                Cursor = Cursors.WaitCursor;
                try
                {
                    MainDataSet.SMTPRow SMTP = Program.MF.SMTP();
                    MailMessage         mail = new MailMessage();

                    // Create a new memory stream and export the report into it as PDF.
                    MemoryStream ms = new MemoryStream();
                    link.ExportToPdf(ms);

                    // Create a new attachment and put the PDF report into it.
                    ms.Seek(0, System.IO.SeekOrigin.Begin);
                    Attachment att = new Attachment(ms, string.Format("{0}-{1}.pdf", tklfTE, tstID), "application/pdf");
                    mail.Attachments.Add(att);

                    mail.To.Add(rprTklfRow.EMAILS);

                    mail.Subject    = rprTklfRow.EMAILSUBJECT;
                    mail.Body       = rprTklfRow.EMAILBODY;
                    mail.IsBodyHtml = true;

                    mail.From = new MailAddress(SMTP.MAIL_FROM_ADDRESS, SMTP.MAIL_FROM_DISPLAY_NAME);
                    SmtpClient smtp = new SmtpClient(SMTP.CLIENT_HOST);
                    smtp.Credentials = new System.Net.NetworkCredential(SMTP.CREDENTIALS_USER_NAME, SMTP.CREDENTIALS_USER_PASSWORD);
                    smtp.EnableSsl   = SMTP.ENABLE_SSL == "T" ? true : false;
                    smtp.Port        = SMTP.PORT;

                    smtp.Send(mail);

                    int    len = (int)ms.Length;
                    byte[] img = new byte[len];
                    ms.Read(img, 0, len);
                    //teklifQueriesTableAdapter.DOC_INS2("TST", tstID, "Teklif", ".pdf", "TKLF", Program.USR, len, img);
                    teklifQueriesTableAdapter.DOC_INS2("TST", tstID, string.Format("Teklif {0}", tstGridView.GetFocusedRowCellValue(colRVSNOt)), ".pdf", "TKLF", Program.USR, len, img);

                    // Close the memory stream.
                    ms.Close();
                    ms.Flush();

                    rptInfo rpti = new rptInfo();
                    rpti.put("TKLF", "TST", tstID, Program.USR, "F", "eMail Teklif");
                    Program.MF.reportDone(rpti, false);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(this, "Error sending eMail.\n" + ex.ToString());
                }
                finally
                {
                    Cursor = Cursors.Default;
                }
            }
            else
            {
                link.ShowPreviewDialog();

                if (XtraMessageBox.Show("İşlem tamamlandı mı?", "Print", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
                {
                    MemoryStream ms = new MemoryStream();
                    link.ExportToPdf(ms);
                    ms.Seek(0, System.IO.SeekOrigin.Begin);
                    int    len = (int)ms.Length;
                    byte[] img = new byte[len];
                    ms.Read(img, 0, len);
                    ms.Close();

                    teklifQueriesTableAdapter.DOC_INS2("TST", tstID, string.Format("Teklif {0}", tstGridView.GetFocusedRowCellValue(colRVSNOt)), ".pdf", "TKLF", Program.USR, len, img);
                    rptInfo rpti = new rptInfo();
                    rpti.put("TKLF", "TST", tstID, Program.USR, "F", "eMail Teklif");
                    Program.MF.reportDone(rpti, false);
                }
            }
        }