Example #1
0
        /// <summary>
        /// Bat dau in Document
        /// </summary>
        /// <param name="panelMain"></param>
        public static void BeginPrint(FPdfPanel panelMain)
        {
            if (doc == null && prDialog == null)
            {
                if (panelMain.pnDetail != null && panelMain.pnDetail.DataSource != null)
                {
                    FPdfPanel detail = panelMain.pnDetail;
                    NumberPage = detail.DataSource.Rows.Count / detail.MaxRow;
                    if ((detail.DataSource.Rows.Count % detail.MaxRow) != 0)
                    {
                        NumberPage++;
                    }
                    MaxRow = detail.MaxRow;
                }
                PanelMain = panelMain;
                PaperSize pageSize = new PaperSize("PaperA4", panelMain.Size.Width, panelMain.Size.Height);
                doc = new PrintDocument();
                doc.DefaultPageSettings.PaperSize = pageSize;
                //doc.DefaultPageSettings.Landscape = true;
                doc.PrintPage += new PrintPageEventHandler(On_PrintPage);


                prDialog          = new PrintPreviewDialog();
                prDialog.Document = doc;
                prDialog.Width    = Screen.PrimaryScreen.WorkingArea.Width;
                prDialog.Height   = Screen.PrimaryScreen.WorkingArea.Height;
            }
        }
Example #2
0
 public static void PrintPdfFile(FPdfPanel panel, PagePdf pagePdf)
 {
     if (doc != null)
     {
         if (panel.pnDetail != null && panel.pnDetail.DataSource != null)
         {
             FPdfPanel detail = panel.pnDetail;
             NumberPage = detail.DataSource.Rows.Count / detail.MaxRow;
             if ((detail.DataSource.Rows.Count % detail.MaxRow) != 0)
             {
                 NumberPage++;
             }
             MaxRow = detail.MaxRow;
         }
         for (int i = 1; i <= NumberPage; i++)
         {
             // moi vong lap la in mot trang Pdf
             CurPage = i;
             // In het cac control trong trang
             PrintAllControlInPanel(panel, pagePdf, CurPage, new FosPoint(0, 0));
             //In het cac line trong trang sau cung
             foreach (FosLine line in lsLineInpage)
             {
                 PrintPdfLine(line, pagePdf);
             }
             //Neu khong phai trang cuoi thi tao moi trang de in tiep
             if (i != NumberPage)
             {
                 CreateNewPage();
             }
         }
     }
 }
Example #3
0
 public static void CoppyFPFPanelDetail(FPdfPanel panelSource, FPdfPanel panelDest, int row)
 {
     panelDest.Size        = panelSource.Size;
     panelDest.DataSource  = panelSource.DataSource;
     panelDest.lsPdfLine   = panelSource.lsPdfLine;
     panelDest.BorderStyle = panelSource.BorderStyle;
     //panelDest.AddControlEx += new AddControl(  panelSource.AddControlEx);
     panelSource.CoppyAddEvent(panelDest);
     foreach (Control ct in panelSource.Controls)
     {
         if (ct is FPdfText)
         {
             FPdfText tb = new FPdfText();
             CopyFPdfText(ct as FPdfText, tb, row);
             panelDest.Controls.Add(tb);
             panelDest.RaiseAddControlEvent(tb);
         }
         else if (ct is FPdfLabel)
         {
             FPdfLabel lb = new FPdfLabel();
             CopyFPdfLabel(ct as FPdfLabel, lb, row);
             panelDest.Controls.Add(lb);
             panelDest.RaiseAddControlEvent(lb);
         }
     }
 }
Example #4
0
        /// <summary>
        /// Sau khi in xong goi ham nay de reset lai cac bien dung de in lan sau
        /// </summary>
        public static void EndPrint()
        {
            doc      = null;
            prDialog = null;
            FPdfPanel PanelMain = null;

            NumberPage   = 1;
            CurPage      = 1;
            MaxRow       = 0;
            lsLineInpage = new List <FosLine>();
        }
Example #5
0
 /// <summary>
 /// In tat ca cac control co trong Panel
 /// </summary>
 /// <param name="panel"></param>
 /// <param name="page"></param>
 /// <param name="curPage"></param>
 /// <param name="rootPoint"></param>
 public static void PrintAllControlInPanel(Graphics g, FPdfPanel panel, int curPage, FosPoint rootPoint)
 {
     //Add line
     if (panel.lsPdfLine.Count > 0)
     {
         foreach (FosLine line in panel.lsPdfLine)
         {
             if (curPage == 1)
             {
                 FosLine lineNew = new FosLine(new FosPoint(), new FosPoint());
                 lineNew.PointStart.XPoint = rootPoint.XPoint + line.PointStart.XPoint;
                 lineNew.PointStart.YPoint = rootPoint.YPoint + line.PointStart.YPoint;
                 lineNew.PointDest.XPoint  = rootPoint.XPoint + line.PointDest.XPoint;
                 lineNew.PointDest.YPoint  = rootPoint.YPoint + line.PointDest.YPoint;
                 lsLineInpage.Add(lineNew);
             }
         }
     }
     // In hinh dau tien
     foreach (Control c in panel.Controls)
     {
         if (c is PictureBox)
         {
             PictureBox pB = c as PictureBox;
             PrintImage(g, pB, rootPoint);
         }
     }
     //Sau do in chu
     foreach (Control c in panel.Controls)
     {
         //if (c is FPdfText)
         //{
         //    FPdfText FPdfText = c as FPdfText;
         //    PrinString(FPdfText, page, rootPoint, curPage);
         //}
         if (c is FPdfLabel)
         {
             FPdfLabel FPdfLabel = c as FPdfLabel;
             PrintString(g, FPdfLabel, rootPoint, curPage);
         }
         //in Panel con
         if (c is FPdfPanel)
         {
             FPdfPanel FPdfPanelChirld = c as FPdfPanel;
             //inborder
             if (FPdfPanelChirld.BorderStyle == BorderStyle.FixedSingle)
             {
                 PrintBorderForControl(FPdfPanelChirld, rootPoint);
             }
             PrintAllControlInPanel(g, FPdfPanelChirld, curPage, new FosPoint(rootPoint.XPoint + FPdfPanelChirld.Location.X, rootPoint.YPoint + FPdfPanelChirld.Location.Y));
         }
     }
 }
Example #6
0
 /// <summary>
 /// Ve cac dong detail
 /// </summary>
 /// <param name="panel"></param>
 public static void DrawAllDetail(FPdfPanel panel)
 {
     if (panel.pnDetail != null)
     {
         FPdfPanel detail = panel.pnDetail;
         for (int i = 1; i < detail.MaxRow; i++)
         {
             FPdfPanel detailCoppy    = new FPdfPanel();
             Point     locationDetail = new Point(detail.Location.X, detail.Location.Y + (detail.Size.Height * i));
             detailCoppy.Location = locationDetail;
             CoppyFPFPanelDetail(detail, detailCoppy, i);
             detail.Parent.Controls.Add(detailCoppy);
         }
     }
 }