async Task CreateDocumentImages(C1PdfDocument pdf)
        {
            // calculate page rect (discounting margins)
            var rcPage = PdfUtils.PageRectangle(pdf);
            InMemoryRandomAccessStream ras = new InMemoryRandomAccessStream();

            // title
            Font font = new Font("Segoe UI Light", 16, PdfFontStyle.Italic);

            pdf.DrawString(Strings.ImagesDocumentTitle, font, Colors.Black, new Rect(72, 72, 400, 100));

            // load image into writeable bitmap
            WriteableBitmap wb   = new WriteableBitmap(880, 660);
            var             file = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///PdfSamplesLib/Assets/pic.jpg"));

            wb.SetSource(await file.OpenReadAsync());

            // simple draw image
            var rcPic = new Rect(72, 100, wb.PixelWidth / 5.0, wb.PixelHeight / 5.0);

            pdf.DrawImage(wb, rcPic);

            // draw on page preserving aspect ratio
            var delta = 100.0;

            rcPic = new Rect(new Point(delta, delta), new Point(rcPage.Width - delta, rcPage.Height - delta));
            pdf.DrawImage(wb, rcPic, ContentAlignment.MiddleCenter, Stretch.Uniform);

            // translucent rectangle
            var clr = Color.FromArgb(50, 0, 255, 0);

            pdf.FillRectangle(clr, new Rect(200, 200, 300, 400));
        }
예제 #2
0
        private async void btnRender_Click(object sender, RoutedEventArgs e)
        {
            await Task.Delay(TimeSpan.FromMilliseconds(100));

            pdf.Clear();
            progressRing.IsActive = true;
            panel.Arrange(pdf.PageRectangle);

            //1. Export UI as an image and then draw this image in pdf document.
            var renderTargetBitmap = new RenderTargetBitmap();
            await renderTargetBitmap.RenderAsync(panel);

            var wb = new WriteableBitmap(renderTargetBitmap.PixelWidth, renderTargetBitmap.PixelHeight);

            (await renderTargetBitmap.GetPixelsAsync()).CopyTo(wb.PixelBuffer);
            var rect = new Rect(0, 0, renderTargetBitmap.PixelWidth, renderTargetBitmap.PixelHeight);

            pdf.DrawImage(wb, rect);

            //2. Draw every UI elements inside the panel in pdf document.
            //await pdf.DrawElement(panel, pdf.PageRectangle);
            PdfUtils.SetDocumentInfo(pdf, Strings.RenderUIDocumentTitle);
            await pdfDocSource.LoadFromStreamAsync(PdfUtils.SaveToStream(pdf).AsRandomAccessStream());

            progressRing.IsActive = false;
        }
예제 #3
0
        private void ConvertToPdf(List <Image> images)
        {
            RectangleF rect      = imagePdfDocument.PageRectangle;
            bool       firstPage = true;

            foreach (var selectedimg in images)
            {
                if (!firstPage)
                {
                    imagePdfDocument.NewPage();
                }
                firstPage = false;
                rect.Inflate(-72, -72);
                imagePdfDocument.DrawImage(selectedimg, rect);
            }
        }
예제 #4
0
        //---------------------------------------------------------------------------------
        #region ** images

        static void CreateDocumentImages(C1PdfDocument pdf)
        {
            // calculate page rect (discounting margins)
            Rect rcPage = PdfUtils.PageRectangle(pdf);

            // load image into writeable bitmap
            BitmapImage bi = new BitmapImage();

            bi.BeginInit();
            bi.StreamSource = DataAccess.GetStream("borabora.jpg");
            bi.EndInit();
            var wb = new WriteableBitmap(bi);

            // center image on page preserving aspect ratio
            pdf.DrawImage(wb, rcPage, ContentAlignment.MiddleCenter, Stretch.Uniform);
        }
예제 #5
0
        private RectangleF RenderMultiPageImage(ref C1PdfDocument c1pdf, RectangleF rcPage, RectangleF rc, string fileName, Fax fax, bool addMetaText)
        {
            //Image img = Image.FromFile(fileName);
            MemoryStream ms  = new MemoryStream(File.ReadAllBytes(fileName));
            Image        img = Image.FromStream(ms);

            FrameDimension oDimension = new FrameDimension(img.FrameDimensionsList[0]);
            int            FrameCount = img.GetFrameCount(oDimension);

            for (int i = 0; i < FrameCount; i++)
            {
                // calculate image height
                // based on image size and page size
                rc.Height = Math.Min(img.Height / 96f * 72, rcPage.Height);

                // skip page if necessary
                if (rc.Bottom > rcPage.Bottom)
                {
                    c1pdf.NewPage();
                    rc.Y = rcPage.Y;
                }

                // draw solid background (mainly to see transparency)
                rc.Inflate(+2, +2);
                c1pdf.FillRectangle(Brushes.White, rc);
                rc.Inflate(-2, -2);

                // draw image (keep aspect ratio)
                img.SelectActiveFrame(oDimension, i);
                string fn = System.IO.Path.GetFileName(fileName);
                fn = _workingFolder + fn.Substring(0, fn.Length - 4) + "-" + i + ".tif";
                img.Save(fn);
                //Image img1 = Image.FromFile(fn);
                MemoryStream ms1  = new MemoryStream(File.ReadAllBytes(fn));
                Image        img1 = Image.FromStream(ms1);

                c1pdf.DrawImage(img1, rc, ContentAlignment.MiddleCenter, ImageSizeModeEnum.Scale);
                // update rectangle
                rc.Y = rc.Bottom + 20;

                if ((i == 0) && (addMetaText == true))
                {
                    AddMetaText(c1pdf, fax);
                }
            }
            return(rc);
        }
예제 #6
0
        void CreateDocumentVisualTree(C1PdfDocument pdf, FrameworkElement targetElement)
        {
            // set up to render
            var font = new Font("Courier", 14);
            var img  = new WriteableBitmap(CreateBitmap(targetElement));

            // go render
            bool firstPage = true;

            foreach (Stretch stretch in new Stretch[] { Stretch.Fill, Stretch.None, Stretch.Uniform, Stretch.UniformToFill })
            {
                // add page break
                if (!firstPage)
                {
                    pdf.NewPage();
                }
                firstPage = false;

                // set up to render
                var alignment = ContentAlignment.TopLeft;
                var rc        = PdfUtils.Inflate(pdf.PageRectangle, -72, -72);
                rc.Height /= 2;

                // render element as image
                pdf.DrawString("Element as Image, Stretch: " + stretch.ToString(), font, Colors.Black, rc);
                rc = PdfUtils.Inflate(rc, -20, -20);
                pdf.DrawImage(img, rc, alignment, stretch);
                pdf.DrawRectangle(Colors.Green, rc);
                rc = PdfUtils.Inflate(rc, +20, +20);
                pdf.DrawRectangle(Colors.Green, rc);

                // move to bottom of the page
                rc = PdfUtils.Offset(rc, 0, rc.Height + 20);

                // render element
                pdf.DrawString("Element as VisualTree, Stretch: " + stretch.ToString(), font, Colors.Black, rc);
                rc = PdfUtils.Inflate(rc, -20, -20);
                pdf.DrawElement(targetElement, rc, alignment, stretch);
                pdf.DrawRectangle(Colors.Green, rc);
                rc = PdfUtils.Inflate(rc, +20, +20);
                pdf.DrawRectangle(Colors.Green, rc);
            }
        }
예제 #7
0
        void DrawPage(PreviewPageInfo[] pages, int index)
        {
            // skip to next page
            if (index > 0)
            {
                _pdf.NewPage();
            }

            // get preview page info
            var pi = pages[index];

            // adjust page size
            var ps = pi.PhysicalSize;

            _pdf.PageSize = new SizeF(ps.Width / 100f * 72, ps.Height / 100f * 72);

            // draw image
            var img = pi.Image;

            _pdf.DrawImage(img, _pdf.PageRectangle);
        }
예제 #8
0
        private void ConvertToPdf(List <Image> images, C1PdfDocument imageToPdf)
        {
            RectangleF rect      = imageToPdf.PageRectangle;
            bool       firstPage = true;

            foreach (var selectedimg in images)
            {
                if (!firstPage)
                {
                    imageToPdf.NewPage();
                }
                firstPage = false;
                rect.Inflate(-72, -72);
                try
                {
                    imageToPdf.DrawImage(selectedimg, rect);
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message, Properties.Resources.dialog_error);
                }
            }
        }
 private void ConvertToPdf(List <Image> images)
 {
     //Coversion to pdf.
     try
     {
         RectangleF rect      = imagePdfDocument.PageRectangle;
         bool       firstPage = true;
         foreach (var selectedimg in images)
         {
             if (!firstPage)
             {
                 imagePdfDocument.NewPage();
             }
             firstPage = false;
             rect.Inflate(-72, -72);
             imagePdfDocument.DrawImage(selectedimg, rect);
         }
     }
     catch (Exception excp)
     {
         MessageBox.Show("Exception occured: " + excp);
     }
 }
예제 #10
0
        void CreateDocumentVisualTree(C1PdfDocument pdf, FrameworkElement targetElement)
        {
            // set up to render
            var font = new Font("Courier", 14);
            var img = new WriteableBitmap(CreateBitmap(targetElement));

            // go render
            bool firstPage = true;
            foreach (Stretch stretch in new Stretch[] { Stretch.Fill, Stretch.None, Stretch.Uniform, Stretch.UniformToFill })
            {
                // add page break
                if (!firstPage)
                {
                    pdf.NewPage();
                }
                firstPage = false;

                // set up to render
                var alignment = ContentAlignment.TopLeft;
                var rc = PdfUtils.Inflate(pdf.PageRectangle, -72, -72);
                rc.Height /= 2;

                // render element as image
                pdf.DrawString("Element as Image, Stretch: " + stretch.ToString(), font, Colors.Black, rc);
                rc = PdfUtils.Inflate(rc, -20, -20);
                pdf.DrawImage(img, rc, alignment, stretch);
                pdf.DrawRectangle(Colors.Green, rc);
                rc = PdfUtils.Inflate(rc, +20, +20);
                pdf.DrawRectangle(Colors.Green, rc);

                // move to bottom of the page
                rc = PdfUtils.Offset(rc, 0, rc.Height + 20);

                // render element
                pdf.DrawString("Element as VisualTree, Stretch: " + stretch.ToString(), font, Colors.Black, rc);
                rc = PdfUtils.Inflate(rc, -20, -20);
                pdf.DrawElement(targetElement, rc, alignment, stretch);
                pdf.DrawRectangle(Colors.Green, rc);
                rc = PdfUtils.Inflate(rc, +20, +20);
                pdf.DrawRectangle(Colors.Green, rc);
            }
        }
        private void printReserveVaccinePDF()
        {
            String pathFolder = "", filename = "", datetick = "";
            int    gapLine = 20, gapLine1 = 15, gapX = 40, gapY = 20, xCol2 = 200, xCol1 = 160, xCol3 = 300, xCol4 = 390, xCol5 = 500;
            Size   size = new Size();

            C1PdfDocument       pdf = new C1PdfDocument();
            C1PdfDocumentSource pds = new C1PdfDocumentSource();
            StringFormat        _sfRight, _sfRightCenter;

            //Font _fontTitle = new Font("Tahoma", 15, FontStyle.Bold);
            _sfRight                     = new StringFormat();
            _sfRight.Alignment           = StringAlignment.Far;
            _sfRightCenter               = new StringFormat();
            _sfRightCenter.Alignment     = StringAlignment.Far;
            _sfRightCenter.LineAlignment = StringAlignment.Center;

            Font titleFont = new Font(bc.iniC.pdfFontName, bc.pdfFontSizetitleFont, FontStyle.Bold);
            Font hdrFont   = new Font(bc.iniC.pdfFontName, bc.pdfFontSizehdrFont, FontStyle.Regular);
            Font hdrFontB  = new Font(bc.iniC.pdfFontName, 16, FontStyle.Bold);
            Font ftrFont   = new Font(bc.iniC.pdfFontName, 8);
            Font txtFont   = new Font(bc.iniC.pdfFontName, bc.pdfFontSizetxtFont, FontStyle.Regular);

            pdf.FontType = FontTypeEnum.Embedded;

            RectangleF rcPage = pdf.PageRectangle;

            rcPage = RectangleF.Empty;
            rcPage.Inflate(-72, -92);
            rcPage.Location = new PointF(rcPage.X, rcPage.Y + titleFont.SizeInPoints + 10);
            rcPage.Size     = new SizeF(0, titleFont.SizeInPoints + 3);
            rcPage.Width    = 110;

            Image loadedImage;

            loadedImage = Resources.LOGO_BW_tran;
            float newWidth  = loadedImage.Width * 100 / loadedImage.HorizontalResolution;
            float newHeight = loadedImage.Height * 100 / loadedImage.VerticalResolution;

            float widthFactor  = 4.8F;
            float heightFactor = 4.8F;

            if (widthFactor > 1 | heightFactor > 1)
            {
                if (widthFactor > heightFactor)
                {
                    widthFactor = 1;
                    newWidth    = newWidth / widthFactor;
                    newHeight   = newHeight / widthFactor;
                    //newWidth = newWidth / 1.2;
                    //newHeight = newHeight / 1.2;
                }
                else
                {
                    newWidth  = newWidth / heightFactor;
                    newHeight = newHeight / heightFactor;
                }
            }

            RectangleF recf = new RectangleF(15, 15, (int)newWidth, (int)newHeight);

            pdf.DrawImage(loadedImage, recf);
            rcPage.X = gapX + recf.Width - 10;
            rcPage.Y = gapY;
            RectangleF rc = rcPage;

            string[] filePaths = Directory.GetFiles(System.IO.Path.GetDirectoryName(Application.ExecutablePath) + "\\slip\\", txtID.Text.Trim() + "*.jpg");
            if (filePaths.Length > 0)
            {
                int i = 1, xx = 40;
                foreach (String filename1 in filePaths)
                {
                    Image loadedImage1, resizedImage1 = null;
                    loadedImage1 = Image.FromFile(filename1);
                    int originalWidth = 0;
                    originalWidth = loadedImage1.Width;
                    int newWidth1 = 200;

                    resizedImage1 = loadedImage1.GetThumbnailImage(newWidth1, (newWidth1 * loadedImage1.Height) / originalWidth, null, IntPtr.Zero);
                    RectangleF recf1 = new RectangleF(i == 1?xx: newWidth1 + 10, 380, (int)newWidth1, (int)resizedImage1.Height);
                    pdf.DrawImage(loadedImage1, recf1);
                    i++;
                }
            }
            Image      qrcode = c1BarCode1.Image;
            RectangleF recf2  = new RectangleF(350, 500, qrcode.Width, qrcode.Height);

            pdf.DrawImage(qrcode, recf2);

            size         = bc.MeasureString(bc.iniC.hostname, titleFont);
            rcPage.Width = size.Width;
            pdf.DrawString(bc.iniC.hostname, titleFont, Brushes.Black, rcPage);
            gapY        += gapLine;
            rcPage.Y     = gapY;
            size         = bc.MeasureString(bc.iniC.hostaddresst, hdrFont);
            rcPage.Width = size.Width;
            pdf.DrawString(bc.iniC.hostaddresst, hdrFont, Brushes.Black, rcPage);

            String dose = "", amt11 = "";
            int    amt111 = 0;

            dose = txtDose.Text.Replace("จอง", "").Replace("เข็ม", "").Replace("3,300", "").Replace("1,650", "").Replace("4,950", "").Trim().Replace("6,600", "").Trim().Replace("8,250", "")
                   .Replace("8,250", "").Replace("9,900", "").Replace("11,500", "").Replace("13,200", "").Replace("14,850", "").Replace("16,500", "").Replace("18,150", "").Replace("19,800", "").Trim();
            int.TryParse(dose, out amt111);
            amt111 *= 1650;

            gapY += gapLine;
            gapY += gapLine;
            gapY += gapLine;
            gapX  = xCol1;
            rc.X  = (pdf.PageSize.Width / 2) - 15;
            rc.Y  = gapY;
            pdf.DrawString("ใบจองวัคซีน", titleFont, Brushes.Black, rc);

            gapY += gapLine;
            gapY += gapLine;
            gapX  = 30;
            rc.X  = gapX;
            rc.Y  = gapY;
            pdf.DrawString("ข้าพเจ้า ชื่อ-นามสกุล", txtFont, Brushes.Black, rc);
            rc.X = 110;
            rc.Y = rc.Y - 4;
            pdf.DrawString(txtName.Text, hdrFont, Brushes.Black, rc);
            pdf.DrawLine(Pens.Gray, 100, gapY + 15, 380, gapY + 15);
            rc.X = 400;
            rc.Y = gapY;
            pdf.DrawString("เลขที่ประชาชน", txtFont, Brushes.Black, rc);
            rc.X = 470;
            rc.Y = rc.Y - 4;
            pdf.DrawString(txtPID.Text, hdrFont, Brushes.Black, rc);
            pdf.DrawLine(Pens.Gray, 455, gapY + 15, 590, gapY + 15);

            gapY += gapLine;
            gapX  = 30;
            rc.X  = gapX;
            rc.Y  = gapY;
            pdf.DrawString("ที่อยู่ปัจจุบัน", txtFont, Brushes.Black, rc);
            rc.X = 75;
            rc.Y = rc.Y - 4;
            pdf.DrawString(txtAddress.Text, hdrFont, Brushes.Black, rc);
            pdf.DrawLine(Pens.Gray, 70, gapY + 15, 400, gapY + 15);
            rc.X = 420;
            rc.Y = gapY;
            pdf.DrawString("เบอร์ที่ติดต่อได้", txtFont, Brushes.Black, rc);
            rc.X = 480;
            rc.Y = rc.Y - 4;
            pdf.DrawString(txtMobile.Text, hdrFont, Brushes.Black, rc);
            pdf.DrawLine(Pens.Gray, 470, gapY + 15, 590, gapY + 15);

            gapY    += gapLine;
            gapX     = 30;
            rc.X     = gapX;
            rc.Y     = gapY;
            rc.Width = 610;
            pdf.DrawString("ขอจองวัคซีนทางเลือก MODERNA และชำระเงิน  จำนวน             โดส   ราคา 1,650 บาทต่อโดส", txtFont, Brushes.Black, rc);
            rc.X = 19;
            rc.Y = rc.Y - 4;
            pdf.DrawString(dose, hdrFont, Brushes.Black, rc);
            pdf.DrawLine(Pens.Gray, 215, gapY + 15, 220, gapY + 15);

            gapY += gapLine;
            gapX  = 30;
            rc.X  = gapX;
            rc.Y  = gapY;
            pdf.DrawString("ราคาดังกล่าวเป็นราคาที่ รวมค่าวัคซีน  ค่าประกัน  ค่าบริการสำหรับการฉีด ไม่รวมค่าแพทย์ ถ้าต้องการพบแพทย์  โดยชำระเงินเต็มจำนวน", txtFont, Brushes.Black, rc);

            gapY += gapLine;
            gapX  = 30;
            rc.X  = gapX;
            rc.Y  = gapY;
            pdf.DrawString("โดสละ 1,650  รวม            โดส  เป็นเงิน                               บาท  ตามใบเจองเลขที่                            ", txtFont, Brushes.Black, rc);
            rc.X = 100;
            rc.Y = rc.Y - 4;
            pdf.DrawString(dose, hdrFont, Brushes.Black, rc);
            rc.X = 175;
            rc.Y = rc.Y;
            pdf.DrawString(amt111.ToString("#,###.00"), hdrFont, Brushes.Black, rc);
            rc.X = 310;
            rc.Y = rc.Y;
            pdf.DrawString(txtID.Text.Trim(), hdrFont, Brushes.Black, rc);
            pdf.DrawLine(Pens.Gray, 95, gapY + 15, 100, gapY + 15);
            pdf.DrawLine(Pens.Gray, 165, gapY + 15, 220, gapY + 15);
            pdf.DrawLine(Pens.Gray, 340, gapY + 15, 470, gapY + 15);

            gapY += gapLine;
            gapX  = 30;
            rc.X  = gapX;
            rc.Y  = gapY;
            pdf.DrawString("หมายเหตุ  1.ทางโรงพยาบาลจะนัดรับวัคซีนหลังจาก โรงพยาบาลได้รับการจัดสรรจากหน่วยงานภาครัฐ  ตามที่อยู่และเบอร์โทรที่ได้ให้ไว้", txtFont, Brushes.Black, rc);

            gapY += gapLine;
            gapX  = 30;
            rc.X  = 67;
            rc.Y  = gapY;
            pdf.DrawString("2.กรณีได้รับจัดสรรวัคซีนมาไม่เพียงพอต่อการจองที่โรงพยาบาลได้รับจองตามที่ได้รับจัดสรร  ทางโรงพยาบาลจะเรียงลำดับการเข้ารับวัคซีนตามลำดดับการจองก่อน-หลัง", txtFont, Brushes.Black, rc);

            gapY += gapLine;
            gapX  = 30;
            rc.X  = 67;
            rc.Y  = gapY;
            pdf.DrawString("และจะคืนเงินมัดจำให้เต็มจำนวน  กรณีจองแล้วไม่ได้", txtFont, Brushes.Black, rc);

            gapY += gapLine;
            gapX  = 30;
            rc.X  = 67;
            rc.Y  = gapY;
            pdf.DrawString("3.ทางโรงพยาบาลสงวนสิทธิ์ยกเลิกการของโดยไม่คืนเงินกรณีผู้จองไม่มารับวัคซีนตามช่วงเวลาที่กำหนด", txtFont, Brushes.Black, rc);

            gapY += gapLine;
            gapX  = 30;
            rc.X  = 67;
            rc.Y  = gapY;
            pdf.DrawString("4.ห้ามนำวัคซีนไปขายต่อเพราะเป็นสินค้าควบคุมราคา", txtFont, Brushes.Black, rc);

            gapY += gapLine;
            gapX  = 30;
            rc.X  = 67;
            rc.Y  = gapY;
            pdf.DrawString("5.ต้องมารับบริการฉีดวัคซีน ที่โรงพยาบาล บางนา5 เท่านั้น", txtFont, Brushes.Black, rc);

            gapY += gapLine;
            gapY += gapLine;
            gapY += gapLine;
            gapY += gapLine;
            gapX  = 30;
            rc.X  = 370;
            rc.Y  = gapY;
            pdf.DrawString("ผู้จอง", txtFont, Brushes.Black, rc);
            pdf.DrawLine(Pens.Gray, 400, gapY + 15, 500, gapY + 15);

            gapY += gapLine;
            gapX  = 30;
            rc.X  = 370;
            rc.Y  = gapY;
            pdf.DrawString("ผู้รับจอง  on line", txtFont, Brushes.Black, rc);
            pdf.DrawLine(Pens.Gray, 400, gapY + 15, 500, gapY + 15);

            String txt = "";

            if (txtDate.Text.Trim().Length > 9)
            {
                txt = bc.datetoShow(txtDate.Text.Trim()) + " " + txtDate.Text.Substring(10).Trim();
            }
            else
            {
                txt = txtDate.Text.Trim();
            }
            gapY += gapLine;
            gapX  = 30;
            rc.X  = 370;
            rc.Y  = gapY;
            pdf.DrawString("วันที่จอง   " + txt, txtFont, Brushes.Black, rc);
            pdf.DrawLine(Pens.Gray, 400, gapY + 15, 500, gapY + 15);

            gapY += gapLine;
            gapY += gapLine;
            gapY += gapLine;
            gapY += gapLine;
            gapY += gapLine;
            gapY += gapLine;
            gapY += gapLine;
            gapY += gapLine;
            gapY += gapLine;
            gapY += gapLine;
            gapY += gapLine;
            gapY += gapLine;
            gapY += gapLine;
            gapX  = 30;
            rc.X  = gapX;
            rc.Y  = gapY;
            pdf.DrawString("สอบถามเพิ่มเติมโทร 02 138 1155-60 ต่อ 143   ", txtFont, Brushes.Black, rc);
            gapY += gapLine;
            gapX  = 30;
            rc.X  = gapX;
            rc.Y  = gapY;
            pdf.DrawString("วันจันทร์ ถึง วันศุกร์ เวลา 8.00 - 16.00 น. (ปิดพักเที่ยง)   ", txtFont, Brushes.Black, rc);
            gapY += gapLine;
            gapX  = 30;
            rc.X  = gapX;
            rc.Y  = gapY;
            pdf.DrawString("line @657bkkyq", txtFont, Brushes.Black, rc);


            RectangleF rcHdr = new RectangleF();

            rcHdr.Width  = pdf.PageSize.Width - 20;
            rcHdr.Height = pdf.PageSize.Height - 20;
            rcHdr.X      = 10;
            rcHdr.Y      = 10;
            String PathName = "medical", fileName = "";

            datetick = DateTime.Now.Ticks.ToString();
            if (!Directory.Exists("report"))
            {
                Directory.CreateDirectory("report");
            }
            fileName = "report\\" + txtID.Text.Trim() + "_" + datetick + ".pdf";
            if (File.Exists(fileName))
            {
                File.Delete(fileName);
                System.Threading.Thread.Sleep(100);
            }
            pdf.DrawRectangle(Pens.Black, rcHdr);       // ตาราง

            String path = Path.GetDirectoryName(Application.ExecutablePath);

            pdf.Save(path + "\\" + fileName);
            Process.Start(fileName);
        }
예제 #12
0
        static void CreateDocumentImages(C1PdfDocument pdf)
        {
            // calculate page rect (discounting margins)
            Rect rcPage = PdfUtils.PageRectangle(pdf);

            // load image into writeable bitmap
            BitmapImage bi = new BitmapImage();
            bi.BeginInit();
            bi.StreamSource = DataAccess.GetStream("borabora.jpg");
            bi.EndInit();
            var wb = new WriteableBitmap(bi);

            // center image on page preserving aspect ratio
            pdf.DrawImage(wb, rcPage, ContentAlignment.MiddleCenter, Stretch.Uniform);
        }