IsOpen() публичный Метод

Checks if the document is open.
public IsOpen ( ) : bool
Результат bool
Пример #1
1
        /// <summary>
        /// Render all data add and writes it to the specified writer
        /// </summary>
        /// <param name="model">
        /// The model to render
        /// </param>
        /// <param name="os">
        /// The output to write to
        /// </param>
        public override void RenderAllTables(IDataSetModel model, Stream os)
        {
            // TODO check the number of horizontal & vertical key values to determine the orientation of the page
            var doc = new Document(this._pageSize, 80, 50, 30, 65);

            // This doesn't seem to do anything...
            doc.AddHeader(Markup.HTML_ATTR_STYLESHEET, "style/pdf.css");
            doc.AddCreationDate();
            doc.AddCreator("NSI .NET Client");
            try
            {
                PdfWriter.GetInstance(doc, os);
                doc.Open();
                this.WriteTableModels(model, doc);
            }
            catch (DocumentException ex)
            {
                Trace.Write(ex.ToString());
                LogError.Instance.OnLogErrorEvent(ex.ToString());
            }
            catch (DbException ex)
            {
                Trace.Write(ex.ToString());
                LogError.Instance.OnLogErrorEvent(ex.ToString());
            }
            finally
            {
                if (doc.IsOpen())
                {
                    doc.Close();
                }
            }
        }
Пример #2
0
        //PDF Ayarları
        public void PdfHazirla()
        {
            iTextSharp.text.Document fis        = new iTextSharp.text.Document(new iTextSharp.text.Rectangle(300, 600));
            iTextSharp.text.Font     normalFont = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.COURIER, 10f, iTextSharp.text.Font.NORMAL);

            iTextSharp.text.Font italikFont = new iTextSharp.text.Font(iTextSharp.text.Font.FontFamily.TIMES_ROMAN, 10f, iTextSharp.text.Font.ITALIC);



            iTextSharp.text.Font tahomaFont = iTextSharp.text.FontFactory.GetFont("Tahoma", 10f);


            PdfWriter.GetInstance(fis, new FileStream("D:e-fatura.pdf", FileMode.Create));
            fis.AddAuthor("Yunus Turhan");
            fis.AddCreationDate();
            fis.AddSubject("Bilgilendirme Maili");



            if (fis.IsOpen() == false)
            {
                fis.Open();
            }

            fis.Add(new Paragraph(mailicerigi.Text));

            fis.Close();
        }
        private void btnDokumanlastir_Click(object sender, EventArgs e)
        {
            string     cikti = "", demirbasKodu = "";
            var        demirbaslar  = db.tblOdaDemirbas.Where(w => w.odaDemirbasAtamaID == secilenOda.odaDemirbasAtamaID).ToList();
            int        siraNumarasi = 1;
            tblDemirba tempDemirbas;

            foreach (var item in demirbaslar)
            {
                demirbasKodu += secilenFakulte.fakulteID + "." + secilenDepartman.departmanID + "." + item.demirbasID;
                cikti        += "   " + siraNumarasi + "    " + demirbasKodu + "    " + item.adet + Environment.NewLine;
            }

            try
            {
                iTextSharp.text.Document raporum = new iTextSharp.text.Document();
                // PDF oluşturması ve konumun belirlenmesi
                PdfWriter.GetInstance(raporum, new FileStream("C:\\Users\\DELL\\Desktop\\Yazılım Sınama Proje\\Proje\\DemirbaşTakip\\EntityFrameworkDeneme\\V5-MDI\\MDIFormDenemesi\\Dokumanlar\\Raporum.pdf", FileMode.Create));
                if (raporum.IsOpen() == false)
                {
                    raporum.Open();
                    raporum.Add(new Paragraph(cikti));
                    raporum.Close();
                    MessageBox.Show("Döküman başarı ile oluşturuldu");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("raporum pdf dosyası kapatılmadan kayıt yapılamaz!");
            }
        }
Пример #4
0
        private void pdfdeneme_Load(object sender, EventArgs e)
        {
            iTextSharp.text.Document document = new iTextSharp.text.Document();

            PdfWriter.GetInstance(document, new FileStream(@"C:\deneme.pdf", FileMode.Create));

            BaseFont arial = BaseFont.CreateFont("C:\\windows\\fonts\\arial.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);

            iTextSharp.text.Font font = new iTextSharp.text.Font(arial, 12, iTextSharp.text.Font.NORMAL);



            if (document.IsOpen() == false)
            {
                document.Open();

                iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(@"C:\info.png");
                img.ScalePercent(40f);
                document.Add(img);
                string text = "Kisi Ad : Adem \n" +
                              "Kisi Soyad : Kesim \n" +
                              "Kisi Ünvan : Yazılımcı";



                text = TurkceKarakter(text);
                document.Add(new Paragraph(text, font));

                document.Add(img);

                document.Close();
            }
        }
        private void btn_Update_Click(object sender, EventArgs e)
        {
            //the library for create a new pdf document
            iTextSharp.text.Document report = new iTextSharp.text.Document();
            //file path of newly created pdf file to save
            PdfWriter.GetInstance(report, new FileStream(@"C:\Users\Asus\Desktop\UPLOADFILES\" + textboxFileName.Text, FileMode.Create));
            //Author name, need for create a new pdf document
            report.AddAuthor(lbl_Author.Text);
            //Creation Date, need for create a new pdf document
            report.AddCreationDate();
            //Creator, need for create a new pdf document
            report.AddCreator(lbl_Creator.Text);
            //Subject, need for create a new pdf document
            report.AddSubject(lbl_Subject.Text);
            //Keywords, need for create a new pdf document
            report.AddKeywords(lbl_Keyword.Text);

            if (report.IsOpen() == false)
            {
                //open report for create a new pdf document
                report.Open();
            }
            //Paragraph, need for create a new pdf document
            report.Add(new Paragraph(rtxt_Paragraph.Text));

            //open the connection
            db.openConnection();
            //a command line for update the document
            SqlCommand query = new SqlCommand("UPDATE Table_DOCUMENT SET file_Path = @fp, u_ID = @uid WHERE file_ID = @fid", db.getConnection());

            //add the value in the label to @fp
            query.Parameters.AddWithValue("@fp", labelFilePath.Text);
            //add the value in the combobox to @uid
            query.Parameters.AddWithValue("@uid", comboboxUserID.Text);
            //add the value in the label to @fid
            query.Parameters.AddWithValue("@fid", labelFileID.Text);

            //ecevute the query
            if (query.ExecuteNonQuery() == 1)
            {
                MessageBox.Show("DATA WERE UPDATED", "Message Box", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation);
                //return the default values
                labelFilePath.Text     = @"C:\Users\Asus\Desktop\UPLOADFILES";
                textboxFilePath.Text   = "";
                labelFileID.Text       = "";
                lbl_FileName.Text      = "";
                labelCreationDate.Text = "";
                comboboxUserID.Text    = " ";
                rtxt_Paragraph.Text    = "";
            }
            else
            {
                MessageBox.Show("ERROR", "Message Box", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
            }
            //close the report
            report.Close();
            //close the connection
            db.closeConnection();
        }
 /// <summary>
 /// 关闭PDF文档流
 /// </summary>
 /// <param name="doc"></param>
 public void DisposePdf(Document doc)
 {
     if (doc.IsOpen())
     {
         doc.Close();
     }
     doc.Dispose();
 }
Пример #7
0
        void Button3Click(object sender, EventArgs e)
        {
            Document document = new iTextSharp.text.Document();

            PdfWriter.GetInstance(document, new FileStream("cari.pdf", FileMode.Create));

            BaseFont arial = BaseFont.CreateFont("C:\\windows\\fonts\\arial.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
            Font     font  = new Font(arial, 12);

            if (document.IsOpen() == false)
            {
                document.Open();
                //PdfPTable table = new PdfPTable(dataGridView2.Columns.Count);
                document.Add(new Paragraph(TurkceKarakter("             " + comboBox1.Text.ToString() + " Hesabı Cari Ekstresi     "), font));
                document.Add(new Paragraph(TurkceKarakter("                        Tarih                        Bakiye            "), font));

                /*		for (int j = 1; j < dataGridView2.Columns.Count; j++)
                 *      {
                 *              table.AddCell(new Phrase(dataGridView2.Columns[j].HeaderText));
                 *      }
                 *      table.HeaderRows = 1;*/

                for (int i = 0; i < dataGridView2.Rows.Count; i++)
                {
                    if (Convert.ToInt32(dataGridView2[2, i].Value) > 0)
                    {
                        document.Add(new Paragraph(TurkceKarakter("            " + dataGridView2[1, i].Value.ToString() + "            " + dataGridView2[2, i].Value.ToString()), font));
                    }
                    else
                    {
                        document.Add(new Paragraph(TurkceKarakter("            " + dataGridView2[1, i].Value.ToString() + "            " + dataGridView2[2, i].Value.ToString() + " alındı"), font));
                    }
                    document.Add(new Paragraph("  ", font));
                    PdfPTable table = new PdfPTable(5);

                    for (int l = 0; l < kac; l++)
                    {
                        int a = Convert.ToInt32(dataGridView2[0, i].Value);
                        if (a == Convert.ToInt32(dataGrid1[l, 0]) && Convert.ToInt32(dataGridView2[2, i].Value) > 0)
                        {
                            for (int k = 1; k < dataGrid1.VisibleColumnCount; k++)
                            {
                                if (dataGrid1[l, k].ToString() != null)
                                {
                                    table.AddCell(new Phrase(dataGrid1[l, k].ToString()));
                                }
                            }
                        }
                    }
                    document.Add(table);
                }



                document.Close();
                System.Diagnostics.Process.Start("cari.pdf");
            }
        }
Пример #8
0
        private void button4_Click(object sender, EventArgs e)
        {
            /*-------------------------------------*/

            iTextSharp.text.Document raporum = new iTextSharp.text.Document();

            // PDF oluşturması ve konumun belirlenmesi
            Random r = new Random();

            PdfWriter.GetInstance(raporum, new FileStream("C:Raporum" + r.Next() + ".pdf", FileMode.Create));

            //PDF yi yazan özelliğine eklenecek

            raporum.AddAuthor("Selim Silgu"); // PDF Oluşturma Tarihi Ekle

            raporum.AddCreationDate();        // PDF Oluşturma Tarihi

            // PDF oluşturan kişi özelliğine yazılacak

            raporum.AddCreator("Selim Silgu");

            if (raporum.IsOpen() == false)
            {
                raporum.Open();
            }

            raporum.Add(new Paragraph("Ürün Fiyatı : " + urunFiyat.Text + " TL"));
            raporum.Add(new Paragraph("Seri Numarası : " + seriNumarasi.Text));
            raporum.Add(new Paragraph("Ürün ID : " + urunid.ToString()));
            raporum.Add(new Paragraph("Ürün Adı : " + urunAdText.Text));
            raporum.Add(new Paragraph("Ürün Modeli : " + UrunModel.Text));
            raporum.Add(new Paragraph("Islemci Hızı : " + islemciHız.Text));
            raporum.Add(new Paragraph("Cache Bellek : " + cache.Text));
            raporum.Add(new Paragraph("Islemci Teknolojisi : " + islemciTeknoloji.Text));
            raporum.Add(new Paragraph("Islemci Markası : " + islemciMarka.Text));
            raporum.Add(new Paragraph("Islemci Hızı : " + islemciHız.Text));
            raporum.Add(new Paragraph("Çekirdek Sayısı : " + cekirdekSayisi.Text));
            raporum.Add(new Paragraph("RAM Tipi :" + ramTip.Text));
            raporum.Add(new Paragraph("RAM Kapasitesi : " + ramKapasite.Text));
            raporum.Add(new Paragraph("RAM Markası : " + ramMarka.Text));
            raporum.Add(new Paragraph("Disk Türü : " + hddTur.Text));
            raporum.Add(new Paragraph("Disk Markası : " + hddMarka.Text));
            raporum.Add(new Paragraph("USB : " + usb.Text));
            raporum.Add(new Paragraph("Isletim Sistemi : " + isletimSistemi.Text));
            raporum.Add(new Paragraph("Ekran Kartı Tipi : " + ekranKartTip.Text));
            raporum.Add(new Paragraph("Ekran Kartı Markası : " + ekranMarka.Text));
            raporum.Add(new Paragraph("Ekran Kartı Chipset : " + chipset.Text));
            raporum.Add(new Paragraph("Ekran Kartı Kapasitesi : " + kapasite.Text));
            raporum.Add(new Paragraph("Çözünürlük : " + cozunurluk.Text));
            raporum.Add(new Paragraph("Kart Okuyucu : " + kartOkuyucu.Text));
            raporum.Add(new Paragraph("Kamera : " + kamera.Text));
            raporum.Add(new Paragraph("Garanti Süresi : " + GarantiSuresi.Text));
            MessageBox.Show("PDF Dosyanız Oluşmuştur.");

            raporum.Close();

            /*-------------------------------------*/
        }
Пример #9
0
 /// <summary>
 /// Concatenates two or more PDF files into one file.
 /// </summary>
 /// <param name="inputFiles">A string array containing the names of the pdf files to concatenate</param>
 /// <param name="outputFile">Name of the concatenated file.</param>
 public void ConcatenatePDFFiles(String[] inputFiles, String outputFile)
 {
     if (inputFiles != null && inputFiles.Length > 0)
     {
         if (!String.IsNullOrEmpty(outputFile) && !String.IsNullOrWhiteSpace(outputFile))
         {
             var concatDocument = new iTextSharpText.Document();
             var outputCopy     = new iTextSharpPDF.PdfCopy(concatDocument, new FileStream(outputFile, FileMode.Create, FileAccess.ReadWrite));
             concatDocument.Open();
             try
             {
                 for (int loop = 0; loop <= inputFiles.GetUpperBound(0); loop++)
                 {
                     var inputDocument = new iTextSharpPDF.PdfReader(inputFiles[loop]);
                     for (int pageLoop = 1; pageLoop <= inputDocument.NumberOfPages; pageLoop++)
                     {
                         concatDocument.SetPageSize(inputDocument.GetPageSizeWithRotation(pageLoop));
                         outputCopy.AddPage(outputCopy.GetImportedPage(inputDocument, pageLoop));
                     }
                     inputDocument.Close();
                     outputCopy.FreeReader(inputDocument);
                     inputDocument = null;
                 }
                 concatDocument.Close();
                 outputCopy.Close();
             }
             catch
             {
                 if (concatDocument != null && concatDocument.IsOpen())
                 {
                     concatDocument.Close();
                 }
                 if (outputCopy != null)
                 {
                     outputCopy.Close();
                 }
                 if (File.Exists(outputFile))
                 {
                     try
                     {
                         File.Delete(outputFile);
                     }
                     catch { }
                 }
                 throw;
             }
         }
         else
         {
             throw new ArgumentNullException("outputFile", exceptionArgumentNullOrEmptyString);
         }
     }
     else
     {
         throw new ArgumentNullException("inputFiles", exceptionArgumentNullOrEmptyString);
     }
 }
Пример #10
0
        protected void GridViewDogalgaz_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "DogalgazOdeme")                       // Tıklanılan sütun (Kolon Adı == DogalgazOdeme ise)
            {
                int      index    = Convert.ToInt16(e.CommandArgument); // Seçili satır indexini alır..
                TableRow secili   = GridViewDogalgaz.Rows[index];       // Seçili Satırı değişkene aldık.
                String   aboneNo  = secili.Cells[1].Text;               // Seçili satırın abone numarasını aldık.
                String   faturaNo = secili.Cells[2].Text;               // Seçili satırın fatura numarasını aldık.
                yonet.dogalgazFaturaOde(aboneNo, faturaNo);             // Ödeme işlemi metodunu çağırdık...
                Response.Write("Ödeme Yapıldı...");                     // Mesaj verme



                /*-------------------------------------*/

                iTextSharp.text.Document     raporum = new iTextSharp.text.Document();
                iTextSharp.text.pdf.BaseFont STF_Helvetica_Turkish = iTextSharp.text.pdf.BaseFont.CreateFont("Helvetica", "CP1254", iTextSharp.text.pdf.BaseFont.NOT_EMBEDDED);

                iTextSharp.text.Font fontNormal = new iTextSharp.text.Font(STF_Helvetica_Turkish, 12, iTextSharp.text.Font.NORMAL);
                // PDF oluşturması ve konumun belirlenmesi
                Random r = new Random();

                PdfWriter.GetInstance(raporum, new FileStream("C:\\Users\\süleyman\\Desktop\\E-Fatura" + r.Next() + ".pdf", FileMode.Create));

                //PDF yi yazan özelliğine eklenecek

                raporum.AddAuthor("Tüm Abone Listesi"); // PDF Oluşturma Tarihi Ekle

                raporum.AddCreationDate();              // PDF Oluşturma Tarihi

                // PDF oluşturan kişi özelliğine yazılacak

                raporum.AddCreator("Aboneler");

                if (raporum.IsOpen() == false)
                {
                    raporum.Open();
                }
                raporum.Add(new Paragraph("ABONE LISTESI"));
                raporum.Add(new Paragraph("__________________________________________________"));
                raporum.Add(new Paragraph("Abone Numarasi     : " + secili.Cells[0].Text));
                raporum.Add(new Paragraph("Fatura Numarası    : " + secili.Cells[1].Text));
                raporum.Add(new Paragraph("Fatura Bedeli      : " + secili.Cells[2].Text));
                raporum.Add(new Paragraph("Fatura Tarihi      : " + secili.Cells[3].Text));
                raporum.Add(new Paragraph("Son Ödeme Tarihi   : " + secili.Cells[4].Text));
                raporum.Add(new Paragraph("Odeme Durumu       : " + "Ödenmistir"));

                Response.Write("PDF Dosyanız Oluşmuştur.");

                raporum.Close();
                Response.Redirect("AboneDogalgaz.aspx");              // Yönlendirme...
                /*-------------------------------------*/
            }
        }
        private void btnPdf_Click(object sender, EventArgs e)
        {
            iTextSharp.text.Document document = new iTextSharp.text.Document();
            PdfWriter.GetInstance(document, new FileStream("D:Document.pdf", FileMode.Create));

            if (document.IsOpen() == false)
            {
                document.Open();
            }
            document.Add(new Paragraph(richTextBox1.Text));
            //document.Close();
        }
Пример #12
0
        public void CreatePages(Models.Document documentTemplate, string outputFile)
        {
            _itextDocument  = new iTextSharp.text.Document();
            _itextPDFWriter = iTextSharp.text.pdf.PdfWriter.GetInstance(_itextDocument,
                                                                        new System.IO.FileStream(outputFile,
                                                                                                 System.IO.
                                                                                                 FileMode.
                                                                                                 Create));

            _itextPDFWriter.PdfVersion = PdfWriter.VERSION_1_7;
            _itextPDFWriter.Open();

            PdfContentByte itextContent = _itextPDFWriter.DirectContent;

            int pageCounter = 0;

            foreach (Models.Page pageTemplate in documentTemplate.Pages)
            {
                pageCounter++;

                if (pageTemplate.Bleeding.Points > 0)
                {
                    _itextPDFWriter.SetBoxSize("bleed",
                                               new iTextSharp.text.Rectangle(0, 0, pageTemplate.Width.Points,
                                                                             pageTemplate.Height.Points));
                }

                Rectangle pageLayoutRectangle = new iTextSharp.text.Rectangle(-pageTemplate.Bleeding.Points,
                                                                              -pageTemplate.Bleeding.Points,
                                                                              pageTemplate.Width.Points +
                                                                              pageTemplate.Bleeding.Points,
                                                                              pageTemplate.Height.Points +
                                                                              pageTemplate.Bleeding.Points);

                _itextPDFWriter.PageEmpty = false;
                _itextDocument.SetPageSize(pageLayoutRectangle);

                if (!_itextDocument.IsOpen())
                {
                    _itextDocument.Open();
                }



                PdfPage page = new PdfPage(this, itextContent);
                page.Render(pageTemplate);
                itextContent.PdfDocument.NewPage();
            }
        }
Пример #13
0
        public static void WriteAddsToPdf(List <Word> _WordList, string _fname)
        {
            iTextSharp.text.Document document = new iTextSharp.text.Document();
            string fpath = PrepareFilePath(_fname, "OutputReports");

            PdfWriter.GetInstance(document, new FileStream(fpath, FileMode.Create));
            string   fpathfont = PrepareFilePath("times.ttf", "Fonts");
            BaseFont arial     = BaseFont.CreateFont(fpathfont, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
            Font     font      = new Font(arial, 12, Font.NORMAL);
            int      countw    = _WordList.Count + 1;


            if (document.IsOpen() == false)
            {
                document.Open();
                PdfPTable table = new PdfPTable(5);

                PdfPCell cell = new PdfPCell(new Phrase(TurkceKarakter("Ek Sıklık Tablosu"), font));
                cell.Colspan             = 5;
                cell.HorizontalAlignment = Element.ALIGN_CENTER;
                table.AddCell(cell);


                string sb = TurkceKarakter("Kullanım Sayısı");
                table.AddCell("Kelime");
                table.AddCell("Tip");
                table.AddCell(new Paragraph(sb, font));
                sb = TurkceKarakter("Kullanım Sırası");
                table.AddCell(new Paragraph(sb, font));
                sb = TurkceKarakter("Kullanım Sıklığı");
                table.AddCell(new Paragraph(sb, font));

                foreach (Word row in _WordList)
                {
                    sb = TurkceKarakter(row.WFull);

                    table.AddCell(new Paragraph(sb, font));
                    sb = TurkceKarakter(row.WType);
                    table.AddCell(new Paragraph(sb, font));
                    table.AddCell(row.Wcount.ToString());
                    table.AddCell(row.WRank.ToString());
                    table.AddCell(row.Wfrequency.ToString());
                }


                document.Add(table);
                document.Close();
            }
        }
Пример #14
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            /*-------------------------------------*/

            iTextSharp.text.Document     raporum = new iTextSharp.text.Document();
            iTextSharp.text.pdf.BaseFont STF_Helvetica_Turkish = iTextSharp.text.pdf.BaseFont.CreateFont("Helvetica", "CP1254", iTextSharp.text.pdf.BaseFont.NOT_EMBEDDED);

            iTextSharp.text.Font fontNormal = new iTextSharp.text.Font(STF_Helvetica_Turkish, 12, iTextSharp.text.Font.NORMAL);
            // PDF oluşturması ve konumun belirlenmesi
            Random r = new Random();

            PdfWriter.GetInstance(raporum, new FileStream("C:\\Users\\süleyman\\Desktop\\E-Fatura" + r.Next() + ".pdf", FileMode.Create));

            //PDF yi yazan özelliğine eklenecek

            raporum.AddAuthor("Tüm Abone Listesi"); // PDF Oluşturma Tarihi Ekle

            raporum.AddCreationDate();              // PDF Oluşturma Tarihi

            // PDF oluşturan kişi özelliğine yazılacak

            raporum.AddCreator("Aboneler");

            if (raporum.IsOpen() == false)
            {
                raporum.Open();
            }
            yonet.TumAboneler();
            raporum.Add(new Paragraph("ABONE LISTESI"));
            while (yonet.dr.Read())
            {
                raporum.Add(new Paragraph("__________________________________________________"));
                raporum.Add(new Paragraph("Abone Numarasi     : " + yonet.dr["ABONENO"].ToString()));
                raporum.Add(new Paragraph("TC Kimlik Numarasi : " + yonet.dr["TCKIMLIKNO"].ToString()));
                raporum.Add(new Paragraph("Abone Ad Soyad     : " + yonet.dr["ADSOYAD"].ToString()));
                raporum.Add(new Paragraph("Abone Dogum Tarihi : " + yonet.dr["DOGTAR"].ToString()));
                raporum.Add(new Paragraph("Abone Telefon      : " + yonet.dr["TEL"].ToString()));
                raporum.Add(new Paragraph("Abone Adres        : " + yonet.dr["ADRES"].ToString()));
                raporum.Add(new Paragraph("Abone Cinsiyet     : " + yonet.dr["CINSIYET"].ToString()));
                raporum.Add(new Paragraph("Abone Turu         : " + yonet.dr["ABONETURU"].ToString()));
            }
            Response.Write("PDF Dosyanız Oluşmuştur.");

            raporum.Close();

            /*-------------------------------------*/
        }
        private void pictureBox1_Click(object sender, EventArgs e)
        {
            iTextSharp.text.Document raporum = new iTextSharp.text.Document();
            PdfWriter.GetInstance(raporum, new FileStream("C:'" + LblHastaAdı.Text + LblRecerteKodu.Text + "'.pdf", FileMode.Create));
            raporum.AddAuthor(LblHastane.Text + "/" + LblDoktor.Text);
            raporum.AddCreationDate();
            raporum.AddCreator(LblHastane.Text + "/" + LblDoktor.Text);
            raporum.AddSubject("Recete" + LblRecerteKodu.Text);
            raporum.AddKeywords(LblHastaAdı.Text);

            if (raporum.IsOpen() == false)
            {
                raporum.Open();
            }
            raporum.Add(new Paragraph(LblRecete.Text));
            pictureBox1.Enabled = false;
            PdfOku();
        }
Пример #16
0
        private void CreatePdf(string filePath)
        {
            iTextSharp.text.Document pdfDoc = new iTextSharp.text.Document();
            PdfWriter.GetInstance(pdfDoc, new FileStream(filePath, FileMode.Create, FileAccess.ReadWrite));

            // For Turkish Characters
            iTextSharp.text.pdf.BaseFont STF_Helvetica_Turkish = BaseFont.CreateFont("Helvetica", "CP1254", BaseFont.NOT_EMBEDDED);
            iTextSharp.text.Font         fontTitle             = new iTextSharp.text.Font(STF_Helvetica_Turkish, 12, iTextSharp.text.Font.NORMAL);

            pdfDoc.AddAuthor("FirstName Lastname");
            pdfDoc.AddCreationDate();
            pdfDoc.AddHeader(tbxPdfFileName.Text, tbxSubject.Text);
            if (pdfDoc.IsOpen() == false)
            {
                pdfDoc.Open();
            }
            pdfDoc.Add(new Paragraph(rtbPdfText.Text, fontTitle));
            pdfDoc.Close();
        }
 private void ciktiAlBtn_Click(object sender, EventArgs e)
 {
     try
     {
         iTextSharp.text.Document raporum = new iTextSharp.text.Document();
         // PDF oluşturması ve konumun belirlenmesi
         PdfWriter.GetInstance(raporum, new FileStream("C:\\Users\\Serap\\Desktop\\yazilimSinamaProje\\Raporum.pdf", FileMode.Create));
         if (raporum.IsOpen() == false)
         {
             raporum.Open();
             raporum.Add(new Paragraph(yazi));
             raporum.Close();
         }
     }
     catch (Exception)
     {
         MessageBox.Show("raporum pdf dosyası kapatılmadan kayıt yapılamaz!");
     }
 }
Пример #18
0
 //重写 打开一个新页面时
 public override void OnStartPage(PdfWriter writer, Document document)
 {
     try
     {
         if (PAGE_NUMBER)
         {
             writer.PageCount = writer.PageNumber;
         }
         if (isPdfTable)
         {
             if (!document.IsOpen())
             {
                 document.Open();
             }
             document.Add(pdftable);
         }
     }
     catch (Exception ex)
     {
         throw new Exception("HeaderAndFooterEvent-->OnStartPage-->" + ex.Message);
     }
    
 }
Пример #19
0
        private void EndOfProductionButton_Click(object sender, EventArgs e)
        {
            string filename = "C:/OP2GUI/";

            if (System.IO.Directory.Exists(filename))
            {
            }
            else
            {
                Directory.CreateDirectory(filename);
            }



            DateTime now = DateTime.Now;

            rapor = new iTextSharp.text.Document();
            PdfWriter.GetInstance(rapor, new FileStream("C:/OP2GUI/" + Initialize.name + DateTime.Now.ToString("yyyyMMddHHmmss") + "OP2GUI.pdf", FileMode.Create));
            rapor.SetMargins(80, 80, 80, 80);
            Initialize.name = TurkceKarakter(Initialize.name);
            rapor.AddAuthor(Initialize.name);
            rapor.AddCreationDate();
            rapor.AddCreator(Initialize.name);
            rapor.AddSubject(Initialize.name + "|OP2-GUI");


            if (rapor.IsOpen() == false)
            {
                rapor.Open();
            }


            BaseFont times  = BaseFont.CreateFont("c:\\windows\\fonts\\times.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
            Font     font16 = new Font(times, 16);
            Font     font14 = new Font(times, 14);
            Font     font12 = new Font(times, 12);

            ///Tarih Ekle
            Paragraph head0 = new Paragraph(now.ToString(), font12);

            head0.Alignment = Element.ALIGN_RIGHT;
            rapor.Add(head0);

            ////Başlık
            Paragraph head = new Paragraph("OP2-GUI", font16);

            head.Alignment = Element.ALIGN_CENTER;
            rapor.Add(head);

            ///Üretimden Sorumlu kişi
            Paragraph head2 = new Paragraph("Üretimden Sorumlu Kisi: " + Initialize.name, font14);

            head2.Alignment = Element.ALIGN_CENTER;
            rapor.Add(head2);

            /// Yeni Veriler
            PdfNewDataLeft("\n");
            PdfNewDataCenter("--------------------------------------------------");
            PdfNewDataCenter("Başlangıçta Belirlenen Parametreler");
            PdfNewDataCenter("--------------------------------------------------");
            PdfNewDataLeft("\n");


            PdfNewDataLeft("--------------------------------------------------");
            PdfNewDataLeft("Malzemenin Adı: " + RefProduction.materialNameTextRP);
            PdfNewDataLeft("Numume Adedi: " + RefProduction.numberOfSamplesTextRP);
            PdfNewDataLeft("Numune Boyutları: " + RefProduction.sampleSizeTextRP);
            PdfNewDataLeft("Üretim Türü: " + Initialize.publicrefProductiontext);
            PdfNewDataLeft("Solüsyon Bilgisi: " + ProductionParameters.publicsolutionInfoText);
            PdfNewDataLeft("--------------------------------------------------");

            PdfNewDataLeft("Başlangıç Saati: " + DateTime.Now.ToShortTimeString());
            PdfNewDataLeft("Kullanılan Program: " + programNameLabelOP.Text);
            PdfNewDataLeft("Alt-taş Sıcaklığı: " + substrateHeaterLabelOP.Text);
            PdfNewDataLeft("Akış Miktarı: " + flowRateLabelOP.Text);
            PdfNewDataLeft("Geçiş Sayısı: " + passCountLabelOP.Text);
            PdfNewDataLeft("Nozzle Gaz: " + nozzleGasPressureLabelOP.Text);
            PdfNewDataLeft("Oksijen Seviyesi (SET): " + oxygenLevelSetLabelOP.Text);
            PdfNewDataLeft("Oksijen Seviyesi (Başlangıç): " + oxygenLevelStartLabelOP.Text);
            PdfNewDataLeft("Ortam Sıcaklığı (SET): " + ambienceTemperatureSetLabelOP.Text);
            PdfNewDataLeft("Ortam Sıcaklığı (Başlangıç) :" + ambienceTemperatureStartLabelOP.Text);
            PdfNewDataLeft("Nem Seviyesi (SET) :" + humidityLevelSetLabelOP.Text);
            PdfNewDataLeft("Nem Seviyesi (Başlangıç) :" + humidityLevelStartLabelOP.Text);
            PdfNewDataLeft("Nemlendirici Gerilimi: " + humidityVoltageLabelOP.Text);
            PdfNewDataLeft("Fan Hızı : " + fanRPMLabelOP.Text);
            PdfNewDataLeft("--------------------------------------------------");

            PdfNewDataLeft("\n");
            PdfNewDataLeft("\n");
            PdfNewDataLeft("\n");
            PdfNewDataLeft("\n");
            PdfNewDataLeft("\n");
            PdfNewDataLeft("\n");
            PdfNewDataCenter("--------------------------------------------------");
            PdfNewDataCenter("Üretim Sırasında Belirlenen Parametreler");
            PdfNewDataCenter("--------------------------------------------------");
            PdfNewDataLeft("\n");


            if (changesListBox.Items.Count > 0)
            {
                PdfNewDataLeft("--------------------------------------------------");
                foreach (string item in changesListBox.Items)
                {
                    PdfNewDataLeft(item);
                }
                PdfNewDataLeft("--------------------------------------------------");
            }



            PdfNewDataLeft("\n");
            PdfNewDataCenter("--------------------------------------------------");
            PdfNewDataCenter("Üretim Sırasında Anlık Parametreler");
            PdfNewDataCenter("--------------------------------------------------");
            PdfNewDataLeft("\n");


            if (instantDataListBox.Items.Count > 0)
            {
                PdfNewDataLeft("--------------------------------------------------");
                foreach (string item in instantDataListBox.Items)
                {
                    PdfNewDataLeft(item);
                    Console.WriteLine(item);
                }
                PdfNewDataLeft("--------------------------------------------------");
            }


            PdfNewDataLeft("\n");
            PdfNewDataCenter("--------------------------------------------------");
            PdfNewDataCenter("Temizlik");
            PdfNewDataCenter("--------------------------------------------------");
            PdfNewDataLeft("\n");

            if (!(CleaningProcess.cleaningProcessCP == ""))
            {
                PdfNewDataLeft("--------------------------------------------------");
                PdfNewDataLeft(CleaningProcess.cleaningProcessCP);
                PdfNewDataLeft("--------------------------------------------------");
            }


            PdfNewDataLeft("\n");
            PdfNewDataCenter("--------------------------------------------------");
            PdfNewDataCenter("İleri İşlemler");
            PdfNewDataCenter("--------------------------------------------------");
            PdfNewDataLeft("\n");


            if (!(PostProcessing.postProcessPOP == ""))
            {
                PdfNewDataLeft("--------------------------------------------------");
                PdfNewDataLeft(PostProcessing.postProcessPOP);
                PdfNewDataLeft("--------------------------------------------------");
            }


            PdfNewDataLeft("\n");
            PdfNewDataCenter("--------------------------------------------------");
            PdfNewDataCenter("Alınacak Olçümler");
            PdfNewDataCenter("--------------------------------------------------");
            PdfNewDataLeft("\n");


            if (Measurements.measumentsMP.Length > 0)
            {
                PdfNewDataLeft("--------------------------------------------------");
                foreach (var item in Measurements.measumentsMP)
                {
                    PdfNewDataLeft(item);
                }
                PdfNewDataLeft("--------------------------------------------------");
            }


            PdfNewDataLeft("\n");
            PdfNewDataCenter("--------------------------------------------------");
            PdfNewDataCenter("Notlar");
            PdfNewDataCenter("--------------------------------------------------");
            PdfNewDataLeft("\n");


            if (!(takeNotesText.Text == ""))
            {
                PdfNewDataLeft("--------------------------------------------------");
                PdfNewDataLeft(takeNotesText.Text);
                PdfNewDataLeft("--------------------------------------------------");
            }

            rapor.Close();



            MessageBox.Show("Dosya Oluşturuldu.\n" + "C:/OP2GUI/" + Initialize.name + DateTime.Now.ToString("yyyyMMddHHmmss") + "OP2GUI.pdf");

            System.Diagnostics.Process.Start("C:/OP2GUI/");
        }
Пример #20
0
        private iTS.Document ExportTo(DocTemplateVers.Domain.DTO.ServiceExport.DTO_Settings settings, System.IO.Stream stream, Boolean forErrorContent)
        {
            iTS.Document doc = null;
            try
            {
                doc = InitializeDocument(ref settings);

                DocTemplateVers.Domain.DTO.ServiceExport.DTO_HeaderFooter Header = GetHeader();
                DocTemplateVers.Domain.DTO.ServiceExport.DTO_HeaderFooter Footer = GetFooter();

                float ContentWidth = settings.Width - (settings.MarginLeft + settings.MarginRight);


                iTS.rtf.RtfWriter2 rtfWriter = iTS.rtf.RtfWriter2.GetInstance(doc, stream);

                doc.Open();



                //Add Header
                iTS.Table table = null;
                if (Header != null)
                {
                    table = ConvertHeaderFooter(Header, ContentWidth);
                    if (table != null)
                    {
                        try
                        {
                            doc.Add(table);
                        }
                        catch { }
                    }
                }

                ////Compilazione documento

                if (forErrorContent)
                {
                    RenderErrorDocument(doc);
                }
                else
                {
                    RenderDocument(doc, rtfWriter);
                }

                if (Footer != null)
                {
                    table = ConvertHeaderFooter(Footer, ContentWidth);
                    if (table != null)
                    {
                        try
                        { doc.Add(table); }
                        catch { }
                    }
                }


                doc.Close();
            }
            catch (Exception ex)
            {
                doc = null;
            }
            finally
            {
                if (doc != null && doc.IsOpen())
                {
                    doc.Close();
                }
            }
            return(doc);
            //DocTemplateVers.Domain.DTO.ServiceExport.DTO_HeaderFooter Header = GetHeader();
            ////DocTemplate.TemplateHeaderFooter Header = GetHeader();
            ////DocTemplate.TemplateHeaderFooter Footer = GetFooter();
            //DocTemplateVers.Domain.DTO.ServiceExport.DTO_HeaderFooter Footer = GetFooter();

            //float ContentWidth = settings.Width - (settings.MarginLeft + settings.MarginRight);

            //Document doc = null;
            //try
            //{
            //    doc = InitializeDocument(settings);

            //    iTextSharp.text.rtf.RtfWriter2 rtfWriter = iTextSharp.text.rtf.RtfWriter2.GetInstance(doc, stream);

            //    doc.Open();



            //    //Add Header
            //    iTextSharp.text.Table table = null;
            //    if (!settings.HTMLheader && Header != null)
            //    {
            //        table = ConvertHeaderFooter(Header, ContentWidth);
            //        if (table != null)
            //            doc.Add(table);
            //    }

            //    ////Compilazione documento

            //    if (forErrorContent)
            //        RenderErrorDocument(doc);
            //    else
            //        RenderDocument(doc, rtfWriter);

            //    if (!settings.HTMLfooter && Footer != null) {
            //        table = ConvertHeaderFooter(Footer, ContentWidth);
            //        if (table!=null)
            //            doc.Add(table);
            //    }


            //    doc.Close();
            //}
            //catch (Exception ex)
            //{
            //    doc = null;
            //}
            //finally{
            //    if (doc != null && doc.IsOpen())
            //        doc.Close();
            //}
            //return doc;
        }
Пример #21
0
        public void bill(string siparisNo, string Kullaniciid)
        {
            this.siparisNo   = siparisNo;
            this.Kullaniciid = Kullaniciid;

            iTextSharp.text.pdf.BaseFont STF_Helvetica_Turkish = iTextSharp.text.pdf.BaseFont.CreateFont("Helvetica", "CP1254", iTextSharp.text.pdf.BaseFont.NOT_EMBEDDED);
            iTextSharp.text.Font         fontTitle             = new iTextSharp.text.Font(STF_Helvetica_Turkish, 11, iTextSharp.text.Font.NORMAL);

            SqlCommand cdname = new SqlCommand("select *from Tbl_Kullanici where KullaniciId=@p1", conn.connection());

            cdname.Parameters.AddWithValue("@p1", Kullaniciid);
            SqlDataReader drname = cdname.ExecuteReader();

            while (drname.Read())
            {
                name   = drname[1].ToString() + " " + drname[2].ToString();
                e_mail = drname[3].ToString();
            }

            conn.connection().Close();

            iTextSharp.text.Document pdf = new iTextSharp.text.Document();
            filePath = HttpContext.Current.Server.MapPath("~/Bills/" + siparisNo + "_Fatura.Pdf");
            PdfWriter.GetInstance(pdf, new FileStream(filePath, FileMode.Create));
            pdf.AddAuthor("BookSite");
            pdf.AddCreator("BookSite");
            pdf.AddCreationDate();
            pdf.AddSubject("Fatura");


            PdfPTable table = new PdfPTable(4);
            PdfPCell  cell  = new PdfPCell(new Phrase(name + "        FATURA - " + siparisNo, fontTitle));

            cell.Colspan             = 4;
            cell.HorizontalAlignment = 1;
            table.AddCell(cell);

            table.AddCell(new Phrase("Kitap Adı", fontTitle));
            table.AddCell(new Phrase("Miktar", fontTitle));
            table.AddCell(new Phrase("Birim Fiyat", fontTitle));
            table.AddCell(new Phrase("Toplam Fiyat", fontTitle));

            SqlCommand cd = new SqlCommand("select *from Tbl_Sepet where SiparisNo=@p1", conn.connection());

            cd.Parameters.AddWithValue("@p1", siparisNo);
            SqlDataReader dr = cd.ExecuteReader();

            while (dr.Read())
            {
                table.AddCell(new Phrase(dr[7].ToString(), fontTitle));
                table.AddCell(new Phrase(dr[2].ToString(), fontTitle));
                table.AddCell(new Phrase(dr[6].ToString(), fontTitle));
                table.AddCell(new Phrase(dr[3].ToString(), fontTitle));
            }
            conn.connection().Close();


            if (pdf.IsOpen() == false)
            {
                pdf.Open();
            }
            pdf.Add(table);
            pdf.Close();
        }
Пример #22
0
        protected void btntetkikkaydet_Click(object sender, EventArgs e)
        {
            MongoClient client           = new MongoClient();
            var         database         = client.GetDatabase("hastane");
            var         collection       = database.GetCollection <yatanhastalar>("yatanhastalar");
            var         servislistesi    = collection.Find(x => x._id != null).ToList().SelectMany(x => x.ServisList).ToList();
            var         hastalistesi     = servislistesi.SelectMany(x => x.HastaList).ToList().Where(x => x._id == ObjectId.Parse(ddlHasta.SelectedValue)).ToList();
            var         radyolojilistesi = hastalistesi.SelectMany(x => x.RadyolojiList).ToList().Where(x => x._id == ObjectId.Parse(ddlRadyoloji.SelectedValue));
            var         tetkiklistesi    = radyolojilistesi.SelectMany(x => x.TetkiklerList).ToList().Where(x => x.tahlil_adi == ListBox1.SelectedItem.Text);
            var         hst = hastalistesi.FirstOrDefault();
            var         rad = radyolojilistesi.FirstOrDefault();

            #region Font seç
            BaseFont             trArial              = BaseFont.CreateFont(@"C:\WINDOWS\Fonts\tahoma.ttf", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
            iTextSharp.text.Font fontArial            = new iTextSharp.text.Font(trArial, 10, iTextSharp.text.Font.NORMAL, iTextSharp.text.BaseColor.DARK_GRAY);
            iTextSharp.text.Font fontArialHeader      = new iTextSharp.text.Font(trArial, 13, iTextSharp.text.Font.BOLD, iTextSharp.text.BaseColor.BLACK);
            iTextSharp.text.Font fontArialbold        = new iTextSharp.text.Font(trArial, 9, iTextSharp.text.Font.BOLD, iTextSharp.text.BaseColor.DARK_GRAY);
            iTextSharp.text.Font fontArialboldgeneral = new iTextSharp.text.Font(trArial, 10, iTextSharp.text.Font.BOLD, iTextSharp.text.BaseColor.BLACK);
            #endregion

            #region Sonuç pdf oluştur
            iTextSharp.text.Document pdfFile = new iTextSharp.text.Document();
            PdfWriter.GetInstance(pdfFile, new FileStream("C:\\Users\\Önder\\Desktop\\Yeni klasör\\Radyoloji Sonuç (" + hst.hasta_tc + " " + hst.hasta_adi + " " + hst.hasta_soyadi + " " + DateTime.UtcNow.ToShortDateString() + ").pdf", FileMode.Create));
            pdfFile.Open();
            #endregion

            #region Sonuç oluşturan bilgileri
            pdfFile.AddCreator("Önder");      //Oluşturan kişinin isminin eklenmesi
            pdfFile.AddCreationDate();        //Oluşturulma tarihinin eklenmesi
            pdfFile.AddAuthor("Radyoloji");   //Yazarın isiminin eklenmesi
            pdfFile.AddHeader("Başlık", "PDF UYGULAMASI OLUSTUR");
            pdfFile.AddTitle("Sonuç Raporu"); //Başlık ve title eklenmesi
            #endregion

            #region Sonuç firma resmi ve tarihi oluştur
            iTextSharp.text.Image jpgimg = iTextSharp.text.Image.GetInstance(@"C:/Users/Önder/Desktop/Önder Fatih Buhurcu Staj Projesi/WebApplicationHastane/WebApplicationHastane/login/images/İsimsiz-1.png");
            jpgimg.ScalePercent(35);
            jpgimg.Alignment = iTextSharp.text.Image.LEFT_ALIGN;

            PdfPTable pdfTableHeader = new PdfPTable(3);
            pdfTableHeader.TotalWidth  = 500f;
            pdfTableHeader.LockedWidth = true;
            //pdfTableHeader.DefaultCell.Border = Rectangle;

            PdfPCell cellheader1 = new PdfPCell(jpgimg);
            cellheader1.HorizontalAlignment = PdfPCell.ALIGN_LEFT;
            cellheader1.VerticalAlignment   = PdfPCell.ALIGN_BOTTOM;
            cellheader1.FixedHeight         = 60f;
            cellheader1.Border = 0;
            pdfTableHeader.AddCell(cellheader1);

            PdfPCell cellheader2 = new PdfPCell(new Phrase("SONUÇ RAPORU", fontArialHeader));
            cellheader2.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cellheader2.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cellheader2.FixedHeight         = 60f;
            cellheader2.Border = 0;
            pdfTableHeader.AddCell(cellheader2);


            PdfPCell cellheader3 = new PdfPCell(new Phrase(DateTime.Now.ToShortDateString(), fontArial));
            cellheader3.HorizontalAlignment = PdfPCell.ALIGN_RIGHT;
            cellheader3.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cellheader3.FixedHeight         = 60f;
            cellheader3.Border = 0;
            pdfTableHeader.AddCell(cellheader3);
            #endregion

            Phrase p = new Phrase("\n");

            Paragraph yazi = new Paragraph("Hasta TC: " + hst.hasta_tc + "\nHasta Adı: " + hst.hasta_adi + "\nHasta Soyadı: " + hst.hasta_soyadi + "\n\n\n");


            #region Tabloyu Oluştur
            PdfPTable pdfTable = new PdfPTable(1);
            pdfTable.TotalWidth              = 500f;
            pdfTable.LockedWidth             = true;
            pdfTable.HorizontalAlignment     = 1;
            pdfTable.DefaultCell.Padding     = 5;
            pdfTable.DefaultCell.BorderColor = iTextSharp.text.BaseColor.GRAY;

            pdfTable.AddCell(new Phrase(ListBox1.SelectedItem.Text + " Sonucu", fontArialboldgeneral));
            pdfTable.AddCell(new Phrase(sonucText.Value, fontArial));

            #endregion

            #region Pdfe yaz ve dosyayı kapat
            if (pdfFile.IsOpen() == false)
            {
                pdfFile.Open();
            }
            pdfFile.Add(pdfTableHeader);
            pdfFile.Add(p);
            pdfFile.Add(yazi);
            pdfFile.Add(pdfTable);
            pdfFile.Close();
            #endregion

            var filter = Builders <yatanhastalar> .Filter.ElemMatch(x => x.ServisList, Builders <servis> .Filter.ElemMatch(x => x.HastaList, Builders <hasta> .Filter.And(Builders <hasta> .Filter.Eq(x => x._id, ObjectId.Parse(ddlHasta.SelectedValue)), Builders <hasta> .Filter.ElemMatch(x => x.RadyolojiList, Builders <radyolojitetkikler> .Filter.And(Builders <radyolojitetkikler> .Filter.Eq(x => x._id, ObjectId.Parse(ddlRadyoloji.SelectedValue)), Builders <radyolojitetkikler> .Filter.ElemMatch(x => x.TetkiklerList, Builders <tetkikler> .Filter.Eq(x => x.tahlil_adi, ListBox1.SelectedItem.Text)))))));

            var update = Builders <yatanhastalar> .Update.Pull("ServisList.$[].HastaList.$[].RadyolojiList.$[].TetkiklerList", tetkiklistesi);

            collection.UpdateOne(filter, update);

            var sayı = radyolojilistesi.SelectMany(x => x.TetkiklerList).ToList();
            if (sayı.Count == 0)
            {
                var filter2 = Builders <yatanhastalar> .Filter.ElemMatch(x => x.ServisList, Builders <servis> .Filter.ElemMatch(x => x.HastaList, Builders <hasta> .Filter.Eq(x => x._id, ObjectId.Parse(ddlHasta.SelectedValue))));

                hst.hasta_radyoloji_durum = "Sonuçlandı";
                var update2 = Builders <yatanhastalar> .Update.Set(b => b.ServisList, servislistesi);
            }
        }
Пример #23
0
        public void CvAdd(CurriculumVitae curriculumVitae)
        {
            Document document = new iTextSharp.text.Document();

            PdfWriter.GetInstance(document, new FileStream(@"C:\Users\ademk\Desktop\PoldyMyCv.pdf", FileMode.Create));
            BaseFont arial = BaseFont.CreateFont("c:\\windows\\fonts\\arial.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
            Font     font  = new Font(arial, 12, Font.NORMAL);

            if (document.IsOpen() == false)
            {
                document.Open();

                // iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(@"C:\Users\ademk\source\repos\Poldy4\deneme\PoldyCv\vesikalik.jpg");
                // img.ScalePercent(30f, 20f);
                string text;

                if (curriculumVitae.MaritalStatus.ToString() == "False")
                {
                    this.medenidurum = "Bekar";
                }
                else if (curriculumVitae.MaritalStatus.ToString() == "True")
                {
                    this.medenidurum = "Evli";
                }
                text =
                    "Kişisel Bilgiler \n" +
                    "--------------------" +
                    "\n Ad :" + curriculumVitae.FirstName +
                    "\n Soyad : " + curriculumVitae.LastName +
                    "\n Doğum Tarihi : " + curriculumVitae.BirthDate +
                    "\n Doğum Yeri : " + curriculumVitae.PlaceOfBirth +
                    "\n Medeni Durum : " + this.medenidurum +
                    "\n ----------------------------------------" +
                    "\n Eğitim Bilgileri" +
                    "\n--------------------" +
                    "\n Öğrenim Seviyesi :" + curriculumVitae.EducationStatus +
                    "\n Okul Adı : " + curriculumVitae.School +
                    "\n Okul Başlangıç : " + curriculumVitae.SchoolStart +
                    "\n Okul Bitiş : " + curriculumVitae.SchoolFinish +
                    "\n --------------------" +
                    "\n İletişim Bilgileri" +
                    "\n ---------------------" +
                    "\n Cep Numarası : " + curriculumVitae.MobilTelefonNumber +
                    "\n Mail Adresi : " + curriculumVitae.Mail +
                    "\n Adres : " + curriculumVitae.Address +
                    "\n --------------------" +
                    "\n Yabancı Dil Bilgileri" +
                    "\n ---------------------" +
                    "\n Yabancı Dil : " + curriculumVitae.ForeignLanguage +
                    "\n Yabancı Dil Seviye : " + curriculumVitae.ForeignLanguageLevel +
                    "\n --------------------" +
                    "\n Yabancı Dil Bilgileri" +
                    "\n ---------------------" +
                    "\n Yetkinlikler : " + curriculumVitae.Competences +
                    "\n ----------------------------" +
                    "\n Referanslar : " + curriculumVitae.Reference
                ;
                //document.Add(img);

                text = Turkish1.TurkishCharacter(text);
                document.Add(new Paragraph(text, font));
                document.Close();
                this.CvPdf = File.ReadAllBytes(@"C:\Users\ademk\Desktop\PoldyMyCv.pdf");
            }
        }
        protected void SonucYazdır_Click(object sender, EventArgs e)
        {
            MongoClient client        = new MongoClient();
            var         database      = client.GetDatabase("hastane");
            var         collection    = database.GetCollection <yatanhastalar>("yatanhastalar");
            var         servislistesi = collection.Find(x => x._id != null).ToList().SelectMany(x => x.ServisList).ToList();
            var         hastalistesi  = servislistesi.SelectMany(x => x.HastaList).ToList().Where(x => x._id == ObjectId.Parse(ddlHasta2.SelectedValue)).ToList().FirstOrDefault();

            var sonuc = database.GetCollection <islemsonuc>("sonuclistesi").Find(x => x._id == ObjectId.Parse(ddlsonuctarih.SelectedValue) && x.sonuc_cesidi == "Laboratuvar").ToList().SelectMany(x => x.SonucList).ToList();



            #region Font seç
            BaseFont             trArial              = BaseFont.CreateFont(@"C:\WINDOWS\Fonts\tahoma.ttf", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
            iTextSharp.text.Font fontArial            = new iTextSharp.text.Font(trArial, 10, iTextSharp.text.Font.NORMAL, iTextSharp.text.BaseColor.DARK_GRAY);
            iTextSharp.text.Font fontArialHeader      = new iTextSharp.text.Font(trArial, 13, iTextSharp.text.Font.BOLD, iTextSharp.text.BaseColor.BLACK);
            iTextSharp.text.Font fontArialbold        = new iTextSharp.text.Font(trArial, 9, iTextSharp.text.Font.BOLD, iTextSharp.text.BaseColor.DARK_GRAY);
            iTextSharp.text.Font fontArialboldgeneral = new iTextSharp.text.Font(trArial, 10, iTextSharp.text.Font.BOLD, iTextSharp.text.BaseColor.BLACK);
            #endregion

            #region Sonuç pdf oluştur
            iTextSharp.text.Document pdfFile = new iTextSharp.text.Document();
            PdfWriter.GetInstance(pdfFile, new FileStream("C:\\Users\\Önder\\Desktop\\Yeni klasör\\Kan Sonucu (" + hastalistesi.hasta_adi + " " + hastalistesi.hasta_soyadi + " " + ddlsonuctarih.SelectedItem.Text + ").pdf", FileMode.Create));
            pdfFile.Open();
            #endregion

            #region Sonuç oluşturan bilgileri
            pdfFile.AddCreator("Önder");      //Oluşturan kişinin isminin eklenmesi
            pdfFile.AddCreationDate();        //Oluşturulma tarihinin eklenmesi
            pdfFile.AddAuthor("Laboratuvar"); //Yazarın isiminin eklenmesi
            pdfFile.AddHeader("Başlık", "PDF UYGULAMASI OLUSTUR");
            pdfFile.AddTitle("Sonuç Raporu"); //Başlık ve title eklenmesi
            #endregion

            #region Sonuç firma resmi ve tarihi oluştur
            iTextSharp.text.Image jpgimg = iTextSharp.text.Image.GetInstance(@"C:/Users/Önder/Desktop/Önder Fatih Buhurcu Staj Projesi/WebApplicationHastane/WebApplicationHastane/login/images/İsimsiz-1.png");
            jpgimg.ScalePercent(35);
            jpgimg.Alignment = iTextSharp.text.Image.LEFT_ALIGN;

            PdfPTable pdfTableHeader = new PdfPTable(3);
            pdfTableHeader.TotalWidth         = 500f;
            pdfTableHeader.LockedWidth        = true;
            pdfTableHeader.DefaultCell.Border = Rectangle.NO_BORDER;

            PdfPCell cellheader1 = new PdfPCell(jpgimg);
            cellheader1.HorizontalAlignment = PdfPCell.ALIGN_LEFT;
            cellheader1.VerticalAlignment   = PdfPCell.ALIGN_BOTTOM;
            cellheader1.FixedHeight         = 60f;
            cellheader1.Border = 0;
            pdfTableHeader.AddCell(cellheader1);

            PdfPCell cellheader2 = new PdfPCell(new Phrase("SONUÇ RAPORU", fontArialHeader));
            cellheader2.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
            cellheader2.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cellheader2.FixedHeight         = 60f;
            cellheader2.Border = 0;
            pdfTableHeader.AddCell(cellheader2);


            PdfPCell cellheader3 = new PdfPCell(new Phrase(DateTime.Now.ToShortDateString(), fontArial));
            cellheader3.HorizontalAlignment = PdfPCell.ALIGN_RIGHT;
            cellheader3.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
            cellheader3.FixedHeight         = 60f;
            cellheader3.Border = 0;
            pdfTableHeader.AddCell(cellheader3);
            #endregion

            Phrase p = new Phrase("\n");

            Paragraph yazi = new Paragraph("Hasta TC: " + hastalistesi.hasta_tc + "\nHasta Adı: " + hastalistesi.hasta_adi + "\nHasta Soyadı: " + hastalistesi.hasta_soyadi + "\n\n\n");


            #region Tabloyu Oluştur
            PdfPTable pdfTable = new PdfPTable(2);
            pdfTable.TotalWidth              = 500f;
            pdfTable.LockedWidth             = true;
            pdfTable.HorizontalAlignment     = 1;
            pdfTable.DefaultCell.Padding     = 5;
            pdfTable.DefaultCell.BorderColor = iTextSharp.text.BaseColor.GRAY;
            foreach (var item in sonuc)
            {
                pdfTable.AddCell(new Phrase(item.tahlil_adi, fontArialboldgeneral));
                pdfTable.AddCell(new Phrase(item.sonuc, fontArial));
            }
            #endregion

            #region Pdfe yaz ve dosyayı kapat
            if (pdfFile.IsOpen() == false)
            {
                pdfFile.Open();
            }
            pdfFile.Add(pdfTableHeader);
            pdfFile.Add(p);
            pdfFile.Add(yazi);
            pdfFile.Add(pdfTable);
            pdfFile.Close();
            #endregion
        }
Пример #25
0
        private void btnCvIndir_Click(object sender, EventArgs e)
        {
            iTextSharp.text.Document document = new iTextSharp.text.Document();

            PdfWriter.GetInstance(document, new FileStream(@"C:\Users\ademk\source\repos\Poldy4\deneme\PoldyCv\Cv.pdf", FileMode.Create));

            BaseFont arial = BaseFont.CreateFont("C:\\windows\\fonts\\arial.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);

            iTextSharp.text.Font font = new iTextSharp.text.Font(arial, 12, iTextSharp.text.Font.NORMAL);



            if (document.IsOpen() == false)
            {
                document.Open();

                iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(@"C:\Users\ademk\source\repos\Poldy4\deneme\PoldyCv\vesikalik.jpg");
                img.ScalePercent(30f, 20f);
                //Unvanlar Çekiliyor
                comboBox2.Items.Clear();
                SqlCommand komut4 = new SqlCommand("Select * From Cv_Cvler Where CvMail=@p1", bgl.baglanti());
                komut4.Parameters.AddWithValue("@p1", txtPosta.Text);
                SqlDataReader dr4  = komut4.ExecuteReader();
                string        text = "deneme";
                while (dr4.Read())
                {
                    if (dr4[5].ToString() == "False")
                    {
                        this.medenidurum = "Bekar";
                    }
                    else if (dr4[5].ToString() == "True")
                    {
                        this.medenidurum = "Evli";
                    }
                    text =
                        "Kişisel Bilgiler \n" +
                        "--------------------" +
                        "\n Ad :" + dr4[1] +
                        "\n Soyad : " + dr4[2] +
                        "\n Doğum Tarihi : " + dr4[3] +
                        "\n Doğum Yılı : " + dr4[4] +
                        "\n Medeni Durum : " + this.medenidurum +
                        "\n ----------------------------------------" +
                        "\n Eğitim Bilgileri" +
                        "\n--------------------" +
                        "\n Öğrenim Seviyesi :" + dr4[6] +
                        "\n Okul Adı : " + dr4[7] +
                        "\n Okul Başlangıç : " + dr4[8] +
                        "\n Okul Bitiş : " + dr4[9] +
                        "\n --------------------" +
                        "\n Adres Bilgileri" +
                        "\n ---------------------" +
                        "\n Adres : " + dr4[10] +
                        "\n --------------------" +
                        "\n İletişim Bilgileri" +
                        "\n ---------------------" +
                        "\n Cep Numarası : " + dr4[11] +
                        "\n Mail Adresi : " + dr4[12] +
                        "\n --------------------" +
                        "\n Yabancı Dil Bilgileri" +
                        "\n ---------------------" +
                        "\n Yabancı Dil : " + dr4[13] +
                        "\n Yabancı Dil Seviye : " + dr4[14] +
                        "\n --------------------" +
                        "\n Yabancı Dil Bilgileri" +
                        "\n ---------------------" +
                        "\n Yetkinlikler : " + dr4[15] +
                        "\n ----------------------------" +
                        "\n Referanslar : " + dr4[15]
                    ;
                }
                bgl.baglanti().Close();
                document.Add(img);



                text = TurkceKarakter(text);
                document.Add(new Paragraph(text, font));
                MessageBox.Show("Cv'niz Oluşturulmuştur.", "Bilgilendirme", MessageBoxButtons.OK, MessageBoxIcon.Information);
                document.Close();
            }
        }
Пример #26
0
    private void PopulateBarCode(int PurchaseID)
    {
        //Rectangle pageSize = new Rectangle(842, 595);
        Rectangle pageSize = new Rectangle(62,29);
        //Document document = new Document(PageSize.A4_LANDSCAPE, 10, 10, 10, 10);
        Document document = new Document(pageSize, 0, 0, 2, 0);
        string TimeStamp = DateTime.Now.Ticks.ToString();
        try
        {
            StringBuilder sbBarcode = new StringBuilder();
            string thisBarcode = string.Empty;

            objPI.SearchText = "";

            SaleBLL objSaleBLL = new SaleBLL();

            List<Sale> objData = new List<Sale>();
            objData = objSaleBLL.GetAllProductBarCode(objPI, PurchaseID);


            PdfWriter pdfWriter = PdfWriter.GetInstance(document, new FileStream(Server.MapPath("~") + "/Handler/BarCode_" + TimeStamp + ".pdf", FileMode.Create));
            document.Open();
            PdfContentByte pdfContentByte = pdfWriter.DirectContent;
            iTextSharp.text.Image img;

            if (objData != null)
            {
                int Kounter = 0;
                for (int i = 0; i < objData.Count; i++)
                {
                    int PurchaseQuantity = (int)objData[i].Quantity;

                    for (int ii = 0; ii < PurchaseQuantity; ii++)
                    {
                        if (Kounter > 0)
                            document.NewPage();

                        PdfPTable table = new PdfPTable(2);
                        //table.TotalWidth = 176f;
                        //fix the absolute width of the table
                        //table.LockedWidth = true;

                        //relative col widths in proportions
                        //float[] widths = new float[] { 1f, 1f };
                        //table.SetWidths(widths);
                        table.HorizontalAlignment = 1;
                        //leave a gap before and after the table
                        //table.SpacingBefore = 1f;
                        //table.SpacingAfter = 1f;
                        table.WidthPercentage = 95;

                        PdfPCell cell = new PdfPCell(new Phrase(objData[i].Brand, new Font(Font.FontFamily.HELVETICA, 3f, Font.BOLD)));
                        cell.Colspan = 2;
                        cell.Border = 0;
                        cell.Padding = 0f;
                        cell.HorizontalAlignment = 0; //0=Left, 1=Centre, 2=Right
                        table.AddCell(cell);

                        cell = new PdfPCell(new Phrase(objData[i].ProductName, new Font(Font.FontFamily.HELVETICA, 2f, Font.NORMAL)));
                        cell.Colspan = 2;
                        cell.Border = 0;
                        cell.Padding = 0f;
                        cell.HorizontalAlignment = 0; //0=Left, 1=Centre, 2=Right
                        table.AddCell(cell);

                        cell = new PdfPCell(AddSize(objData[i].SizeName));
                        cell.HorizontalAlignment = 0; //0=Left, 1=Centre, 2=Right
                        cell.Border = 0;
                        cell.Padding = 0f;
                        table.AddCell(cell);

                        cell = new PdfPCell(new Phrase("€ " + string.Format("{0:0.00}", objData[i].Price), new Font(Font.FontFamily.HELVETICA, 4f, Font.BOLD)));
                        cell.HorizontalAlignment = 2; //0=Left, 1=Centre, 2=Right
                        cell.Border = 0;
                        cell.Padding = .5f;
                        table.AddCell(cell);

                        pdfContentByte = pdfWriter.DirectContent;
                        img = GetBarcode128(pdfContentByte, objData[i].BarCode, false, Barcode.CODE128);

                        cell = new PdfPCell(); //new Phrase(new Chunk(img, 0, 0)));
                        cell.AddElement(img);
                        cell.Colspan = 2;
                        cell.Border = 0;
                        cell.Padding = 0f;
                        //cell.FixedHeight = img.Height + 200;
                        cell.HorizontalAlignment = 0; //0=Left, 1=Centre, 2=Right
                        table.AddCell(cell);

                        document.Add(table);

                        Kounter++;
                    }

                }
                document.Close();

            }

            HttpContext context = HttpContext.Current;
            Response.Clear();
            Response.ContentType = "application/pdf";
            Response.AppendHeader("Content-Disposition", "attachment; filename=Barcode_" + TimeStamp + ".pdf");
            Response.WriteFile(Server.MapPath("~/Handler/BarCode_" + TimeStamp + ".pdf"));
            Response.Flush();
            Response.Close();
            if (File.Exists(Server.MapPath("~/Handler/BarCode_" + TimeStamp + ".pdf")))
            {
                File.Delete(Server.MapPath("~/Handler/BarCode_" + TimeStamp + ".pdf"));
            }

        }
        catch (Exception ex)
        {
            if (document.IsOpen())
                document.Close();
            SendMail.MailMessage("CSWeb > Error > " + (new StackTrace()).GetFrame(0).GetMethod().Name, ex.ToString());
            Response.Write(ex.ToString());
        }
    }
Пример #27
0
        private void GenerateInvoicePDF()
        {
            Document document = new Document(PageSize.A4, 20f, 20f, 20f, 20f);
            try
            {
                if (!Directory.Exists(InvoiceFolderPath))
                {
                    Directory.CreateDirectory(InvoiceFolderPath);
                }

                PdfWriter.GetInstance(document, new FileStream(string.Format(InvoiceFolderPath + @"/Invoice{0}.pdf", txtInvoiceNumber.Text), FileMode.Create));
                document.Open();
                //Tables for Logo and Invoice Details
                PdfPTable outerHeader = new PdfPTable(2);
                outerHeader.DefaultCell.BorderWidth = 0;
                outerHeader.TotalWidth = 750f;
                outerHeader.WidthPercentage = 100;
                outerHeader.SpacingAfter = 20f;
                outerHeader.HorizontalAlignment = Element.ALIGN_LEFT;
                PdfPTable pdfCompanyTable = CreateCompanyGrid();
                PdfPTable pdfInvoiceTable = CreateInvoiceGrid();
                outerHeader.AddCell(pdfCompanyTable);
                outerHeader.AddCell(pdfInvoiceTable);

                //Tables for Billing and Shipping Address
                PdfPTable outerAddress = new PdfPTable(2);
                outerAddress.DefaultCell.BorderWidth = 0;
                outerAddress.TotalWidth = 750f;
                outerAddress.WidthPercentage = 100;
                outerAddress.SpacingAfter = 10f;
                outerAddress.HorizontalAlignment = Element.ALIGN_LEFT;
                PdfPTable pdfBillingAddressTable = CreateBillingAddressGrid();
                outerAddress.AddCell(pdfBillingAddressTable);
                PdfPTable pdfShippingAddressTable = CreateShippingAddressGrid();
                outerAddress.AddCell(pdfShippingAddressTable);

                //Product Table
                PdfPTable pdfProductTable = CreateProductsGrid();

                //Tables for Authorized Signatory and Invoice Amounts
                PdfPTable outerInvoiceDetails = new PdfPTable(2);
                outerInvoiceDetails.DefaultCell.BorderWidth = 0;
                outerInvoiceDetails.TotalWidth = 750f;
                outerInvoiceDetails.WidthPercentage = 100;
                outerInvoiceDetails.SpacingAfter = 20f;
                outerInvoiceDetails.HorizontalAlignment = Element.ALIGN_LEFT;
                PdfPTable pdfAuthorizedSignatoryTable = CreateAuthorizedSignatoryGrid();
                outerInvoiceDetails.AddCell(pdfAuthorizedSignatoryTable);
                PdfPTable pdfinvoiceAmountTable = CreateInvoiceAmountDetailsGrid();
                outerInvoiceDetails.AddCell(pdfinvoiceAmountTable);
                PdfPTable pdfNotes = CreateNotesGrid();
                //Adding all tables to the document
                document.Add(outerHeader);
                document.Add(outerAddress);
                document.Add(pdfProductTable);
                document.Add(outerInvoiceDetails);
                document.Add(pdfNotes);
                document.Close();
            }
            catch (Exception ex)
            {
                if (document.IsOpen())
                {
                    document.CloseDocument();
                }

                MessageBox.Show("Error previwing Invoice :" + ex.Message);
            }
        }
    /// <summary>
    /// 创建客户对账单
    /// </summary>
    /// <param name="document"></param>
    /// <param name="client"></param>
    /// <param name="documentDate"></param>
    /// <param name="year"></param>
    /// <param name="month"></param>
    /// <returns></returns>
    private Document ReceiveBillPDF(Document document, CM_Client client, string documentDate, DateTime dateBegin, DateTime dateEnd)
    {
        if (!document.IsOpen())
        {
            return null;
        }
        document = this.GetDocumentHeader(document, "客户对账单", documentDate, client);
        document.Add(Chunk.NEWLINE);

        string procName = "KD.AIS20140109134912.dbo.STKD_ARREPORT_CXCAI";//应收账款存储过程名

        DataTable dt = new DataTable();
        while (DateTime.Compare(dateBegin, dateEnd) <= 0)
        {
            //文档期间项
            int year = dateBegin.Year;
            int month = dateBegin.Month;
            DataTable dtTemp = new CM_ClientBLL().GetStatement(procName, year, month, client.Code);
            dt.Merge(dtTemp);

            dateBegin = dateBegin.AddMonths(1);
        }

        //DataColumn col = new DataColumn("dateStr");
        //col.DefaultValue = ViewState["dateStr"].ToString();
        //dt.Columns.Add(col);
        //dt.Columns["dateStr"].SetOrdinal(0);

        List<string> tableHeaders = new List<string>(5);
        tableHeaders.Add("单据日期");
        tableHeaders.Add("单据类型");
        tableHeaders.Add("单据编号");
        tableHeaders.Add("摘要");
        tableHeaders.Add("本期应收");
        tableHeaders.Add("本期实收");
        tableHeaders.Add("期末余额");
        for (int i = 0; i < dt.Columns.Count; i++)
        {
            dt.Columns[i].ColumnName = tableHeaders[i];
        }

        PdfPTable ptable = TableToPDFTable(dt);
        float[] widths = new float[] { 1f, 1.5f, 1f, 2f, 1f, 1f, 1f };
        ptable.SetWidths(widths);

        Paragraph paragraph = new Paragraph();
        paragraph.Add(ptable);
        paragraph.Alignment = Element.PTABLE;
        document.Add(paragraph);

        document.Add(Chunk.NEWLINE);

        this.GetDocumentSign(document);

        return document;
    }
Пример #29
0
        /// <summary>
        /// 匯出盤點工作PDF
        /// </summary>
        public void CountBookPDF()
        {
            PdfHelper pdf = new PdfHelper();
            List<string> pdfList = new List<string>();
            float[] arrColWidth = new float[] { 25, 60, 40, 40, 55,40, 140, 50, 40, 50};
            string newFileName = string.Empty;
            string newName = string.Empty;
            string json = string.Empty;
            BaseFont bf = BaseFont.CreateFont("C:\\WINDOWS\\Fonts\\simsun.ttc,1", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
            iTextSharp.text.Font fontChinese = new iTextSharp.text.Font(bf, 8, iTextSharp.text.Font.UNDERLINE, iTextSharp.text.BaseColor.RED);
            iTextSharp.text.Font font = new iTextSharp.text.Font(bf, 12, iTextSharp.text.Font.BOLD, new iTextSharp.text.BaseColor(0, 0, 0));//黑  
            string filename = "盤點工作" + DateTime.Now.ToString("yyyyMMddHHmmss");
            Document document = new Document(PageSize.A4.Rotate());
            string newPDFName = Server.MapPath(excelPath) + filename;
            PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(newPDFName, FileMode.Create));
            document.Open();
            int index = 0;
            CbjobMasterQuery query = new CbjobMasterQuery();
            List<CbjobMasterQuery> cbjobList = new List<CbjobMasterQuery>();
            query.IsPage = false;

            if (!string.IsNullOrEmpty(Request.Params["rowIDs"]))
            {
                query.row_id_IN = Request.Params["rowIDs"].TrimEnd(',');

            }
            _CbjobMasterMgr = new CbjobMasterMgr(mySqlConnectionString);
            int totalCount = 0;
            cbjobList = _CbjobMasterMgr.GetjobMaster(query, out  totalCount);
            DataTable _dtBody = new DataTable();
            _dtBody.Columns.Add("編號", typeof(string));
            _dtBody.Columns.Add("條碼", typeof(string));
            _dtBody.Columns.Add("料位", typeof(string));
            _dtBody.Columns.Add("現有庫存", typeof(string));
            _dtBody.Columns.Add("盤點數量", typeof(string));
            _dtBody.Columns.Add("效期控制", typeof(string));
            _dtBody.Columns.Add("品名", typeof(string));
            _dtBody.Columns.Add("規格", typeof(string));
            _dtBody.Columns.Add("細項編號", typeof(string));
            _dtBody.Columns.Add("備註", typeof(string));
            PdfPTable ptablefoot = new PdfPTable(10);

                if (cbjobList.Count > 0)
                {
                    _cbjobMgr = new CbjobDetailMgr(mySqlConnectionString);


                    for (int i = 0; i < cbjobList.Count; i++)
                    {
                        CbjobDetail cbdetail = new CbjobDetail();
                        cbdetail.cb_jobid = cbjobList[i].cbjob_id;
                        DataTable _dtdetail = _cbjobMgr.GetDetailTable(cbdetail);
                        _dtBody.Rows.Clear();


                        #region 標頭
                        #region 標頭
                        PdfPTable ptable = new PdfPTable(10);
                        ptable.WidthPercentage = 100;//表格寬度
                        ptable.SetTotalWidth(arrColWidth);
                        PdfPCell cell = new PdfPCell();
                        cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 12)));
                        cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                        cell.Colspan = 10;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(4);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 12)));
                        cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                        cell.Colspan = 4;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        // cell.DisableBorderSide(4);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("      盤點薄" + "-" + cbdetail.cb_jobid, new iTextSharp.text.Font(bf, 18)));
                        cell.VerticalAlignment = Element.ALIGN_LEFT;
                        cell.Colspan = 3;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 12)));
                        cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                        cell.Colspan = 3;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        cell.DisableBorderSide(4);
                        // cell.DisableBorderSide(8);
                        ptable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 12)));
                        cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                        cell.Colspan = 10;
                        cell.DisableBorderSide(1);
                        cell.DisableBorderSide(2);
                        // cell.DisableBorderSide(4);
                        //cell.DisableBorderSide(8);
                        ptable.AddCell(cell);


                        #endregion
                        #region 表頭
                        cell = new PdfPCell(new Phrase("編號", new iTextSharp.text.Font(bf, 12)));
                        cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("條碼", new iTextSharp.text.Font(bf, 12)));
                        cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);



                        cell = new PdfPCell(new Phrase("料位", new iTextSharp.text.Font(bf, 12)));
                        cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("現有庫存", new iTextSharp.text.Font(bf, 12)));
                        cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("盤點數量", new iTextSharp.text.Font(bf, 12)));
                        cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("效期控制", new iTextSharp.text.Font(bf, 12)));
                        cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("品名", new iTextSharp.text.Font(bf, 12)));
                        cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);

                        cell = new PdfPCell(new Phrase("規格", new iTextSharp.text.Font(bf, 12)));
                        cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("細項編號", new iTextSharp.text.Font(bf, 12)));
                        cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                        cell.DisableBorderSide(8);
                        ptable.AddCell(cell);
                        cell = new PdfPCell(new Phrase("備註", new iTextSharp.text.Font(bf, 12)));
                        cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                        ptable.AddCell(cell);
                        #endregion
                        #endregion

                        if (_dtdetail.Rows.Count > 0)
                        {
                            _IiupcMgr = new IupcMgr(mySqlConnectionString);
                            int a = 0;
                            foreach (DataRow rows in _dtdetail.Rows)
                            {
                                a++;
                                string upc_id = string.Empty;
                                #region 取條碼

                                List<IupcQuery> list = new List<IupcQuery>();
                                IupcQuery iupc_query = new IupcQuery();
                                if (!string.IsNullOrEmpty(rows["item_id"].ToString()))
                                {
                                    uint item_id = uint.Parse(rows["item_id"].ToString());
                                    iupc_query.item_id = item_id;
                                    iupc_query.upc_type_flg = "1";
                                    list = _IiupcMgr.GetIupcByType(iupc_query);
                                    if (list.Count > 0)
                                    {
                                        upc_id = list[0].upc_id;
                                    }
                                    else
                                    {
                                        iupc_query.upc_type_flg = "3";
                                        list = _IiupcMgr.GetIupcByType(iupc_query);
                                        if (list.Count > 0)
                                        {
                                            upc_id = list[0].upc_id;
                                        }
                                        else
                                        {
                                            iupc_query.upc_type_flg = "2";
                                            list = _IiupcMgr.GetIupcByType(iupc_query);
                                            if (list.Count > 0)
                                            {
                                                upc_id = list[0].upc_id;
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    upc_id = " ";
                                }
                                #endregion
                                DataRow row = _dtBody.NewRow();
                                row["編號"] = a;
                                row["條碼"] = upc_id;

                                row["料位"] = rows["loc_id"];
                                row["現有庫存"] = rows["prod_qty"];
                                row["盤點數量"] = "";
                                row["效期控制"] = string.IsNullOrEmpty(rows["pwy_dte_ctl"].ToString()) ? "否" : (rows["pwy_dte_ctl"].ToString() == "Y" ? "是" : "否");
                                row["品名"] = rows["product_name"];
                                row["規格"] = rows["spec_title_1"];
                                row["細項編號"] = rows["item_id"];
                                row["備註"] = " ";
                                _dtBody.Rows.Add(row);
                            }
                        }
                        newFileName = newPDFName + "_part" + index++ + "." + "pdf";
                        pdf.ExportDataTableToPDF(_dtBody, false, newFileName, arrColWidth, ptable, ptablefoot, "", "", 10, uint.Parse(_dtBody.Rows.Count.ToString()));/*第一7是列,第二個是行*/
                        pdfList.Add(newFileName);
                    }



                }
            if (_dtBody.Rows.Count == 0)
            {
                #region 標頭
                #region 標頭
                PdfPTable ptable = new PdfPTable(10);
                ptable.WidthPercentage = 100;//表格寬度
                ptable.SetTotalWidth(arrColWidth);
                PdfPCell cell = new PdfPCell();
                cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.Colspan = 10;
                cell.DisableBorderSide(1);
                cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.Colspan = 4;
                cell.DisableBorderSide(1);
                cell.DisableBorderSide(2);
                // cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("      盤點薄", new iTextSharp.text.Font(bf, 18)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;
                cell.Colspan = 3;
                cell.DisableBorderSide(1);
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.Colspan = 3;
                cell.DisableBorderSide(1);
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(4);
                // cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.Colspan = 10;
                cell.DisableBorderSide(1);
                cell.DisableBorderSide(2);
                // cell.DisableBorderSide(4);
                //cell.DisableBorderSide(8);
                ptable.AddCell(cell);


                #endregion
                #region 表頭
                cell = new PdfPCell(new Phrase("編號", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("條碼", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);



                cell = new PdfPCell(new Phrase("料位", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("現有庫存", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("盤點數量", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase("效期控制", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase("品名", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("規格", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase("細項編號", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase("備註", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                ptable.AddCell(cell);
                #endregion
                #endregion
                document = new Document(PageSize.A4.Rotate());
                if (!document.IsOpen())
                {
                    document.Open();
                }
                cell = new PdfPCell(new Phrase(" ", font));
                cell.Colspan = 4;
                cell.VerticalAlignment = Element.ALIGN_CENTER;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("此工作代號無數據!", font));
                cell.Colspan = 3;
                cell.DisableBorderSide(4);
                cell.VerticalAlignment = Element.ALIGN_CENTER;//字體水平居左
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase(" ", font));
                cell.Colspan = 3;
                cell.VerticalAlignment = Element.ALIGN_CENTER;//字體水平居左
                //cell.DisableBorderSide(8);
                ptable.AddCell(cell);


                // document.Add(ptable);
                //document.Add(ptablefoot); 
                newFileName = newPDFName + "_part" + index++ + "." + "pdf";
                pdf.ExportDataTableToPDF(_dtBody, false, newFileName, arrColWidth, ptable, ptablefoot, "", "", 10, uint.Parse(_dtBody.Rows.Count.ToString()));/*第一7是列,第二個是行*/
                pdfList.Add(newFileName);

            }
            newFileName = newPDFName + "." + "pdf";
            pdf.MergePDF(pdfList, newFileName);

            Response.Clear();
            Response.Charset = "gb2312";
            Response.ContentEncoding = System.Text.Encoding.UTF8;
            Response.AddHeader("Content-Disposition", "attach-ment;filename=" + filename + ".pdf");
            Response.WriteFile(newFileName);
        }
Пример #30
0
        public void AseldPDFS()
        {
            PdfHelper pdf = new PdfHelper();
            List<string> pdfList = new List<string>();
            float[] arrColWidth = new float[] {  135,50,45, 60,  55, 55,60, 45,  35, 45, 45, 35 };
            int index = 0;
            string newFileName = string.Empty;
            string newName = string.Empty;
            string json = string.Empty;
            BaseFont bf = BaseFont.CreateFont("C:\\WINDOWS\\Fonts\\simsun.ttc,1", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
            iTextSharp.text.Font fontChinese = new iTextSharp.text.Font(bf, 8, iTextSharp.text.Font.UNDERLINE, iTextSharp.text.BaseColor.RED);
            iTextSharp.text.Font font = new iTextSharp.text.Font(bf, 12, iTextSharp.text.Font.BOLD, new iTextSharp.text.BaseColor(0, 0, 0));//黑  
            string filename = "總量撿貨報表" + DateTime.Now.ToString("yyyyMMddHHmmss");
            Document document = new Document(PageSize.A4.Rotate());
            string newPDFName = Server.MapPath(excelPath) + filename;
            PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(newPDFName, FileMode.Create));
            document.Open();


            string user_username = (Session["caller"] as Caller).user_username;
            DataTable aseldTable = new DataTable();
            DataTable assg_idTable = new DataTable();
            AseldQuery ase_query = new AseldQuery();
            ase_query.IsPage = false;
            ase_query.assg_id = string.Empty;
            ase_query.start_dtim = DateTime.MinValue;
            ase_query.change_dtim = DateTime.MinValue;
            int total = 0;

            //PdfHelper pdf = new PdfHelper();
            //List<string> pdfList = new List<string>();
            //string newfilename = string.Empty;
            //string filename = "待撿貨商品報表" + DateTime.Now.ToString("yyyyMMddHHmmss");
            //string newPDFName = Server.MapPath(excelPath) + filename;
            //int index = 0;
            int serchWhr = 0;

            if (!string.IsNullOrEmpty(Request.Params["assg_id"]))
            {
                ase_query.assg_id = Request.Params["assg_id"].Trim();
                serchWhr++;
            }
            DateTime date = DateTime.MinValue;
            if (Request.Params["start_time"] != "null" && Request.Params["end_time"] != "null")
            {
                if (DateTime.TryParse(Request.Params["start_time"], out date))
                {
                    ase_query.start_dtim = Convert.ToDateTime(date.ToString("yyyy-MM-dd HH:mm:ss"));
                }
                if (DateTime.TryParse(Request.Params["end_time"], out date))
                {
                    ase_query.change_dtim = Convert.ToDateTime(date.ToString("yyyy-MM-dd HH:mm:ss"));
                }
                serchWhr++;
            }
            IAseldImplMgr aseldMgr = new AseldMgr(mySqlConnectionString);

            DataTable _dtBody = new DataTable();
           
            _dtBody.Columns.Add("商品名稱", typeof(string));
            _dtBody.Columns.Add("料位編號", typeof(string));
            _dtBody.Columns.Add("撿貨庫存", typeof(string));
            _dtBody.Columns.Add("本次撿貨量", typeof(string));
            _dtBody.Columns.Add("製造日期", typeof(string)); 
            _dtBody.Columns.Add("有效日期", typeof(string));
            _dtBody.Columns.Add("條碼", typeof(string));
            _dtBody.Columns.Add("細項編號", typeof(string));

            _dtBody.Columns.Add("訂貨量", typeof(string));
            _dtBody.Columns.Add("已撿貨量", typeof(string));
            _dtBody.Columns.Add("待撿貨量", typeof(string));
           
            
            _dtBody.Columns.Add("備註", typeof(string));
            PdfPTable ptablefoot = new PdfPTable(14);
            #region MyRegion



            #region 數據行
            if (ase_query.assg_id != string.Empty)
            {
                _dtBody.Rows.Clear();
                aseldTable = aseldMgr.GetAseldTable(ase_query, out total);
                #region 標頭
                #region 表頭
                PdfPTable ptable = new PdfPTable(12);


                ptable.WidthPercentage = 100;//表格寬度
                ptable.SetTotalWidth(arrColWidth);
                PdfPCell cell = new PdfPCell();
                cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.Colspan = 12;
                cell.DisableBorderSide(1);
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.Colspan = 4;
                cell.DisableBorderSide(1);
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("總量撿貨報表", new iTextSharp.text.Font(bf, 18)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;
                cell.Colspan = 5;
                cell.DisableBorderSide(1);
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.Colspan = 3;
                cell.DisableBorderSide(1);
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.Colspan = 12;
                cell.DisableBorderSide(1);
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("印表人:" + user_username, new iTextSharp.text.Font(bf, 8)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.Colspan = 3;
                cell.DisableBorderSide(1);
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(bf, 8)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.Colspan = 6;
                cell.DisableBorderSide(1);
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("印表時間:" + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"), new iTextSharp.text.Font(bf, 8)));
                cell.VerticalAlignment = Element.ALIGN_RIGHT;//字體水平居右
                cell.Colspan = 3;
                cell.DisableBorderSide(1);
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(bf, 8)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.Colspan = 12;
                cell.DisableBorderSide(1);
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                #endregion
                cell = new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(bf, 8)));
                cell.VerticalAlignment = Element.ALIGN_RIGHT;//字體水平居右
                cell.Colspan = 4;
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase("工作代號:" + ase_query.assg_id, new iTextSharp.text.Font(bf, 15)));
                cell.VerticalAlignment = Element.ALIGN_CENTER;
                cell.Colspan = 5;
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(bf, 8)));
                cell.VerticalAlignment = Element.ALIGN_RIGHT;//字體水平居右
                cell.Colspan = 3;
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(4);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase("商品名稱", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase("料位編號", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase("撿貨庫存", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("本次撿貨量", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase("製造日期", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                //cell = new PdfPCell(new Phrase("撿貨料位編號", new iTextSharp.text.Font(bf, 8)));
                //cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                //cell.DisableBorderSide(8);
                //ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase("有效日期", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase("條碼", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase("細項編號", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
               
               
               

                cell = new PdfPCell(new Phrase("訂貨量", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("已撿貨量", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("待撿貨量", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
               
           

                //cell = new PdfPCell(new Phrase("創建時間", new iTextSharp.text.Font(bf, 8)));
                //cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                //ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("備註", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                ptable.AddCell(cell);
                #endregion
                #region 新增功能


                if (aseldTable.Rows.Count > 0)
                {
                    _iinvd = new IinvdMgr(mySqlConnectionString);//  GetSearchIinvd
                    _IiupcMgr = new IupcMgr(mySqlConnectionString);
                    foreach (DataRow rows in aseldTable.Rows)
                    {
                        IinvdQuery IinvdQuery = new IinvdQuery();
                        IinvdQuery.item_id = uint.Parse(rows["item_id"].ToString());
                        IinvdQuery.ista_id = "A";
                        List<IinvdQuery> Store = new List<IinvdQuery>();
                        Store = _iinvd.GetPlasIinvd(IinvdQuery);
                        int P_num = string.IsNullOrEmpty(rows["out_qty"].ToString()) ? 0 : int.Parse(rows["out_qty"].ToString()); /*要撿貨的數量*/
                        string upc_id = string.Empty;
                        #region 取條碼

                        List<IupcQuery> list = new List<IupcQuery>();
                        IupcQuery iupc_query = new IupcQuery();
                        if (!string.IsNullOrEmpty(rows["item_id"].ToString()))
                        {
                            uint item_id = uint.Parse(rows["item_id"].ToString());
                            iupc_query.item_id = item_id;
                            iupc_query.upc_type_flg = "1";
                            list = _IiupcMgr.GetIupcByType(iupc_query);
                            if (list.Count > 0)
                            {
                                upc_id = list[0].upc_id;
                            }
                            else
                            {
                                iupc_query.upc_type_flg = "3";
                                list = _IiupcMgr.GetIupcByType(iupc_query);
                                if (list.Count > 0)
                                {
                                    upc_id = list[0].upc_id;
                                }
                                else
                                {
                                    iupc_query.upc_type_flg = "2";
                                    list = _IiupcMgr.GetIupcByType(iupc_query);
                                    if (list.Count > 0)
                                    {
                                        upc_id = list[0].upc_id;
                                    }
                                }
                            }
                        }
                        
                        else
                        {
                            upc_id = " ";
                        }
                        #endregion

                        if (Store.Count > 0)
                        {
                            int crorow = 0;
                            for (int i = 0; i < Store.Count; i++)
                            {
                                DataRow row = _dtBody.NewRow();
                                if (Store[i].prod_qty > P_num)
                                {
                                    if (crorow != 0)
                                    {
                                        row["商品名稱"] = "";
                                        row["條碼"] = "";
                                        row["細項編號"] ="";
                                        row["訂貨量"] = "";
                                        row["已撿貨量"] = "";
                                        row["待撿貨量"] = "";
                                        row["料位編號"] = "";
                                    }
                                    else
                                    {
                                        row["商品名稱"] = rows["product_name"] + rows["spec"].ToString();
                                        row["條碼"] = upc_id;
                                        row["細項編號"] = rows["item_id"];
                                        row["訂貨量"] = rows["ord_qty"];
                                        row["已撿貨量"] = rows["act_pick_qty"];
                                        row["待撿貨量"] = rows["out_qty"];
                                        row["料位編號"] = rows["loc_id"];
                                    }
                                    row["製造日期"] = string.IsNullOrEmpty(Store[i].made_date.ToString()) ? " " : Store[i].made_date.ToString("yyyy/MM/dd");
                                    row["有效日期"] = string.IsNullOrEmpty(Store[i].cde_dt.ToString()) ? " " : Store[i].cde_dt.ToString("yyyy/MM/dd");
                                    row["撿貨庫存"] = P_num;
                                    row["本次撿貨量"] = " ";
                                    row["備註"] = " ";
                                    // row["撿貨料位編號"] = Store[i].plas_loc_id;
                                   
                                   
                                  //  row["創建時間"] = rows["create_dtim"];
                                  
                                    _dtBody.Rows.Add(row);
                                    break;
                                }
                                else
                                {
                                    if (crorow != 0)
                                    {
                                        row["商品名稱"] = "";
                                        row["條碼"] = "";
                                        row["細項編號"] = "";
                                        row["訂貨量"] = "";
                                        row["已撿貨量"] = "";
                                        row["待撿貨量"] = "";
                                        row["料位編號"] = "";
                                    }
                                    else
                                    {
                                        row["商品名稱"] = rows["product_name"] + rows["spec"].ToString();
                                        row["條碼"] = upc_id;
                                        row["細項編號"] = rows["item_id"];
                                        row["訂貨量"] = rows["ord_qty"];
                                        row["已撿貨量"] = rows["act_pick_qty"];
                                        row["待撿貨量"] = rows["out_qty"];
                                        row["料位編號"] = rows["loc_id"];
                                    }
                                    row["製造日期"] = string.IsNullOrEmpty(Store[i].made_date.ToString()) ? " " : Store[i].made_date.ToString("yyyy/MM/dd");
                                    row["有效日期"] = string.IsNullOrEmpty(Store[i].cde_dt.ToString()) ? " " : Store[i].cde_dt.ToString("yyyy/MM/dd");
                                    row["撿貨庫存"] = Store[i].prod_qty;
                                    row["本次撿貨量"] = " ";

                                    //row["撿貨料位編號"] = Store[i].plas_loc_id;
                                  //  row["創建時間"] = rows["create_dtim"];
                                    row["備註"] = " ";
                                    _dtBody.Rows.Add(row);
                                    P_num -= Store[i].prod_qty;
                                    crorow++;
                                    if (P_num == 0)
                                        break;
                                }

                            }
                            // _dtBody.Rows.Add(row);
                        }
                        else
                        {
                            DataRow row = _dtBody.NewRow();
                            row["商品名稱"] = rows["product_name"] + rows["spec"].ToString();
                            row["條碼"] = upc_id;
                            row["細項編號"] = rows["item_id"];
                            row["訂貨量"] = rows["ord_qty"];
                            row["已撿貨量"] = rows["act_pick_qty"];
                            row["待撿貨量"] = rows["out_qty"];
                            row["本次撿貨量"] = " ";
                            row["料位編號"] = rows["loc_id"];
                            //row["撿貨料位編號"] = " ";
                            row["撿貨庫存"] = 0;
                            row["製造日期"] = " ";
                            row["有效日期"] = " ";
                         //   row["創建時間"] = rows["create_dtim"];
                            row["備註"] = " ";
                            _dtBody.Rows.Add(row);
                        }


                    }
                }
                #endregion

                //  pdfList.Add(MakePDF(aseldTable, ase_query.assg_id, user_username, newPDFName, index++));
                newFileName = newPDFName + "_part" + index++ + "." + "pdf";
                pdf.ExportDataTableToPDF(_dtBody, false, newFileName, arrColWidth, ptable, ptablefoot, "", "", 12, uint.Parse(_dtBody.Rows.Count.ToString()));/*第一7是列,第二個是行*/
                pdfList.Add(newFileName);
            }
            else if (ase_query.start_dtim != DateTime.MinValue && ase_query.change_dtim != DateTime.MinValue || serchWhr == 0)
            {
                assg_idTable = aseldMgr.GetAseldTablePDF(ase_query);
                for (int a = 0; a < assg_idTable.Rows.Count; a++)
                {
                    ase_query.assg_id = assg_idTable.Rows[a]["assg_id"].ToString();
                    aseldTable = aseldMgr.GetAseldTable(ase_query, out total);
                    _dtBody.Rows.Clear();
                    #region 標頭
                    #region 表頭
                    PdfPTable ptable = new PdfPTable(12);


                    ptable.WidthPercentage = 100;//表格寬度
                    ptable.SetTotalWidth(arrColWidth);
                    PdfPCell cell = new PdfPCell();
                    cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 12)));
                    cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                    cell.Colspan = 12;
                    cell.DisableBorderSide(1);
                    cell.DisableBorderSide(2);
                    cell.DisableBorderSide(4);
                    cell.DisableBorderSide(8);
                    ptable.AddCell(cell);

                    cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 12)));
                    cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                    cell.Colspan = 4;
                    cell.DisableBorderSide(1);
                    cell.DisableBorderSide(2);
                    cell.DisableBorderSide(4);
                    cell.DisableBorderSide(8);
                    ptable.AddCell(cell);

                    cell = new PdfPCell(new Phrase("總量撿貨報表", new iTextSharp.text.Font(bf, 18)));
                    cell.VerticalAlignment = Element.ALIGN_LEFT;
                    cell.Colspan = 5;
                    cell.DisableBorderSide(1);
                    cell.DisableBorderSide(2);
                    cell.DisableBorderSide(4);
                    cell.DisableBorderSide(8);
                    ptable.AddCell(cell);

                    cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 12)));
                    cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                    cell.Colspan = 4;
                    cell.DisableBorderSide(1);
                    cell.DisableBorderSide(2);
                    cell.DisableBorderSide(4);
                    cell.DisableBorderSide(8);
                    ptable.AddCell(cell);

                    cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 12)));
                    cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                    cell.Colspan = 12;
                    cell.DisableBorderSide(1);
                    cell.DisableBorderSide(2);
                    cell.DisableBorderSide(4);
                    cell.DisableBorderSide(8);
                    ptable.AddCell(cell);

                    cell = new PdfPCell(new Phrase("印表人:" + user_username, new iTextSharp.text.Font(bf, 8)));
                    cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                    cell.Colspan = 3;
                    cell.DisableBorderSide(1);
                    cell.DisableBorderSide(2);
                    cell.DisableBorderSide(4);
                    cell.DisableBorderSide(8);
                    ptable.AddCell(cell);
                    cell = new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(bf, 8)));
                    cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                    cell.Colspan = 6;
                    cell.DisableBorderSide(1);
                    cell.DisableBorderSide(2);
                    cell.DisableBorderSide(4);
                    cell.DisableBorderSide(8);
                    ptable.AddCell(cell);

                    cell = new PdfPCell(new Phrase("印表時間:" + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"), new iTextSharp.text.Font(bf, 8)));
                    cell.VerticalAlignment = Element.ALIGN_RIGHT;//字體水平居右
                    cell.Colspan = 3;
                    cell.DisableBorderSide(1);
                    cell.DisableBorderSide(2);
                    cell.DisableBorderSide(4);
                    cell.DisableBorderSide(8);
                    ptable.AddCell(cell);

                    cell = new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(bf, 8)));
                    cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                    cell.Colspan = 12;
                    cell.DisableBorderSide(1);
                    cell.DisableBorderSide(2);
                    cell.DisableBorderSide(4);
                    cell.DisableBorderSide(8);
                    ptable.AddCell(cell);
                    #endregion
                    cell = new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(bf, 8)));
                    cell.VerticalAlignment = Element.ALIGN_RIGHT;//字體水平居右
                    cell.Colspan = 4;
                    cell.DisableBorderSide(2);
                    cell.DisableBorderSide(8);
                    ptable.AddCell(cell);
                    cell = new PdfPCell(new Phrase("工作代號:" + ase_query.assg_id, new iTextSharp.text.Font(bf, 15)));
                    cell.VerticalAlignment = Element.ALIGN_CENTER;
                    cell.Colspan = 5;
                    cell.DisableBorderSide(2);
                    cell.DisableBorderSide(4);
                    cell.DisableBorderSide(8);
                    ptable.AddCell(cell);
                    cell = new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(bf, 8)));
                    cell.VerticalAlignment = Element.ALIGN_RIGHT;//字體水平居右
                    cell.Colspan = 3;
                    cell.DisableBorderSide(2);
                    cell.DisableBorderSide(4);
                    ptable.AddCell(cell);
                    cell = new PdfPCell(new Phrase("商品名稱", new iTextSharp.text.Font(bf, 12)));
                    cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                    cell.DisableBorderSide(8);
                    ptable.AddCell(cell);
                    cell = new PdfPCell(new Phrase("料位編號", new iTextSharp.text.Font(bf, 12)));
                    cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                    cell.DisableBorderSide(8);
                    ptable.AddCell(cell);
                     cell = new PdfPCell(new Phrase("撿貨庫存", new iTextSharp.text.Font(bf, 12)));
                    cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                    cell.DisableBorderSide(8);
                    ptable.AddCell(cell);

                    cell = new PdfPCell(new Phrase("本次撿貨量", new iTextSharp.text.Font(bf, 12)));
                    cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                    cell.DisableBorderSide(8);
                    ptable.AddCell(cell);
                    cell = new PdfPCell(new Phrase("製造日期", new iTextSharp.text.Font(bf, 12)));
                    cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                    cell.DisableBorderSide(8);
                    ptable.AddCell(cell);
                    //cell = new PdfPCell(new Phrase("撿貨料位編號", new iTextSharp.text.Font(bf, 8)));
                    //cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                    //cell.DisableBorderSide(8);
                    //ptable.AddCell(cell);
                    cell = new PdfPCell(new Phrase("有效日期", new iTextSharp.text.Font(bf, 12)));
                    cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                    cell.DisableBorderSide(8);
                    ptable.AddCell(cell);
                    cell = new PdfPCell(new Phrase("條碼", new iTextSharp.text.Font(bf, 12)));
                    cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                    cell.DisableBorderSide(8);
                    ptable.AddCell(cell);
                    cell = new PdfPCell(new Phrase("細項編號", new iTextSharp.text.Font(bf, 12)));
                    cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                    cell.DisableBorderSide(8);
                    ptable.AddCell(cell);
                    
                   
                   

                    cell = new PdfPCell(new Phrase("訂貨量", new iTextSharp.text.Font(bf, 12)));
                    cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                    cell.DisableBorderSide(8);
                    ptable.AddCell(cell);

                    cell = new PdfPCell(new Phrase("已撿貨量", new iTextSharp.text.Font(bf, 12)));
                    cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                    cell.DisableBorderSide(8);
                    ptable.AddCell(cell);

                    cell = new PdfPCell(new Phrase("待撿貨量", new iTextSharp.text.Font(bf, 12)));
                    cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                    cell.DisableBorderSide(8);
                    ptable.AddCell(cell);
                   
                  

                    //cell = new PdfPCell(new Phrase("創建時間", new iTextSharp.text.Font(bf, 8)));
                    //cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                    //ptable.AddCell(cell);

                    cell = new PdfPCell(new Phrase("備註", new iTextSharp.text.Font(bf, 12)));
                    cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                    ptable.AddCell(cell);
                    #endregion


                    #region 新增功能


                    if (aseldTable.Rows.Count > 0)
                    {
                        _iinvd = new IinvdMgr(mySqlConnectionString);//  GetSearchIinvd
                        _IiupcMgr = new IupcMgr(mySqlConnectionString);
                        foreach (DataRow rows in aseldTable.Rows)
                        {
                            IinvdQuery IinvdQuery = new IinvdQuery();
                            IinvdQuery.item_id = uint.Parse(rows["item_id"].ToString());
                            IinvdQuery.ista_id = "A";
                            List<IinvdQuery> Store = new List<IinvdQuery>();
                            Store = _iinvd.GetPlasIinvd(IinvdQuery);
                            int P_num = string.IsNullOrEmpty(rows["out_qty"].ToString()) ? 0 : int.Parse(rows["out_qty"].ToString()); /*要撿貨的數量*/
                            string upc_id = string.Empty;
                            #region 取條碼

                            List<IupcQuery> list = new List<IupcQuery>();
                            IupcQuery iupc_query = new IupcQuery();
                            if (!string.IsNullOrEmpty(rows["item_id"].ToString()))
                            {
                                uint item_id = uint.Parse(rows["item_id"].ToString());
                                iupc_query.item_id = item_id;
                                iupc_query.upc_type_flg = "1";
                                list = _IiupcMgr.GetIupcByType(iupc_query);
                                if (list.Count > 0)
                                {
                                    upc_id = list[0].upc_id;
                                }
                                else
                                {
                                    iupc_query.upc_type_flg = "3";
                                    list = _IiupcMgr.GetIupcByType(iupc_query);
                                    if (list.Count > 0)
                                    {
                                        upc_id = list[0].upc_id;
                                    }
                                    else
                                    {
                                        iupc_query.upc_type_flg = "2";
                                        list = _IiupcMgr.GetIupcByType(iupc_query);
                                        if (list.Count > 0)
                                        {
                                            upc_id = list[0].upc_id;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                upc_id = " ";
                            }
                            #endregion

                            if (Store.Count > 0)
                            {
                                int crorow = 0;
                                for (int i = 0; i < Store.Count; i++)
                                {
                                    DataRow row = _dtBody.NewRow();
                                    if (Store[i].prod_qty > P_num)
                                    {
                                        if (crorow != 0)
                                        {
                                            row["商品名稱"] = "";
                                            row["條碼"] = "";
                                            row["細項編號"] = "";
                                            row["訂貨量"] = "";
                                            row["已撿貨量"] = "";
                                            row["待撿貨量"] = "";
                                            row["料位編號"] = "";
                                        }
                                        else
                                        {
                                            row["商品名稱"] = rows["product_name"] + rows["spec"].ToString();
                                            row["條碼"] = upc_id;
                                            row["細項編號"] = rows["item_id"];
                                            row["訂貨量"] = rows["ord_qty"];
                                            row["已撿貨量"] = rows["act_pick_qty"];
                                            row["待撿貨量"] = rows["out_qty"];
                                            row["料位編號"] = rows["loc_id"];
                                        }
                                        row["製造日期"] = string.IsNullOrEmpty(Store[i].made_date.ToString()) ? " " : Store[i].made_date.ToString("yyyy/MM/dd");
                                        row["有效日期"] = string.IsNullOrEmpty(Store[i].cde_dt.ToString()) ? " " : Store[i].cde_dt.ToString("yyyy/MM/dd");
                                        row["撿貨庫存"] = P_num;
                                        row["本次撿貨量"] = " ";
                                        row["備註"] = " ";
                                        _dtBody.Rows.Add(row);
                                        break;
                                    }
                                    else
                                    {
                                        if (crorow != 0)
                                        {
                                            row["商品名稱"] = "";
                                            row["條碼"] = "";
                                            row["細項編號"] = "";
                                            row["訂貨量"] = "";
                                            row["已撿貨量"] = "";
                                            row["待撿貨量"] = "";
                                            row["料位編號"] = "";
                                        }
                                        else
                                        {
                                            row["商品名稱"] = rows["product_name"] + rows["spec"].ToString();
                                            row["條碼"] = upc_id;
                                            row["細項編號"] = rows["item_id"];
                                            row["訂貨量"] = rows["ord_qty"];
                                            row["已撿貨量"] = rows["act_pick_qty"];
                                            row["待撿貨量"] = rows["out_qty"];
                                            row["料位編號"] = rows["loc_id"];
                                        }
                                        row["製造日期"] = string.IsNullOrEmpty(Store[i].made_date.ToString()) ? " " : Store[i].made_date.ToString("yyyy/MM/dd");
                                        row["有效日期"] = string.IsNullOrEmpty(Store[i].cde_dt.ToString()) ? " " : Store[i].cde_dt.ToString("yyyy/MM/dd");
                                        row["撿貨庫存"] = Store[i].prod_qty;
                                        row["本次撿貨量"] = " ";

                                        //row["撿貨料位編號"] = Store[i].plas_loc_id;
                                        //  row["創建時間"] = rows["create_dtim"];
                                        row["備註"] = " ";
                                        _dtBody.Rows.Add(row);
                                        crorow++;
                                        P_num -= Store[i].prod_qty;
                                        if (P_num == 0)
                                            break;
                                    }

                                }
                                // _dtBody.Rows.Add(row);
                            }
                            else
                            {
                                DataRow row = _dtBody.NewRow();
                                row["商品名稱"] = rows["product_name"] + rows["spec"].ToString();
                                row["條碼"] = upc_id;
                                row["細項編號"] = rows["item_id"];
                                row["訂貨量"] = rows["ord_qty"];
                                row["已撿貨量"] = rows["act_pick_qty"];
                                row["待撿貨量"] = rows["out_qty"];
                                
                                row["本次撿貨量"] = " ";
                                row["料位編號"] = rows["loc_id"];
                                //row["撿貨料位編號"] = " ";
                                row["撿貨庫存"] = 0;
                                row["製造日期"] = " ";
                                row["有效日期"] = " ";
                              //  row["創建時間"] = rows["create_dtim"];
                                row["備註"] = " ";
                                _dtBody.Rows.Add(row);
                            }


                        }
                    }
                    #endregion

                    //  pdfList.Add(MakePDF(aseldTable, ase_query.assg_id, user_username, newPDFName, index++));
                    newFileName = newPDFName + "_part" + index++ + "." + "pdf";
                    pdf.ExportDataTableToPDF(_dtBody, false, newFileName, arrColWidth, ptable, ptablefoot, "", "", 12, uint.Parse(_dtBody.Rows.Count.ToString()));/*第一7是列,第二個是行*/
                    pdfList.Add(newFileName);
                }
            }
            #endregion

            #endregion
           
          
            if (_dtBody.Rows.Count == 0)
            {
                #region 標頭
                #region 表頭
                PdfPTable ptable = new PdfPTable(12);


                ptable.WidthPercentage = 100;//表格寬度
                ptable.SetTotalWidth(arrColWidth);
                PdfPCell cell = new PdfPCell();
                cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.Colspan = 12;
                cell.DisableBorderSide(1);
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.Colspan = 4;
                cell.DisableBorderSide(1);
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("總量撿貨報表", new iTextSharp.text.Font(bf, 18)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;
                cell.Colspan = 5;
                cell.DisableBorderSide(1);
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.Colspan = 3;
                cell.DisableBorderSide(1);
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.Colspan = 12;
                cell.DisableBorderSide(1);
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("印表人:" + user_username, new iTextSharp.text.Font(bf, 8)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.Colspan = 3;
                cell.DisableBorderSide(1);
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(bf, 8)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.Colspan = 6;
                cell.DisableBorderSide(1);
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("印表時間:" + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"), new iTextSharp.text.Font(bf, 8)));
                cell.VerticalAlignment = Element.ALIGN_RIGHT;//字體水平居右
                cell.Colspan = 3;
                cell.DisableBorderSide(1);
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(bf, 8)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.Colspan = 12;
                cell.DisableBorderSide(1);
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                #endregion
                cell = new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(bf, 8)));
                cell.VerticalAlignment = Element.ALIGN_RIGHT;//字體水平居右
                cell.Colspan = 4;
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase("工作代號:" + ase_query.assg_id, new iTextSharp.text.Font(bf, 15)));
                cell.VerticalAlignment = Element.ALIGN_CENTER;
                cell.Colspan = 5;
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(bf, 8)));
                cell.VerticalAlignment = Element.ALIGN_RIGHT;//字體水平居右
                cell.Colspan = 3;
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(4);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase("商品名稱", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase("料位編碼", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase("撿貨庫存", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("本次撿貨量", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase("製造日期", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                //cell = new PdfPCell(new Phrase("撿貨料位編號", new iTextSharp.text.Font(bf, 8)));
                //cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                //cell.DisableBorderSide(8);
                //ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase("有效日期", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase("條碼", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                
               
                cell = new PdfPCell(new Phrase("細項編號", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("訂貨量", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("已撿貨量", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("待撿貨量", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                


                //cell = new PdfPCell(new Phrase("創建時間", new iTextSharp.text.Font(bf, 8)));
                //cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                //ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("備註", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                ptable.AddCell(cell);
                #endregion
                document = new Document(PageSize.A4.Rotate());
                if (!document.IsOpen())
                {
                    document.Open();
                }
                cell = new PdfPCell(new Phrase(" ", font));
                cell.Colspan = 5;
                cell.VerticalAlignment = Element.ALIGN_CENTER;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("此工作代號無數據!", font));
                cell.Colspan = 9;
                cell.DisableBorderSide(4);
                cell.VerticalAlignment = Element.ALIGN_CENTER;//字體水平居左
                ptable.AddCell(cell);


                // document.Add(ptable);
                //document.Add(ptablefoot); 
                newFileName = newPDFName + "_part" + index++ + "." + "pdf";
                pdf.ExportDataTableToPDF(_dtBody, false, newFileName, arrColWidth, ptable, ptablefoot, "", "", 12, uint.Parse(_dtBody.Rows.Count.ToString()));/*第一7是列,第二個是行*/
                pdfList.Add(newFileName);

            }
            //else
            //{
            //    newFileName = newPDFName + "_part" + index++ + "." + "pdf";

            //    pdf.ExportDataTableToPDF(_dtBody, false, newFileName, arrColWidth, ptable, ptablefoot, "", "", 11, uint.Parse(_dtBody.Rows.Count.ToString()));/*第一7是列,第二個是行*/
            //    pdfList.Add(newFileName);

            //}

            newFileName = newPDFName + "." + "pdf";
            pdf.MergePDF(pdfList, newFileName);

            Response.Clear();
            Response.Charset = "gb2312";
            Response.ContentEncoding = System.Text.Encoding.UTF8;
            Response.AddHeader("Content-Disposition", "attach-ment;filename=" + filename + ".pdf");
            Response.WriteFile(newFileName);

        }
        // based on example http://itextsharp.sourceforge.net/examples/Concat.cs
        public string ConcatFilesOld(List <string> files, string targetPath)
        {
            try
            {
                if (files.Count > 0)
                {
                    string file = files[0];
                    iTextSharp.text.pdf.PdfReader reader = new iTextSharp.text.pdf.PdfReader(GetFullPath(file));
                    int n = reader.NumberOfPages;
                    iTextSharp.text.Document      document = new iTextSharp.text.Document(reader.GetPageSizeWithRotation(1));
                    iTextSharp.text.pdf.PdfWriter writer   = iTextSharp.text.pdf.PdfWriter.GetInstance(document, new System.IO.FileStream(targetPath, System.IO.FileMode.Create));

                    reader.Close();
                    document.Open();
                    iTextSharp.text.pdf.PdfContentByte  cb = writer.DirectContent;
                    iTextSharp.text.pdf.PdfImportedPage page;
                    int rotation;
                    foreach (string sourceFile in files)
                    {
                        int i = 0;
                        iTextSharp.text.pdf.PdfReader reader2 = new iTextSharp.text.pdf.PdfReader(GetFullPath(sourceFile));
                        n = reader2.NumberOfPages;
                        while (i < n)
                        {
                            i++;
                            document.SetPageSize(reader2.GetPageSizeWithRotation(i));
                            document.NewPage();
                            page     = writer.GetImportedPage(reader2, i);
                            rotation = reader2.GetPageRotation(i);
                            if (rotation == 90)
                            {
                                cb.AddTemplate(page, 0, -1f, 1f, 0, 0, reader2.GetPageSizeWithRotation(i).Height);
                            }
                            else if ((rotation == 270))
                            {
                                cb.AddTemplate(page, 0f, 1f, -1f, 0f, reader2.GetPageSizeWithRotation(i).Width, 0f);
                            }
                            else
                            {
                                cb.AddTemplate(page, 1f, 0, 0, 1f, 0, 0);
                            }
                        }

                        writer.FreeReader(reader2);
                        reader2.Close();
                    }

                    if (document.IsOpen())
                    {
                        document.CloseDocument();
                        document.Close();
                    }
                    return("");
                }
                else
                {
                    return("No files to process, use AddFile method");
                }
            }
            catch (Exception e)
            {
                return(e.Message);
            }
        }
Пример #32
0
 private void convertPDF()
 {
     DirectoryInfo di = new DirectoryInfo(_imagepath);
     FileInfo[] files = di.GetFiles("*" + ImageType);
     Array.Sort(files, mySort);
     Document document = new Document(iTextSharp.text.PageSize.A4, 0, 0, 0, 0);
     try
     {
         PdfWriter pdfWrite = PdfWriter.GetInstance(document, new FileStream(PDFFilePath, FileMode.Create, FileAccess.ReadWrite));
         document.Open();
         iTextSharp.text.Image image;
         document.AddTitle(_book.Title);
         foreach (FileInfo file in files)
         {
             image = iTextSharp.text.Image.GetInstance(file.FullName);
             document.SetPageSize(new iTextSharp.text.Rectangle(image.Width, image.Height));
             image.Alignment = iTextSharp.text.Image.ALIGN_MIDDLE;
             document.NewPage();
             document.Add(image);
         }
         try
         {
             BookContentNode content = BookContent.GetBookContent(_book.did, _book.PdgPath);
             PdfContentByte pdfcontent = pdfWrite.DirectContent;
             AddBookContents(pdfWrite, pdfcontent.RootOutline, content);
         }
         catch (Exception e)
         {
             if (e is ThreadAbortException)
                 throw e;
         }
         Directory.Delete(_imagepath, true);
     }
     catch (Exception e)
     {
         if (e is ThreadAbortException)
             throw e;
         throw new Exception("转换PDF时出错");
     }
     finally
     {
         if (document != null && document.IsOpen())
             document.Close();
     }
 }
Пример #33
0
        public void ExtractPdf(DataGridView dataGridView, bool selectedParameter)
        {
            Phrase p = new Phrase("\n");

            #region Font seç
            BaseFont             trArial              = BaseFont.CreateFont(@"C:\WINDOWS\Fonts\tahoma.ttf", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
            iTextSharp.text.Font fontArial            = new iTextSharp.text.Font(trArial, 10, iTextSharp.text.Font.NORMAL, iTextSharp.text.BaseColor.DARK_GRAY);
            iTextSharp.text.Font fontArialHeader      = new iTextSharp.text.Font(trArial, 11, iTextSharp.text.Font.BOLD, iTextSharp.text.BaseColor.BLACK);
            iTextSharp.text.Font fontArialbold        = new iTextSharp.text.Font(trArial, 9, iTextSharp.text.Font.BOLD, iTextSharp.text.BaseColor.DARK_GRAY);
            iTextSharp.text.Font fontArialboldgeneral = new iTextSharp.text.Font(trArial, 10, iTextSharp.text.Font.BOLD, iTextSharp.text.BaseColor.BLACK);
            #endregion

            #region Fatura pdf oluştur
            SaveFileDialog save = new SaveFileDialog();
            save.OverwritePrompt = false;
            save.Title           = "PDF Dosyaları";
            save.DefaultExt      = "pdf";
            save.Filter          = "pdf Dosyaları (*.pdf)|*.pdf|Tüm Dosyalar(*.*)|*.*";
            if (save.ShowDialog() == DialogResult.OK)
            {
                iTextSharp.text.Document pdfFile = new iTextSharp.text.Document();
                PdfWriter.GetInstance(pdfFile, new FileStream(save.FileName, FileMode.Create));
                pdfFile.Open();

                #region Fatura oluşturan bilgileri
                pdfFile.AddCreator("Hakedis");                     //Oluşturan kişinin isminin eklenmesi
                pdfFile.AddCreationDate();                         //Oluşturulma tarihinin eklenmesi
                pdfFile.AddAuthor("Hakedis" + applicationVersion); //Yazarın isiminin eklenmesi
                pdfFile.AddHeader(DateTime.Now.ToLongDateString(), "Hakediş " + DateTime.Now.ToLongDateString());
                pdfFile.AddTitle("Hakediş Rapor");                 //Başlık ve title eklenmesi
                #endregion

                #region Tablo Başlık tarih ve marka bilgileri
                PdfPTable markAndDateTable = new PdfPTable(2);
                markAndDateTable.TotalWidth         = 250f;
                markAndDateTable.DefaultCell.Border = iTextSharp.text.Rectangle.NO_BORDER;

                PdfPCell markName = new PdfPCell(new Phrase("Hakediş " + applicationVersion, fontArialbold));
                markName.HorizontalAlignment = Element.ALIGN_LEFT;
                markName.VerticalAlignment   = Element.ALIGN_LEFT;
                markName.Border = 0;

                PdfPCell dateTimeReport = new PdfPCell(new Phrase(DateTime.Now.ToLongDateString(), fontArialbold));
                dateTimeReport.VerticalAlignment   = Element.ALIGN_RIGHT;
                dateTimeReport.HorizontalAlignment = Element.ALIGN_RIGHT;
                dateTimeReport.Border = 0;
                dateTimeReport.ExtraParagraphSpace = 5f;

                markAndDateTable.AddCell(markName);
                markAndDateTable.AddCell(dateTimeReport);
                #endregion

                #region Veri Tablosu İşlemleri

                #region Pdf Kolon Başlıklarını Belirleme
                int       columnCount     = dataGridView.Columns.Count;
                PdfPTable pdfColumnheader = new PdfPTable(columnCount - 2);
                pdfColumnheader.TotalWidth         = 400f;
                pdfColumnheader.LockedWidth        = true;
                pdfColumnheader.DefaultCell.Border = iTextSharp.text.Rectangle.NO_BORDER;
                if (selectedParameter == true)
                {
                    for (int i = 0; i < columnCount; i++)
                    {
                        if (i != 0 && i != 1)
                        {
                            PdfPCell columnName = new PdfPCell(new Phrase(dataGridView.Columns[i].HeaderText, fontArialHeader));
                            columnName.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
                            columnName.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
                            columnName.FixedHeight         = 30f;
                            columnName.Border = 1;
                            pdfColumnheader.AddCell(columnName);
                        }
                    }
                }
                else
                {
                    pdfColumnheader = new PdfPTable(columnCount - 1);
                    for (int i = 0; i < columnCount; i++)
                    {
                        if (i != 0)
                        {
                            PdfPCell columnName = new PdfPCell(new Phrase(dataGridView.Columns[i].HeaderText, fontArialHeader));
                            columnName.HorizontalAlignment = PdfPCell.ALIGN_CENTER;
                            columnName.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
                            columnName.FixedHeight         = 30f;
                            columnName.Border = 1;
                            pdfColumnheader.AddCell(columnName);
                        }
                    }
                }

                #region Satır işlemleri

                int       rowsCount    = dataGridView.Rows.Count;
                PdfPTable pdfDataTable = new PdfPTable(columnCount - 2);
                if (selectedParameter == true)
                {
                    for (int i = 0; i <= rowsCount - 1; i++)
                    {
                        for (int j = 0; j < dataGridView.Rows[i].Cells.Count; j++)
                        {
                            if (j != 0 && j != 2)
                            {
                                PdfPCell cell2 = new PdfPCell(new Phrase(dataGridView.Rows[i].Cells[j].Value.ToString(), fontArial));
                                pdfDataTable.AddCell(cell2);
                            }
                        }
                    }
                }
                else
                {
                    pdfDataTable = new PdfPTable(columnCount - 1);
                    for (int i = 0; i <= rowsCount - 1; i++)
                    {
                        for (int j = 0; j < dataGridView.Rows[i].Cells.Count; j++)
                        {
                            if (j != 0)
                            {
                                PdfPCell cell2 = new PdfPCell(new Phrase(dataGridView.Rows[i].Cells[j].Value.ToString(), fontArial));
                                pdfDataTable.AddCell(cell2);
                            }
                        }
                    }
                }


                #endregion

                #region Toplam Bilgi Verileri
                PdfPTable tableTotalInfo = new PdfPTable(2);
                tableTotalInfo.TotalWidth         = 250f;
                tableTotalInfo.LockedWidth        = true;
                tableTotalInfo.DefaultCell.Border = iTextSharp.text.Rectangle.NO_BORDER;
                double totalManOfDay = 0;
                if (selectedParameter == true)
                {
                    for (int i = 0; i < dataGridView.Rows.Count; i++)
                    {
                        totalManOfDay += double.Parse(dataGridView.Rows[i].Cells[6].Value.ToString());
                    }
                }
                else
                {
                    for (int i = 0; i < dataGridView.Rows.Count; i++)
                    {
                        totalManOfDay += double.Parse(dataGridView.Rows[i].Cells[2].Value.ToString());
                    }
                }

                PdfPCell cellTotalManOfDay = new PdfPCell(new Phrase(totalManOfDay.ToString(), fontArial));
                cellTotalManOfDay.HorizontalAlignment = Element.ALIGN_CENTER;
                cellTotalManOfDay.VerticalAlignment   = Element.ALIGN_LEFT;
                PdfPCell cellTotal = new PdfPCell(new Phrase("Toplam İş Günü", fontArial));
                cellTotal.HorizontalAlignment = Element.ALIGN_CENTER;
                cellTotal.VerticalAlignment   = Element.ALIGN_LEFT;
                tableTotalInfo.AddCell(cellTotal);
                tableTotalInfo.AddCell(cellTotalManOfDay);
                #endregion

                #endregion

                #region Pdf Dosyasını yaz ve kapat
                if (pdfFile.IsOpen() == false)
                {
                    pdfFile.Open();
                }
                pdfFile.Add(markAndDateTable);
                pdfFile.Add(p);
                pdfFile.Add(pdfColumnheader);
                pdfFile.Add(p);
                pdfFile.Add(pdfDataTable);
                pdfFile.Add(p);
                pdfFile.Add(tableTotalInfo);
                //pdfFile.Add(p);
                //pdfFile.Add(p);
                //pdfFile.Add(p);
                //pdfFile.Add(nameSurname);
                //pdfFile.Add(p);
                //pdfFile.Add(signature);
                pdfFile.Close();
                #endregion
                #endregion
            }
            #endregion
        }
Пример #34
0
        /// <summary>
        /// Takes pages from two pdf files, and produces an output file
        /// whose odd pages are the contents of the first, and
        /// even pages are the contents of the second. Useful for
        /// merging front/back output from single sided scanners.
        /// </summary>
        /// <param name="oddPageFile">The file supplying odd numbered pages</param>
        /// <param name="evenPageFile">The file supplying even numbered pages</param>
        /// <param name="outputFile">The output file containing the merged pages</param>
        /// <param name="skipExtraPages">Set to true to skip any extra pages if
        ///                              one file is longer than the other</param>
        public void EvenOddMerge(String oddPageFile, String evenPageFile, 
                                 String outputFile, bool skipExtraPages)
        {
            if (!String.IsNullOrEmpty(oddPageFile) && !String.IsNullOrWhiteSpace(oddPageFile) &&
                !String.IsNullOrEmpty(evenPageFile) && !String.IsNullOrWhiteSpace(evenPageFile) &&
                !String.IsNullOrEmpty(outputFile) && !String.IsNullOrWhiteSpace(outputFile))
            {
                var oddPageDocument = new iTextSharpPDF.PdfReader(oddPageFile);
                var evenPageDocument = new iTextSharpPDF.PdfReader(evenPageFile);
                try
                {
                    iTextSharpText.Document mergedOutputDocument = null;
                    iTextSharpPDF.PdfCopy mergedOutputFile = null;

                    int lastPage = 0;
                    switch (skipExtraPages)
                    {
                        case (false):
                            lastPage = oddPageDocument.NumberOfPages;
                            if (evenPageDocument.NumberOfPages > oddPageDocument.NumberOfPages)
                                lastPage = evenPageDocument.NumberOfPages;
                            else
                                lastPage = oddPageDocument.NumberOfPages;
                            break;
                        case (true):
                            if (evenPageDocument.NumberOfPages < oddPageDocument.NumberOfPages)
                                lastPage = evenPageDocument.NumberOfPages;
                            else
                                lastPage = oddPageDocument.NumberOfPages;
                            break;
                    }

                    try
                    {
                        mergedOutputDocument = new iTextSharpText.Document();
                        mergedOutputFile = new iTextSharpPDF.PdfCopy(mergedOutputDocument, new FileStream(outputFile, FileMode.Create, FileAccess.ReadWrite));
                        mergedOutputDocument.Open();
                        for (int loop = 1; loop <= lastPage; loop++)
                        {
                            // Extract and merge odd page
                            if (loop <= oddPageDocument.NumberOfPages)
                            {
                                mergedOutputDocument.SetPageSize(oddPageDocument.GetPageSizeWithRotation(loop));
                                mergedOutputFile.AddPage(mergedOutputFile.GetImportedPage(oddPageDocument, loop));
                            }
                            // Extract and merge even page
                            if (loop <= evenPageDocument.NumberOfPages)
                            {
                                mergedOutputDocument.SetPageSize(evenPageDocument.GetPageSizeWithRotation(loop));
                                mergedOutputFile.AddPage(mergedOutputFile.GetImportedPage(evenPageDocument, loop));
                            }
                        }
                    }
                    finally
                    {
                        if (mergedOutputDocument != null && mergedOutputDocument.IsOpen()) mergedOutputDocument.Close();
                        if (mergedOutputFile != null)
                        {
                            mergedOutputFile.Close();
                            mergedOutputFile.FreeReader(oddPageDocument);
                            mergedOutputFile.FreeReader(evenPageDocument);
                        }
                    }
                }
                catch
                {
                    try
                    {
                        File.Delete(outputFile);
                    }
                    catch { }
                    throw;
                }
                finally
                {
                    try
                    {
                        if (oddPageDocument != null) oddPageDocument.Close();
                        oddPageDocument = null;
                    }
                    catch { }
                    try
                    {
                        if (evenPageDocument != null) evenPageDocument.Close();
                        evenPageDocument = null;
                    }
                    catch { }
                }
            }
            else
            {
                if (String.IsNullOrEmpty(oddPageFile) || String.IsNullOrWhiteSpace(oddPageFile)) throw new ArgumentNullException("oddPageFile", exceptionArgumentNullOrEmptyString);
                if (String.IsNullOrEmpty(evenPageFile) || String.IsNullOrWhiteSpace(evenPageFile)) throw new ArgumentNullException("evenPageFile", exceptionArgumentNullOrEmptyString);
                if (String.IsNullOrEmpty(outputFile) || String.IsNullOrWhiteSpace(outputFile)) throw new ArgumentNullException("outputFile", exceptionArgumentNullOrEmptyString);
            }
        }
Пример #35
0
        /// <summary>
        /// Utility function to crop a png into page-sized portions and embed each png into the pdf.
        /// </summary>
        /// <param name="png"></param>
        /// <returns></returns>
        public static byte[] ConvertPngToPdf(byte[] png)
        {
            using (MemoryStream pdfStream = new MemoryStream())
            {
                Document pdfDocument = new iTextSharp.text.Document(PageSize.LETTER, 36, 36, 36, 36);

                var writer = PdfWriter.GetInstance(pdfDocument, pdfStream);
                writer.CloseStream = false;

                pdfDocument.Open();

                var maxImageHeight = pdfDocument.PageSize.Height + 36;

                using (var source = new System.Drawing.Bitmap(new MemoryStream(png)))
                {
                    if (source.Height > maxImageHeight)
                    {
                        int heightOffset = 0;

                        while (heightOffset < source.Height)
                        {
                            Rectangle sourceRect = heightOffset + (int)(maxImageHeight) > source.Height
                                                     ? new System.Drawing.Rectangle(0, heightOffset, source.Width, source.Height)
                                                     : new System.Drawing.Rectangle(0, heightOffset, source.Width, (int)(maxImageHeight));

                            using (var target = new System.Drawing.Bitmap(sourceRect.Width, sourceRect.Height))
                            {
                                using (var g = Graphics.FromImage(target))
                                {
                                    g.DrawImage(source, new System.Drawing.Rectangle(0, 0, target.Width, target.Height),
                                                sourceRect,
                                                GraphicsUnit.Pixel);
                                }

                                using (MemoryStream ms = new MemoryStream())
                                {
                                    target.Save(ms, ImageFormat.Png);
                                    pdfDocument.Add(new Paragraph());
                                    Image img = Image.GetInstance(ms.GetBuffer());
                                    img.ScaleToFit(pdfDocument.PageSize.Width - 72, img.Height);
                                    pdfDocument.Add(img);
                                    if (sourceRect.Height >= maxImageHeight)
                                    {
                                        pdfDocument.NewPage();
                                    }
                                }
                            }

                            heightOffset += sourceRect.Height;
                        }
                    }
                    else
                    {
                        pdfDocument.Add(new Paragraph());

                        Image img = Image.GetInstance(png);
                        img.ScaleToFit(pdfDocument.PageSize.Width - 72, img.Height);
                        pdfDocument.Add(img);
                    }
                }

                if (pdfDocument.IsOpen())
                {
                    pdfDocument.Close();
                }

                pdfStream.Flush();
                pdfStream.Seek(0, SeekOrigin.Begin);
                return(pdfStream.GetBuffer());
            }
        }
Пример #36
0
        private void btnSlipPrint_Click(object sender, EventArgs e)
        {
            string sss = DateTime.Now.Millisecond + "Doc1.pdf";
            string filename = AppDomain.CurrentDomain.BaseDirectory + sss;
            Document document = new Document(new iTextSharp.text.Rectangle(155f, 219f), 1f, 1f, 1f, 1f);

            PdfWriter.GetInstance(document, new FileStream(filename, FileMode.Create));

            #region Header

            iTextSharp.text.Table tblHeader = new iTextSharp.text.Table(2, 6);
            tblHeader.Padding = 0;
            tblHeader.BorderWidth = 0;
            tblHeader.Border = 0;
            tblHeader.BorderColor = iTextSharp.text.Color.WHITE;
            tblHeader.Width = 100;
            tblHeader.DefaultCell.Border = iTextSharp.text.Rectangle.NO_BORDER;
            tblHeader.DefaultCell.BorderWidth = 0;
            tblHeader.DefaultCell.BorderColor = iTextSharp.text.Color.WHITE;
            tblHeader.SetWidths(new[] { 45, 100 });
            tblHeader.AddCell(CellCreate("CAFE MOLA", Element.ALIGN_CENTER, Element.ALIGN_CENTER, 2, 1, 10), 0, 0);
            tblHeader.AddCell(CellCreate("Masa No", Element.ALIGN_LEFT, Element.ALIGN_CENTER, 1, 0, 8), 1, 0);
            tblHeader.AddCell(CellCreate(":" + gTable.TableName, Element.ALIGN_LEFT, Element.ALIGN_CENTER), 1, 1);
            tblHeader.AddCell(CellCreate("Açılış", Element.ALIGN_LEFT, Element.ALIGN_CENTER, 1, 0, 8), 2, 0);
            tblHeader.AddCell(
                CellCreate(":" + gTable.RecordDate.ToString("dd.MM.yyyy hh:mm:ss"), Element.ALIGN_LEFT, Element.ALIGN_CENTER),
                2, 1);
            tblHeader.AddCell(CellCreate("Adisyon No", Element.ALIGN_LEFT, Element.ALIGN_CENTER, 1, 0, 8), 3, 0);
            tblHeader.AddCell(CellCreate(":" + gTable.Id.ToString(), Element.ALIGN_LEFT, Element.ALIGN_CENTER), 3, 1);

            #endregion

            #region Content

            iTextSharp.text.Table aTableProduct = new iTextSharp.text.Table(4, vBasket.Count + 1);
            aTableProduct.Padding = 0;
            aTableProduct.BorderWidth = 0;
            aTableProduct.Border = 0;
            aTableProduct.BorderColor = iTextSharp.text.Color.WHITE;
            aTableProduct.Width = 100;
            aTableProduct.SetWidths(new[] { 70, 25, 25, 25 });
            aTableProduct.DefaultCell.Border = iTextSharp.text.Rectangle.NO_BORDER;
            aTableProduct.DefaultCell.BorderWidth = 0;
            aTableProduct.DefaultCell.BorderColor = iTextSharp.text.Color.WHITE;

            aTableProduct.AddCell(CellCreate("Ürün", Element.ALIGN_LEFT, Element.ALIGN_CENTER, 1, 2, 8));
            aTableProduct.AddCell(CellCreate("Mik.", Element.ALIGN_LEFT, Element.ALIGN_CENTER, 1, 2, 8));
            aTableProduct.AddCell(CellCreate("Fiyat", Element.ALIGN_LEFT, Element.ALIGN_CENTER, 1, 2, 8));
            aTableProduct.AddCell(CellCreate("Tutar", Element.ALIGN_LEFT, Element.ALIGN_CENTER, 1, 2, 8));

            foreach (Basket t in vBasket)
            {
                aTableProduct.AddCell(CellCreate(t.Product.ProductName, Element.ALIGN_LEFT, Element.ALIGN_CENTER, 1, 1, 6));
                aTableProduct.AddCell(CellCreate(t.Quantity.ToString(CultureInfo.CurrentCulture), Element.ALIGN_LEFT,
                    Element.ALIGN_CENTER, 1, 1, 6));
                aTableProduct.AddCell(CellCreate(t.Product.SalesPrice.ToString("N2"), Element.ALIGN_LEFT,
                    Element.ALIGN_CENTER, 1, 1, 6));
                aTableProduct.AddCell(CellCreate(t.Total.ToString("N2"), Element.ALIGN_LEFT, Element.ALIGN_CENTER, 1, 1, 6));
            }

            #endregion

            #region Footer

            iTextSharp.text.Table tblFooter = new iTextSharp.text.Table(2, 3);
            tblFooter.Padding = 0;
            tblFooter.BorderWidth = 0;
            tblFooter.Border = 0;
            tblFooter.BorderColor = iTextSharp.text.Color.WHITE;
            tblFooter.Width = 100;
            tblFooter.DefaultCell.Border = iTextSharp.text.Rectangle.NO_BORDER;
            tblFooter.DefaultCell.BorderWidth = 0;
            tblFooter.DefaultCell.BorderColor = iTextSharp.text.Color.WHITE;
            tblFooter.SetWidths(new[] { 100, 45 });
            tblFooter.AddCell(CellCreate("Ara", Element.ALIGN_LEFT, Element.ALIGN_CENTER, 1, 1, 8), 0, 0);
            tblFooter.AddCell(CellCreate(total.ToString("N2"), Element.ALIGN_RIGHT, Element.ALIGN_CENTER, 1, 1, 8), 0,
                1);
            tblFooter.AddCell(CellCreate("Genel Toplam", Element.ALIGN_LEFT, Element.ALIGN_CENTER, 1, 1, 8), 1, 0);
            tblFooter.AddCell(CellCreate(total.ToString("N2"), Element.ALIGN_RIGHT, Element.ALIGN_CENTER, 1, 1, 8), 1,
                1);
            tblFooter.AddCell(CellCreate("Afiyet Olsun", Element.ALIGN_CENTER, Element.ALIGN_CENTER, 2, 1, 12), 2, 0);

            #endregion

            if (document.IsOpen() == false)
            {
                document.Open();
            }

            Paragraph headerPhrase = new Paragraph("") { Alignment = Element.ALIGN_CENTER };
            document.Add(tblHeader);
            document.Add(headerPhrase);
            document.Add(aTableProduct);
            document.Add(headerPhrase);
            document.Add(tblFooter);

            document.Close();
            var vList = MySettings.GetListPrinter();
            //pdDoc.PrinterSettings.PrinterName = vList[0].Value;
            //FileInfo file_into = new FileInfo(filename);
            //string short_name = file_into.Name;

            //// Set the PrintDocument's name for use by the printer queue.
            //pdDoc.DocumentName = short_name;

            //// Read the file's contents.
            //try
            //{
            //    FileContents = File.ReadAllText(filename).Trim();
            //    pdDoc.PrintPage += pdocTextFile_PrintPage;
            //}
            //catch (Exception ex)
            //{
            //    MessageBox.Show("Error reading file " + filename +
            //        ".\n" + ex.Message);
            //    return;
            //}

            //// Print.
            //pdDoc.Print();

            //return;

            myPrinters.SetDefaultPrinter(vList[0].Value);

            //ReportProcessor reportProcessor = new ReportProcessor();
            //reportProcessor.PrintReport(new Report1(), new PrinterSettings());
            ProcessStartInfo info = new ProcessStartInfo();
            info.Verb = "print";
            info.FileName = filename;
            info.CreateNoWindow = true;
            info.WindowStyle = ProcessWindowStyle.Hidden;

            Process p = new Process();
            p.StartInfo = info;
            p.Start();

            p.WaitForInputIdle();
            System.Threading.Thread.Sleep(10000);
            if (false == p.CloseMainWindow())
            {
                p.Kill();
                //File.Delete(filename);
            }
        }
Пример #37
0
        static void Main(string[] args)
        {
            // Path
            var path = "C:\\Workspace\\Personal\\Lourtec-2018-i\\MCSDAppBuilder2018I\\Clase-5\\holaMundo.txt";

            /* Tip sobre los strings de forma nativa/implicita
             * "" al crear string con comillas dobles necesitan caracteres de escape para algunos caracteres especiales para eso se utiliza un backslash \, un doble backslash para incluir uno en el text \\
             * @"" copia strings literales, todos sin caracteres de escape, incluye saltos de linea
             * $"" permite generar concatenacion con anclas dinamicas con {}
             */
            var parentDirectory = Path.GetDirectoryName(path);

            Console.WriteLine(parentDirectory);

            var extension = Path.GetExtension(path);

            Console.WriteLine(extension);

            var root = Path.GetPathRoot(path);

            Console.WriteLine(root);

            var randomName = Path.GetRandomFileName();

            Console.WriteLine(randomName);
            // Directory

            var randomDirectoryName = $"{Path.GetDirectoryName(path)}\\{Path.GetRandomFileName()}";

            if (!Directory.Exists(randomDirectoryName))
            {
                Directory.CreateDirectory(randomDirectoryName);

                Console.WriteLine(Directory.GetParent(randomDirectoryName));
                Directory.SetCreationTime(randomDirectoryName, new DateTime(1999, 12, 15));
                Console.WriteLine(Directory.GetCreationTime(randomDirectoryName));
            }

            // DirectoryInfo
            Console.Write("------------Directory Info------------------");
            DirectoryInfo d = new DirectoryInfo(randomDirectoryName);

            Console.WriteLine($"{d.FullName} {d.CreationTime} {d.Attributes.ToString()}");

            // File
            randomName = randomDirectoryName + "\\" + randomName + ".txt";
            if (!File.Exists(randomName))
            {
                using (var fileStream = File.CreateText(randomName))
                {
                    fileStream.WriteLine("Hola Mundo");
                    fileStream.Flush();
                }

                Console.WriteLine(File.ReadAllText(randomName));
            }
            // FileInfo
            FileInfo f = new FileInfo(randomName);

            Console.WriteLine($"{f.FullName} {f.CreationTime} {f.Attributes}");


            // Creacion de Fantasmas
            List <Fantasma> fantasmas   = new List <Fantasma>();
            var             phantonPath = $"{Path.GetDirectoryName(path)}\\Fantasmas";

            if (!Directory.Exists(phantonPath))
            {
                Directory.CreateDirectory(phantonPath);
            }

            if (Directory.Exists(phantonPath))
            {
                Console.WriteLine("----Binary---");
                SerializacionBinaria(phantonPath, fantasmas);

                Console.WriteLine("----XML---");
                SerializacionXml(phantonPath, fantasmas);


                Console.WriteLine("----JSON---");
                SerializacionJson(phantonPath, fantasmas);
            }

            // PDF ITextSharp
            string pdfPath      = @"C:\Workspace\Personal\Lourtec-2018-i\MCSDAppBuilder2018I\Clase-5\phdThesis.pdf";
            string pdfPathClone = @"C:\Workspace\Personal\Lourtec-2018-i\MCSDAppBuilder2018I\Clase-5\Clone.pdf";


            iTextSharp.text.Document document = null;
            try
            {
                document = new iTextSharp.text.Document();
                PdfWriter write  = PdfWriter.GetInstance(document, new FileStream(pdfPathClone, FileMode.Create));
                Anchor    anchor = new Anchor("Hola Mundo");
                iTextSharp.text.Paragraph paragraph = new iTextSharp.text.Paragraph();
                paragraph.Add(anchor);
                document.Open();
                document.OpenDocument();

                document.Add(new Chunk("Hola Mundo Chunk"));
                document.Add(paragraph);
                if (document.IsOpen())
                {
                    document.NewPage();
                }
                document.Close();
                write.Close();
            }
            catch (Exception ex)
            {
            }
        }
Пример #38
0
        /// <summary>
        /// Concatenates multiple PDF files together.
        /// </summary>
        /// <param name="outputPDFTitle">The name of the temp file to write</param>
        /// <param name="args">list of files (paths) to concatentate</param>
        public bool ConcatPDFs(string outputPDFTitle, String[] args)
        {
            Document document = new Document();
            try
            {
                int f = 0;
                // we create a reader for a certain document
                PdfReader reader = new PdfReader(args[f]);
                // we retrieve the total number of pages
                int n = reader.NumberOfPages;

                // step 1: creation of a document-object
                document = new Document(reader.GetPageSizeWithRotation(1));

                // step 2: we create a writer that listens to the document
                PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(outputPDFTitle, FileMode.Create));

                // step 3: we open the document
                document.Open();

                PdfContentByte cb = writer.DirectContent;
                PdfImportedPage page;
                int rotation;

                // step 4: we add content
                while (f < args.Length)
                {
                    int i = 0;
                    while (i < n)
                    {
                        i++;
                        document.SetPageSize(reader.GetPageSizeWithRotation(i));
                        document.NewPage();
                        page = writer.GetImportedPage(reader, i);
                        rotation = reader.GetPageRotation(i);
                        if (rotation == 90 || rotation == 270)
                        {
                            cb.AddTemplate(page, 0, -1f, 1f, 0, 0, reader.GetPageSizeWithRotation(i).Height);
                        }
                        else
                        {
                            cb.AddTemplate(page, 1f, 0, 0, 1f, 0, 0);
                        }
                    }
                    f++;
                    if (f < args.Length)
                    {
                        reader = new PdfReader(args[f]);
                        // we retrieve the total number of pages
                        n = reader.NumberOfPages;
                    }
                }

                // step 5: we close the document
                document.Close();

                return true;
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                if (document.IsOpen())
                {
                    document.Close();
                }
                return false;
            }
        }
Пример #39
0
        public ActionResult EnviarPDF(int? licID)
        {
            string pdfpath = "";
            string _nomearquivo = "";
            try
            {
                var docs = db.LICITACAODOCS.Where(d => d.DOC_LIC_ID == licID).ToList();
                string _arquivo = "";
                string path = HttpContext.Server.MapPath("~/DOCS/");
                var lic = new Licitacao(licID);
                string _numproc = lic.TLicitacao.NUMPROC.ToString(); //db.LICITACAO.FirstOrDefault(l => l.ID == licID).NUMPROC.ToString();
                string _diamesano = new DAO.Documento().DiaMesAnoAtual();
                pdfpath = HttpContext.Server.MapPath("~/PDF/") + SoNumeros(_numproc) +"_"+ _diamesano + ".pdf";
                _nomearquivo = SoNumeros(_numproc) + "_" + _diamesano + ".pdf";
                //string pdfpath = HttpContext.Server.MapPath("~/PDF/") + procID.ToString() + ".pdf";

                if (System.IO.File.Exists(pdfpath))
                {
                    System.IO.File.Delete(pdfpath);
                }

                using (var doc = new iTextSharp.text.Document())
                {
                    if (doc.IsOpen()) doc.Close();
                    iTextSharp.text.pdf.PdfWriter.GetInstance(doc, new FileStream(pdfpath, FileMode.Create));
                    doc.Open();

                    //DADOS CAPA
                    doc.Add(new Paginacao().ParagrafoNegrito("ESTADO DO CEARÁ \n\n", 24f));
                    doc.Add(new Paginacao().ParagrafoNegrito(new Entidade().NomeEntidade() + "\n\n\n", 24f));
                    doc.Add(new Paginacao().ParagrafoNegrito("PROCESSO DE LICITATÓRIO \n\n", 24f));

                    doc.Add(new Paginacao().ParagrafoNegrito("Exercício:" + new Funcoes().MMAAAA(lic.TLicitacao.DTREFDOC.ToString()) + " \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", 24f));

                    Single _tamfont = 10f;
                    var fun = new Funcoes();

                    doc.Add(new Paginacao().Paragrafo("Modalidade: " + fun.NaoNull(lic.TLicitacao.MOLMODALIDADE.ToString()) + "", _tamfont, 1));
                    doc.Add(new Paginacao().Paragrafo("Data Realização: " + fun.NaoNull(lic.TLicitacao.DTREAL.ToString()) + "", _tamfont, 1));

                    doc.Add(new Paginacao().Paragrafo("Participantes: " + fun.NaoNull(lic.Participantes) + "", _tamfont, 1));

                    doc.Add(new Paginacao().Paragrafo("Descrição do Objeto: " + fun.NaoNull(lic.TLicitacao.DESCOBJ.ToString()) + "", _tamfont, 1));

                    doc.Add(new Paginacao().Paragrafo("\n\n\n\n\n\n\n\n", _tamfont, 1));
                    doc.Add(new Paginacao().Paragrafo("Ged SESCONTI", _tamfont, 0));
                    doc.Add(new Paginacao().Paragrafo("Emissão em " + Funcoes.DataAtual(), _tamfont, 0));

                    doc.NewPage();

                    foreach (var itm in docs)
                    {
                        _arquivo = path + itm.DOC_ARQUIVO;
                        iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(_arquivo);

                        image.ScaleToFit(doc.PageSize.Width - 120, doc.PageSize.Height - 80);
                        image.ScaleAbsoluteHeight(doc.PageSize.Height - 80);
                        image.ScaleAbsoluteWidth(doc.PageSize.Width - 80);

                        doc.Add(image);
                    }

                }

                TempData["MsgFixa"] = "Documentos gravados em "+ pdfpath +" com sucesso.";
            }
            catch (Exception ex)
            {
                TempData["MsgErro"] = "Occoreu um erro: " + ex.Message;
            }

            return RedirectToAction("Edit", new { id = licID, arqpdf=_nomearquivo });
        }
Пример #40
0
        public ActionResult EnviarPDF(int? procID)
        {
            try
            {
                var docs = db.DOCUMENTOS.Where(d => d.DOC_PROC_ID == procID).ToList();
                string _arquivo = "";
                string path = HttpContext.Server.MapPath("~/DOCS/");
                //TODO: 17/03/2016
                var proc = new Processo().GetProcesso(procID);
                string _nrodoccaixa = proc.PRC_DOCCAIXA.ToString();
                string _diamesano = new DAO.Documento().DiaMesAnoAtual();
                string pdfpath = HttpContext.Server.MapPath("~/PDF/") + _nrodoccaixa + _diamesano + ".pdf";
                string nomearquivo = _nrodoccaixa + _diamesano + ".pdf";
                //string pdfpath = HttpContext.Server.MapPath("~/PDF/") + procID.ToString() + ".pdf";

                if (System.IO.File.Exists(pdfpath))
                {
                    System.IO.File.Delete(pdfpath);
                }

                using (var doc = new iTextSharp.text.Document())
                {
                    if (doc.IsOpen()) doc.Close();
                    iTextSharp.text.pdf.PdfWriter.GetInstance(doc, new FileStream(pdfpath, FileMode.Create));
                    doc.Open();

                    //DADOS CAPA
                    doc.Add(new Paginacao().ParagrafoNegrito("ESTADO DO CEARÁ \n\n", 24f));
                    doc.Add(new Paginacao().ParagrafoNegrito(new Entidade().NomeEntidade()+"\n\n\n", 24f));
                    doc.Add(new Paginacao().ParagrafoNegrito("PROCESSO DE PAGAMENTO \n\n", 24f));

                    doc.Add(new Paginacao().ParagrafoNegrito("Exercício:" + proc.PRC_DTREFDOC.Substring(2, 4) + " \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", 24f));

                    Single _tamfont = 10f;
                    var fun = new Funcoes();

                    doc.Add(new Paginacao().Paragrafo("Credor: " + fun.NaoNull(proc.PRC_CREDOR.ToString()) + "", _tamfont, 1));
                    doc.Add(new Paginacao().Paragrafo("Documento Caixa: " + fun.NaoNull(proc.PRC_DOCCAIXA.ToString()) + "", _tamfont, 1));
                    doc.Add(new Paginacao().Paragrafo("Empenho: " + fun.NaoNull(proc.PRC_NOTAEMP.ToString()) + "", _tamfont, 1));
                    doc.Add(new Paginacao().Paragrafo("Valor: " + fun.NaoNull(proc.PRC_VRPAGAM.ToString()) + "", _tamfont, 1));
                    doc.Add(new Paginacao().Paragrafo("Código Orgão: " + fun.NaoNull(proc.PRC_ORGAO.ToString()) + "", _tamfont, 1));
                    doc.Add(new Paginacao().Paragrafo("Código Unidade Orç: " + fun.NaoNull(proc.PRC_UND_ORC.ToString()) + "", _tamfont, 1));

                    if(proc.PRC_UND_GEST!=null)
                        doc.Add(new Paginacao().Paragrafo("Unidade Gestora: " + new UnidadeGestora(proc.PRC_UND_GEST).NomeUnidGestora + "", _tamfont, 1));
                    else
                        doc.Add(new Paginacao().Paragrafo("Unidade Gestora: Não Informada", _tamfont, 1));

                    doc.Add(new Paginacao().Paragrafo("\n\n\n\n\n\n\n\n", _tamfont, 1));
                    doc.Add(new Paginacao().Paragrafo("Ged SESCONTI", _tamfont, 0));
                    doc.Add(new Paginacao().Paragrafo("Emissão em "+Funcoes.DataAtual(), _tamfont, 0));

                    doc.NewPage();

                    foreach (var itm in docs)
                    {
                        _arquivo = path + itm.DOC_ARQUIVO;
                        iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(_arquivo);

                        image.ScaleToFit(doc.PageSize.Width - 120, doc.PageSize.Height - 80);
                        image.ScaleAbsoluteHeight(doc.PageSize.Height - 80);
                        image.ScaleAbsoluteWidth(doc.PageSize.Width - 80);

                        doc.Add(image);
                    }
                }
                ViewBag.PDFEnviado = nomearquivo;
                TempData["MsgFixa"] = "Documentos gravados em PDF com sucesso.";
            }
            catch (Exception ex)
            {
                TempData["MsgErro"] = "Occoreu um erro: " + ex.Message;
            }

            PROCESSOS pROCESSOS = db.PROCESSOS.Find(procID);
            return View("Edit", pROCESSOS);
        }
Пример #41
0
        public void KTPrintPDF()
        {
            PdfHelper pdf = new PdfHelper();
            List<string> pdfList = new List<string>();
            float[] arrColWidth = new float[] { 60, 60, 100, 60, 50, 30, 60, 60, 60, 60 };
            int index = 0;
            string newFileName = string.Empty;
            string newName = string.Empty;
            string json = string.Empty;
            IialgQuery q = new IialgQuery();
            if (!string.IsNullOrEmpty(Request.Params["KT_NO"].Trim().ToUpper()))//by zhaozhi0623j add 20151006
            {
                q.doc_no = Request.Params["KT_NO"].Trim().ToUpper();
            }
            try
            {
                List<IialgQuery> store = new List<IialgQuery>();
                _iagMgr = new IialgMgr(mySqlConnectionString);
                int totalCount = 0;
                q.IsPage = false;
                store = _iagMgr.GetIialgList(q, out totalCount);
                int rid = 0;
                DataTable _dtBody = new DataTable();

                if (store.Count > 0)
                {
                    _dtBody.Columns.Add("商品細項編號", typeof(string));
                    _dtBody.Columns.Add("主料位", typeof(string));
                    _dtBody.Columns.Add("商品名稱", typeof(string));
                    _dtBody.Columns.Add("規格", typeof(string));
                    _dtBody.Columns.Add("調整原因", typeof(string));
                    _dtBody.Columns.Add("數量", typeof(string));
                    _dtBody.Columns.Add("调整料位", typeof(string));
                    _dtBody.Columns.Add("有效日期", typeof(string));
                    _dtBody.Columns.Add("前置單號", typeof(string));
                    _dtBody.Columns.Add("備註", typeof(string));
                    for (int i = 0; i < store.Count; i++)
                    {
                        store[i].id = rid++;
                        store[i].qty = store[i].qty_o + store[i].adj_qty;
                        DataRow newRow = _dtBody.NewRow();
                        newRow["商品細項編號"] = store[i].item_id;
                        newRow["主料位"] = store[i].loc_id;
                        newRow["商品名稱"] = store[i].product_name;
                        newRow["規格"] = string.IsNullOrEmpty(store[i].prod_sz) ? " " : store[i].prod_sz;
                        newRow["調整原因"] = string.IsNullOrEmpty(store[i].iarc_id) ? " " : store[i].iarc_id;
                        newRow["數量"] = store[i].adj_qty;
                        newRow["调整料位"] = store[i].loc_R;
                        newRow["有效日期"] = store[i].cde_dt.ToString("yyyy-MM-dd").Substring(0, 10) == "0001-01-01" ? " " : store[i].cde_dt.ToString("yyyy-MM-dd").Substring(0, 10);
                        newRow["前置單號"] = string.IsNullOrEmpty(store[i].po_id) ? " " : store[i].po_id;
                        newRow["備註"] = string.IsNullOrEmpty(store[i].remarks) ? " " : store[i].remarks;

                        _dtBody.Rows.Add(newRow);
                    }
                }
                string UsingName = " ";
                String UsingTime = " ";
                if (store.Count > 0)
                {
                    UsingName = store[0].name;
                    UsingTime = store[0].create_dtim.ToString("yyyy/MM/dd");
                }
                BaseFont bf = BaseFont.CreateFont("C:\\WINDOWS\\Fonts\\simsun.ttc,1", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
                iTextSharp.text.Font fontChinese = new iTextSharp.text.Font(bf, 8, iTextSharp.text.Font.UNDERLINE, iTextSharp.text.BaseColor.RED);
                iTextSharp.text.Font font = new iTextSharp.text.Font(bf, 12, iTextSharp.text.Font.BOLD, new iTextSharp.text.BaseColor(0, 0, 0));//黑  
                string filename = "庫存調整" + DateTime.Now.ToString("yyyyMMddHHmmss");
                Document document = new Document(PageSize.A4.Rotate());
                string newPDFName = Server.MapPath(excelPath) + filename;
                PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(newPDFName, FileMode.Create));
                document.Open();

                #region 庫存調整單頭

                PdfPTable ptable = new PdfPTable(10);


                ptable.WidthPercentage = 100;//表格寬度
                ptable.SetTotalWidth(arrColWidth);
                PdfPCell cell = new PdfPCell();

                cell = new PdfPCell(new Phrase("執行人員:" + UsingName, new iTextSharp.text.Font(bf, 10)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.Colspan = 2;
                cell.DisableBorderSide(1);
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 10)));
                cell.VerticalAlignment = Element.ALIGN_RIGHT;//字體水平居右
                cell.Colspan = 8;
                cell.DisableBorderSide(1);
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("執行日期:" + UsingTime, new iTextSharp.text.Font(bf, 10)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.Colspan = 2;
                cell.DisableBorderSide(1);
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 10)));
                cell.VerticalAlignment = Element.ALIGN_RIGHT;//字體水平居右
                cell.Colspan = 8;
                cell.DisableBorderSide(1);
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(bf, 4)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.Colspan = 10;
                //cell.DisableBorderSide(1);
                cell.DisableBorderSide(2);
                //cell.DisableBorderSide(4);
                //cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 15)));
                cell.VerticalAlignment = Element.ALIGN_CENTER;//字體水平居左
                cell.Colspan = 3;
                cell.DisableBorderSide(1);
                cell.DisableBorderSide(2);
                //cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase("  庫存調整單", new iTextSharp.text.Font(bf, 15)));
                cell.VerticalAlignment = Element.ALIGN_CENTER;//字體水平居左
                cell.Colspan = 7;
                cell.DisableBorderSide(1);
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(4);
                // cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 10)));
                cell.VerticalAlignment = Element.ALIGN_CENTER;//字體水平居左
                cell.Colspan = 3;
                cell.DisableBorderSide(1);
                cell.DisableBorderSide(2);
                // cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase("單號" + ":" + q.doc_no, new iTextSharp.text.Font(bf, 10)));// ipoStore[a].po_type_desc
                cell.VerticalAlignment = Element.ALIGN_CENTER;//字體水平居左
                cell.Colspan = 7;
                cell.DisableBorderSide(1);
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(4);
                // cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(bf, 4)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.Colspan = 10;
                cell.DisableBorderSide(1);
                //cell.DisableBorderSide(2);
                // cell.DisableBorderSide(4);
                //cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("商品細項編號", new iTextSharp.text.Font(bf, 10)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左

                //cell.DisableBorderSide(1);
                // cell.DisableBorderSide(2);
                //cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase("主料位", new iTextSharp.text.Font(bf, 10)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左

                //cell.DisableBorderSide(1);
                // cell.DisableBorderSide(2);
                //cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase("商品名稱", new iTextSharp.text.Font(bf, 10)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左

                //cell.DisableBorderSide(1);
                // cell.DisableBorderSide(2);
                //cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase("規格", new iTextSharp.text.Font(bf, 10)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左

                //cell.DisableBorderSide(1);
                // cell.DisableBorderSide(2);
                //cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase("調整原因", new iTextSharp.text.Font(bf, 10)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左

                //cell.DisableBorderSide(1);
                // cell.DisableBorderSide(2);
                //cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase("數量", new iTextSharp.text.Font(bf, 10)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左

                //cell.DisableBorderSide(1);
                //cell.DisableBorderSide(2);
                //cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase("调整料位", new iTextSharp.text.Font(bf, 10)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左

                //cell.DisableBorderSide(1);
                // cell.DisableBorderSide(2);
                //cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("有效日期", new iTextSharp.text.Font(bf, 10)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左

                //cell.DisableBorderSide(1);
                // cell.DisableBorderSide(2);
                //cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase("前置單號", new iTextSharp.text.Font(bf, 10)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左

                //cell.DisableBorderSide(1);
                // cell.DisableBorderSide(2);
                //cell.DisableBorderSide(4);
                //cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase("備註", new iTextSharp.text.Font(bf, 10)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左

                //cell.DisableBorderSide(1);
                // cell.DisableBorderSide(2);
                //cell.DisableBorderSide(4);
                //cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                //cell.UseAscender = true;
                //cell.HorizontalAlignment = Element.ALIGN_CENTER;//字體垂直居中
                //cell.VerticalAlignment = Element.ALIGN_MIDDLE;//字體水平居中
                //cell.BorderWidth = 0.1f;
                //cell.BorderColor = new BaseColor(0, 0, 0);

                #endregion

                #region 庫存調整單尾

                PdfPTable ptablefoot = new PdfPTable(10);


                ptablefoot.WidthPercentage = 100;//表格寬度
                ptablefoot.SetTotalWidth(arrColWidth);
                PdfPCell footcell = new PdfPCell();
                footcell.UseAscender = true;
                footcell.HorizontalAlignment = Element.ALIGN_CENTER;//字體垂直居中
                footcell.VerticalAlignment = Element.ALIGN_MIDDLE;//字體水平居中
                footcell.BorderWidth = 0.1f;
                footcell.BorderColor = new BaseColor(0, 0, 0);
                footcell = new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(bf, 15)));
                footcell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                //footcell.HorizontalAlignment = Element.ALIGN_LEFT;//水平居右
                footcell.Colspan = 10;
                footcell.DisableBorderSide(1);
                footcell.DisableBorderSide(2);
                footcell.DisableBorderSide(4);
                footcell.DisableBorderSide(8);
                ptablefoot.AddCell(footcell);


                footcell = new PdfPCell(new Phrase("印表日期:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), new iTextSharp.text.Font(bf, 10)));
                footcell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居右
                // footcell.HorizontalAlignment = Element.ALIGN_LEFT;//水平居右
                footcell.Colspan = 2;
                footcell.DisableBorderSide(1);
                footcell.DisableBorderSide(2);
                footcell.DisableBorderSide(4);
                footcell.DisableBorderSide(8);
                ptablefoot.AddCell(footcell);
                footcell = new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(bf, 10)));
                footcell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居右
                // footcell.HorizontalAlignment = Element.ALIGN_LEFT;//水平居右
                footcell.Colspan = 1;
                footcell.DisableBorderSide(1);
                footcell.DisableBorderSide(2);
                footcell.DisableBorderSide(4);
                footcell.DisableBorderSide(8);
                ptablefoot.AddCell(footcell);

                footcell = new PdfPCell(new Phrase("印表人:" + (System.Web.HttpContext.Current.Session["caller"] as Caller).user_username, new iTextSharp.text.Font(bf, 10)));
                footcell.VerticalAlignment = Element.ALIGN_RIGHT;//水平居右
                footcell.Colspan = 2;
                footcell.DisableBorderSide(1);
                footcell.DisableBorderSide(2);
                footcell.DisableBorderSide(4);
                footcell.DisableBorderSide(8);
                ptablefoot.AddCell(footcell);
                footcell = new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(bf, 10)));
                footcell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居右
                // footcell.HorizontalAlignment = Element.ALIGN_LEFT;//水平居右
                footcell.Colspan = 3;
                footcell.DisableBorderSide(1);
                footcell.DisableBorderSide(2);
                footcell.DisableBorderSide(4);
                footcell.DisableBorderSide(8);
                ptablefoot.AddCell(footcell);

                footcell = new PdfPCell(new Phrase("主管簽核:__________________", new iTextSharp.text.Font(bf, 10)));
                footcell.VerticalAlignment = Element.ALIGN_RIGHT;//字體水平居右
                footcell.Colspan = 2;
                footcell.DisableBorderSide(1);
                footcell.DisableBorderSide(2);
                footcell.DisableBorderSide(4);
                footcell.DisableBorderSide(8);
                ptablefoot.AddCell(footcell);


                #endregion
                if (store.Count == 0)
                {
                    document = new Document(PageSize.A4.Rotate());
                    if (!document.IsOpen())
                    {
                        document.Open();
                    }
                    cell = new PdfPCell(new Phrase(" ", font));
                    cell.Colspan = 4;
                    cell.VerticalAlignment = Element.ALIGN_CENTER;//字體水平居左
                    cell.DisableBorderSide(8);
                    ptable.AddCell(cell);

                    cell = new PdfPCell(new Phrase("此庫調單庫調數據不存在!", font));
                    cell.Colspan = 7;
                    cell.DisableBorderSide(4);
                    cell.VerticalAlignment = Element.ALIGN_CENTER;//字體水平居左
                    ptable.AddCell(cell);


                    // document.Add(ptable);
                    //document.Add(ptablefoot); 
                    newFileName = newPDFName + "_part" + index++ + "." + "pdf";
                    pdf.ExportDataTableToPDF(_dtBody, false, newFileName, arrColWidth, ptable, ptablefoot, "", "", 10, uint.Parse(store.Count.ToString()));/*第一7是列,第二個是行*/
                    pdfList.Add(newFileName);

                }
                else
                {
                    newFileName = newPDFName + "_part" + index++ + "." + "pdf";

                    pdf.ExportDataTableToPDF(_dtBody, false, newFileName, arrColWidth, ptable, ptablefoot, "", "", 10, uint.Parse(store.Count.ToString()));/*第一7是列,第二個是行*/
                    pdfList.Add(newFileName);

                }


                //newFileName = newPDFName + "_part" + index++ + "." + "pdf";
                //pdf.ExportDataTableToPDF(newFileName, ptable, "", "");
                //pdfList.Add(newFileName);

                //document.Add(ptable);
                //document.NewPage();
                newFileName = newPDFName + "." + "pdf";
                pdf.MergePDF(pdfList, newFileName);

                Response.Clear();
                Response.Charset = "gb2312";
                Response.ContentEncoding = System.Text.Encoding.UTF8;
                Response.AddHeader("Content-Disposition", "attach-ment;filename=" + filename + ".pdf");
                Response.WriteFile(newFileName);

            }
            catch (Exception)
            {

                throw;
            }

        }
        //create a new pdf document
        private void btn_Prepare_Click(object sender, EventArgs e)
        {
            //if all of these null
            if ((textboxAuthor.Text == "" || textboxCreator.Text == "" || textboxSubject.Text == "" || textboxKeyword.Text == "" || rtextboxParagraph.Text == "") || checkTextboxValues())
            {
                MessageBox.Show("PLEASE FILL IN THE TEXTBOXES", "Message Box", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
            }
            else
            {
                //the library for create a new pdf document
                iTextSharp.text.Document report = new iTextSharp.text.Document();
                //file path of newly created pdf file to save
                PdfWriter.GetInstance(report, new FileStream(@"C:\Users\Asus\Desktop\UPLOADFILES\" + textboxFileName.Text, FileMode.Create));
                //Author name, need for create a new pdf document
                report.AddAuthor(textboxAuthor.Text);
                //Creation Date, need for create a new pdf document
                report.AddCreationDate();
                //Creator, need for create a new pdf document
                report.AddCreator(textboxCreator.Text);
                //Subject, need for create a new pdf document
                report.AddSubject(textboxSubject.Text);
                //Keywords, need for create a new pdf document
                report.AddKeywords(textboxKeyword.Text);

                if (report.IsOpen() == false)
                {
                    //open report for create a new pdf document
                    report.Open();
                }
                //Paragraph, need for create a new pdf document
                report.Add(new Paragraph(rtextboxParagraph.Text));
                //open the connection
                db.openConnection();
                //a command line for add a new document
                SqlCommand query = new SqlCommand("INSERT INTO Table_DOCUMENT(file_Name,file_Path,file_CreationDate,u_ID) VALUES(@fn, @fp, @cd,@uid)", db.getConnection());
                //add the value in the textbox to @fn
                query.Parameters.AddWithValue("@fn", textboxFileName.Text);
                //add the value in the textbox to @fp
                query.Parameters.AddWithValue("@fp", textboxFilePath.Text + @"\" + textboxFileName.Text);
                //add the value in the combobox to @uid
                query.Parameters.AddWithValue("@uid", comboboxUserID.Text);
                //add the value in the textbox to @cd
                query.Parameters.AddWithValue("@cd", textboxFileDate.Text);

                if (textboxFileDate.Text == "" || textboxFileName.Text == "" || comboboxUserID.Text == "")
                {
                    MessageBox.Show("PLEASE ENTER THE NAME OF THE FILE: FILE NAME, CREATION DATE, OR USER ID", "Message Box", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                }
                else if (checkFileName())
                {
                    MessageBox.Show("This File Name Already Exist, Select A Different One", "Message Box", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                    textboxFileName.Text = "";
                }
                else
                {
                    //execute the query
                    if (query.ExecuteNonQuery() == 1)
                    {
                        //the record is successfully
                        MessageBox.Show("DATA WERE RECORDED", "Message Box", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation);

                        //return the default values and colors
                        dateTimePicker1.ResetText();
                        textboxFileID.Text        = "file ID";
                        textboxFileID.ForeColor   = Color.DimGray;
                        textboxFileName.Text      = "filename.pdf";
                        textboxFileName.ForeColor = Color.DimGray;
                        comboboxUserID.Text       = "user id";
                        comboboxUserID.ForeColor  = Color.DimGray;
                        textboxFilePath.Text      = "file path";
                        textboxFilePath.ForeColor = Color.DimGray;
                        dateTimePicker1.ResetText();
                        textboxFileDate.Text      = "DD.MM.YYYY";
                        textboxFileDate.ForeColor = Color.DimGray;
                        textboxSubject.Text       = "";
                        rtextboxParagraph.Text    = "";
                        dateTimePicker1.Text      = "";
                        textboxAuthor.Text        = "";
                        textboxCreator.Text       = "";
                        textboxKeyword.Text       = "";
                    }
                    else
                    {
                        MessageBox.Show("ERROR", "Message Box", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                    }
                }
                //close the report
                report.Close();
                //close the connection
                db.closeConnection();
            }
        }
    /// <summary>
    /// 创建转账明细表
    /// </summary>
    /// <param name="document"></param>
    /// <param name="client"></param>
    /// <param name="documentDate"></param>
    /// <param name="year"></param>
    /// <param name="month"></param>
    /// <returns></returns>
    private Document TransferDetailPDF(Document document, CM_Client client, string documentDate, DateTime dateBegin, DateTime dateEnd)
    {
        if (!document.IsOpen())
        {
            return null;
        }
        document = this.GetDocumentHeader(document, "转账明细表", documentDate, client);
        document.Add(Chunk.NEWLINE);

        string procName = "JD.AIS_YSL.dbo.STKD_DDFYREPORT02_CXCAI";//代垫费用余额(让利明细表)存储过程名
        DataTable dt = new DataTable();
        while (DateTime.Compare(dateBegin, dateEnd) <= 0)
        {
            //文档期间项
            int year = dateBegin.Year;
            int month = dateBegin.Month;
            DataTable dtTemp = new CM_ClientBLL().GetStatement(procName, year, month, client.Code);
            dt.Merge(dtTemp);

            dateBegin = dateBegin.AddMonths(1);
        }
        dt.Columns.RemoveAt(1);//去除“期间”列
        //dt.Columns[1].SetOrdinal(0);

        List<string> tableHeaders = new List<string>(5);
        //tableHeaders.Add("期间");
        tableHeaders.Add("日期");
        tableHeaders.Add("摘要");
        tableHeaders.Add("转账金额");
        tableHeaders.Add("市场费用投入");
        tableHeaders.Add("期末余额");
        for (int i = 0; i < dt.Columns.Count; i++)
        {
            dt.Columns[i].ColumnName = tableHeaders[i];
        }

        PdfPTable ptable = TableToPDFTable(dt);
        //ptable.TotalWidth = 520f;
        //ptable.LockedWidth = true;
        float[] widths = new float[] { 1f, 2f, 1f, 1f, 1f };
        ptable.SetWidths(widths);

        document.Add(ptable);

        document = this.GetDocumentNotice(document);
        document.Add(Chunk.NEWLINE);
        this.GetDocumentSign(document);

        return document;
    }
Пример #44
0
        /// <summary>
        /// Extracts a range of pages from a PDF file,
        /// and writes them to a new file.
        /// </summary>
        /// <param name="inputFile">The PDF to extract pages from.</param>
        /// <param name="outputFile">The new file to write the extracted pages to.</param>
        /// <param name="firstPage">The first page to extract.</param>
        /// <param name="lastPage">The last page to extract.</param>
        /// <exception cref="ArgumentNullException"></exception>
        /// <exception cref="ArgumentOutOfRangeException"></exception>
        /// <remarks><see cref="FileStream"/> constructor exceptions may also be thrown.</remarks>
        public void ExtractPDFPages(String inputFile, String outputFile, int firstPage, int lastPage)
        {
            if (!String.IsNullOrEmpty(inputFile) && !String.IsNullOrWhiteSpace(inputFile) &&
                !String.IsNullOrEmpty(outputFile) && !String.IsNullOrWhiteSpace(outputFile) &&
                firstPage > 0 && lastPage > 0 &&
                lastPage >= firstPage)
            {
                var inputDocument = new iTextSharpPDF.PdfReader(inputFile);
                try
                {
                    // Page numbers specified must not be greater
                    // than the number of pages in the document
                    if (firstPage <= inputDocument.NumberOfPages &&
                        lastPage <= inputDocument.NumberOfPages)
                    {
                        iTextSharpText.Document extractOutputDocument = null;
                        iTextSharpPDF.PdfCopy extractOutputFile = null;
                        try
                        {
                            extractOutputDocument = new iTextSharpText.Document();
                            extractOutputFile = new iTextSharpPDF.PdfCopy(extractOutputDocument, new FileStream(outputFile, FileMode.Create, FileAccess.ReadWrite));
                            extractOutputDocument.Open();
                            for (int loop = firstPage; loop <= lastPage; loop++)
                            {
                                extractOutputDocument.SetPageSize(inputDocument.GetPageSizeWithRotation(loop));
                                extractOutputFile.AddPage(extractOutputFile.GetImportedPage(inputDocument, loop));
                            }
                        }
                        finally
                        {
                            if (extractOutputDocument != null && extractOutputDocument.IsOpen()) extractOutputDocument.Close();
                            if (extractOutputFile != null)
                            {
                                extractOutputFile.Close();
                                extractOutputFile.FreeReader(inputDocument);
                            }
                        }
                    }
                    else
                    {
                        if (firstPage > inputDocument.NumberOfPages) throw new ArgumentOutOfRangeException("firstPage", String.Format(exceptionParameterCannotBeGreaterThan,"firstPage", "the number of pages in the document."));
                        throw new ArgumentOutOfRangeException("lastPage", String.Format(exceptionParameterCannotBeGreaterThan,"firstPage", "the number of pages in the document."));
                    }

                }
                catch
                {
                    try
                    {
                        File.Delete(outputFile);
                    }
                    catch { }
                    throw;

                }
                finally
                {
                    if (inputDocument != null) inputDocument.Close();
                    inputDocument = null;
                }
            }
            else
            {
                if (String.IsNullOrEmpty(inputFile) || String.IsNullOrWhiteSpace(inputFile)) throw new ArgumentNullException("inputFile", exceptionArgumentNullOrEmptyString);
                if (String.IsNullOrEmpty(outputFile) || String.IsNullOrWhiteSpace(outputFile)) throw new ArgumentNullException("outputFile", exceptionArgumentNullOrEmptyString);
                if (firstPage < 1) throw new ArgumentOutOfRangeException("firstPage", exceptionArgumentZeroOrNegative);
                if (lastPage < 1) throw new ArgumentOutOfRangeException("lastPage", exceptionArgumentZeroOrNegative);
                if (lastPage < firstPage) throw new ArgumentOutOfRangeException("lastPage", String.Format(exceptionParameterCannotBeLessThan, "lastPage", "firstPage"));
            }
        }
Пример #45
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="inputFile">The PDF file to split</param>
 /// <param name="splitStartPages"></param>
 public void SplitPDF(String inputFile, SortedList <int, String> splitStartPages)
 {
     if (!String.IsNullOrEmpty(inputFile) &&
         !String.IsNullOrWhiteSpace(inputFile) &&
         splitStartPages != null &&
         splitStartPages.Count >= 2)
     {
         var inputDocument = new iTextSharpPDF.PdfReader(inputFile);
         // First split must begin with page 1
         // Last split must not be higher than last page
         if (splitStartPages.Keys[0] == 1 &&
             splitStartPages.Keys[splitStartPages.Count - 1] <= inputDocument.NumberOfPages)
         {
             int currentPage = 1;
             int firstPageOfSplit;
             int lastPageOfSplit;
             try
             {
                 for (int splitPoint = 0; splitPoint <= (splitStartPages.Count - 1); splitPoint++)
                 {
                     firstPageOfSplit = currentPage;
                     if (splitPoint < (splitStartPages.Count - 1))
                     {
                         lastPageOfSplit = splitStartPages.Keys[splitPoint + 1] - 1;
                     }
                     else
                     {
                         lastPageOfSplit = inputDocument.NumberOfPages;
                     }
                     iTextSharpText.Document splitDocument   = null;
                     iTextSharpPDF.PdfCopy   splitOutputFile = null;
                     try
                     {
                         splitDocument   = new iTextSharpText.Document();
                         splitOutputFile = new iTextSharpPDF.PdfCopy(splitDocument, new FileStream(splitStartPages.Values[splitPoint], FileMode.Create, FileAccess.ReadWrite));
                         splitDocument.Open();
                         for (int outputPage = firstPageOfSplit; outputPage <= lastPageOfSplit; outputPage++)
                         {
                             splitDocument.SetPageSize(inputDocument.GetPageSizeWithRotation(currentPage));
                             splitOutputFile.AddPage(splitOutputFile.GetImportedPage(inputDocument, currentPage));
                             currentPage++;
                         }
                     }
                     finally
                     {
                         if (splitDocument != null && splitDocument.IsOpen())
                         {
                             splitDocument.Close();
                         }
                         if (splitOutputFile != null)
                         {
                             splitOutputFile.Close();
                             splitOutputFile.FreeReader(inputDocument);
                         }
                         splitDocument   = null;
                         splitOutputFile = null;
                     }
                 }
             }
             catch
             {
                 // Cleanup any files that may have
                 // been written
                 foreach (KeyValuePair <int, String> split in splitStartPages)
                 {
                     try
                     {
                         File.Delete(split.Value);
                     }
                     catch { }
                 }
                 throw;
             }
             finally
             {
                 if (inputDocument != null)
                 {
                     inputDocument.Close();
                 }
             }
         }
         else
         {
             if (splitStartPages.Keys[splitStartPages.Count - 1] > inputDocument.NumberOfPages)
             {
                 throw new ArgumentOutOfRangeException("splitStartPages", String.Format("Final page number must be less than the number of pages ({0}). Passed value is {1}.", inputDocument.NumberOfPages, splitStartPages.Keys[splitStartPages.Count - 1]));
             }
             throw new ArgumentOutOfRangeException("splitStartPages", "First page number must be 1.");
         }
     }
     else
     {
         if (inputFile == null)
         {
             throw new ArgumentNullException("inputFile", exceptionArgumentNullOrEmptyString);
         }
         if (splitStartPages == null)
         {
             throw new ArgumentNullException("splitStartPages", exceptionArgumentNullOrEmptyString);
         }
         throw new ArgumentOutOfRangeException("splitStartPages", "Must contain at least two KeyValue pairs.");
     }
 }
Пример #46
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="inputFile">The PDF file to split</param>
        /// <param name="splitStartPages"></param>
        public void SplitPDF(String inputFile, SortedList<int, String> splitStartPages)
        {
            if (!String.IsNullOrEmpty(inputFile) &&
                !String.IsNullOrWhiteSpace(inputFile) &&
                splitStartPages != null &&
                splitStartPages.Count >= 2)
            {
                var inputDocument = new iTextSharpPDF.PdfReader(inputFile);
                // First split must begin with page 1
                // Last split must not be higher than last page
                if (splitStartPages.Keys[0] == 1 &&
                    splitStartPages.Keys[splitStartPages.Count - 1] <= inputDocument.NumberOfPages)
                {
                    int currentPage = 1;
                    int firstPageOfSplit;
                    int lastPageOfSplit;
                    try
                    {
                        for (int splitPoint = 0; splitPoint <= (splitStartPages.Count - 1); splitPoint++)
                        {
                            firstPageOfSplit = currentPage;
                            if (splitPoint < (splitStartPages.Count - 1))
                            {
                                lastPageOfSplit = splitStartPages.Keys[splitPoint + 1] - 1;
                            }
                            else
                            {
                                lastPageOfSplit = inputDocument.NumberOfPages;
                            }
                            iTextSharpText.Document splitDocument = null;
                            iTextSharpPDF.PdfCopy splitOutputFile = null;
                            try
                            {
                                splitDocument = new iTextSharpText.Document();
                                splitOutputFile = new iTextSharpPDF.PdfCopy(splitDocument, new FileStream(splitStartPages.Values[splitPoint], FileMode.Create, FileAccess.ReadWrite));
                                splitDocument.Open();
                                for (int outputPage = firstPageOfSplit; outputPage <= lastPageOfSplit; outputPage++)
                                {
                                    splitDocument.SetPageSize(inputDocument.GetPageSizeWithRotation(currentPage));
                                    splitOutputFile.AddPage(splitOutputFile.GetImportedPage(inputDocument, currentPage));
                                    currentPage++;
                                }
                            }
                            finally
                            {
                                if (splitDocument != null && splitDocument.IsOpen()) splitDocument.Close();
                                if (splitOutputFile != null)
                                {
                                    splitOutputFile.Close();
                                    splitOutputFile.FreeReader(inputDocument);
                                }
                                splitDocument = null;
                                splitOutputFile = null;
                            }
                        }
                    }
                    catch
                    {
                        // Cleanup any files that may have
                        // been written
                        foreach (KeyValuePair<int, String> split in splitStartPages)
                        {
                            try
                            {
                                File.Delete(split.Value);
                            }
                            catch { }
                        }
                        throw;
                    }
                    finally
                    {
                        if (inputDocument != null) inputDocument.Close();
                    }

                }
                else
                {
                    if (splitStartPages.Keys[splitStartPages.Count - 1] > inputDocument.NumberOfPages) throw new ArgumentOutOfRangeException("splitStartPages", String.Format("Final page number must be less than the number of pages ({0}). Passed value is {1}.", inputDocument.NumberOfPages, splitStartPages.Keys[splitStartPages.Count - 1]));
                    throw new ArgumentOutOfRangeException("splitStartPages", "First page number must be 1.");
                }
            }
            else
            {
                if (inputFile == null) throw new ArgumentNullException("inputFile", exceptionArgumentNullOrEmptyString);
                if (splitStartPages == null) throw new ArgumentNullException("splitStartPages", exceptionArgumentNullOrEmptyString);
                throw new ArgumentOutOfRangeException("splitStartPages", "Must contain at least two KeyValue pairs.");
            }
        }
Пример #47
0
        /// <summary>
        /// Takes pages from two pdf files, and produces an output file
        /// whose odd pages are the contents of the first, and
        /// even pages are the contents of the second. Useful for
        /// merging front/back output from single sided scanners.
        /// </summary>
        /// <param name="oddPageFile">The file supplying odd numbered pages</param>
        /// <param name="evenPageFile">The file supplying even numbered pages</param>
        /// <param name="outputFile">The output file containing the merged pages</param>
        /// <param name="skipExtraPages">Set to true to skip any extra pages if
        ///                              one file is longer than the other</param>
        public void EvenOddMerge(String oddPageFile, String evenPageFile,
                                 String outputFile, bool skipExtraPages)
        {
            if (!String.IsNullOrEmpty(oddPageFile) && !String.IsNullOrWhiteSpace(oddPageFile) &&
                !String.IsNullOrEmpty(evenPageFile) && !String.IsNullOrWhiteSpace(evenPageFile) &&
                !String.IsNullOrEmpty(outputFile) && !String.IsNullOrWhiteSpace(outputFile))
            {
                var oddPageDocument  = new iTextSharpPDF.PdfReader(oddPageFile);
                var evenPageDocument = new iTextSharpPDF.PdfReader(evenPageFile);
                try
                {
                    iTextSharpText.Document mergedOutputDocument = null;
                    iTextSharpPDF.PdfCopy   mergedOutputFile     = null;

                    int lastPage = 0;
                    switch (skipExtraPages)
                    {
                    case (false):
                        lastPage = oddPageDocument.NumberOfPages;
                        if (evenPageDocument.NumberOfPages > oddPageDocument.NumberOfPages)
                        {
                            lastPage = evenPageDocument.NumberOfPages;
                        }
                        else
                        {
                            lastPage = oddPageDocument.NumberOfPages;
                        }
                        break;

                    case (true):
                        if (evenPageDocument.NumberOfPages < oddPageDocument.NumberOfPages)
                        {
                            lastPage = evenPageDocument.NumberOfPages;
                        }
                        else
                        {
                            lastPage = oddPageDocument.NumberOfPages;
                        }
                        break;
                    }

                    try
                    {
                        mergedOutputDocument = new iTextSharpText.Document();
                        mergedOutputFile     = new iTextSharpPDF.PdfCopy(mergedOutputDocument, new FileStream(outputFile, FileMode.Create, FileAccess.ReadWrite));
                        mergedOutputDocument.Open();
                        for (int loop = 1; loop <= lastPage; loop++)
                        {
                            // Extract and merge odd page
                            if (loop <= oddPageDocument.NumberOfPages)
                            {
                                mergedOutputDocument.SetPageSize(oddPageDocument.GetPageSizeWithRotation(loop));
                                mergedOutputFile.AddPage(mergedOutputFile.GetImportedPage(oddPageDocument, loop));
                            }
                            // Extract and merge even page
                            if (loop <= evenPageDocument.NumberOfPages)
                            {
                                mergedOutputDocument.SetPageSize(evenPageDocument.GetPageSizeWithRotation(loop));
                                mergedOutputFile.AddPage(mergedOutputFile.GetImportedPage(evenPageDocument, loop));
                            }
                        }
                    }
                    finally
                    {
                        if (mergedOutputDocument != null && mergedOutputDocument.IsOpen())
                        {
                            mergedOutputDocument.Close();
                        }
                        if (mergedOutputFile != null)
                        {
                            mergedOutputFile.Close();
                            mergedOutputFile.FreeReader(oddPageDocument);
                            mergedOutputFile.FreeReader(evenPageDocument);
                        }
                    }
                }
                catch
                {
                    try
                    {
                        File.Delete(outputFile);
                    }
                    catch { }
                    throw;
                }
                finally
                {
                    try
                    {
                        if (oddPageDocument != null)
                        {
                            oddPageDocument.Close();
                        }
                        oddPageDocument = null;
                    }
                    catch { }
                    try
                    {
                        if (evenPageDocument != null)
                        {
                            evenPageDocument.Close();
                        }
                        evenPageDocument = null;
                    }
                    catch { }
                }
            }
            else
            {
                if (String.IsNullOrEmpty(oddPageFile) || String.IsNullOrWhiteSpace(oddPageFile))
                {
                    throw new ArgumentNullException("oddPageFile", exceptionArgumentNullOrEmptyString);
                }
                if (String.IsNullOrEmpty(evenPageFile) || String.IsNullOrWhiteSpace(evenPageFile))
                {
                    throw new ArgumentNullException("evenPageFile", exceptionArgumentNullOrEmptyString);
                }
                if (String.IsNullOrEmpty(outputFile) || String.IsNullOrWhiteSpace(outputFile))
                {
                    throw new ArgumentNullException("outputFile", exceptionArgumentNullOrEmptyString);
                }
            }
        }
Пример #48
0
 /// <summary>
 /// Extracts a range of pages from a PDF file,
 /// and writes them to a new file.
 /// </summary>
 /// <param name="inputFile">The PDF to extract pages from.</param>
 /// <param name="outputFile">The new file to write the extracted pages to.</param>
 /// <param name="firstPage">The first page to extract.</param>
 /// <param name="lastPage">The last page to extract.</param>
 /// <exception cref="ArgumentNullException"></exception>
 /// <exception cref="ArgumentOutOfRangeException"></exception>
 /// <remarks><see cref="FileStream"/> constructor exceptions may also be thrown.</remarks>
 public void ExtractPDFPages(String inputFile, String outputFile, int firstPage, int lastPage)
 {
     if (!String.IsNullOrEmpty(inputFile) && !String.IsNullOrWhiteSpace(inputFile) &&
         !String.IsNullOrEmpty(outputFile) && !String.IsNullOrWhiteSpace(outputFile) &&
         firstPage > 0 && lastPage > 0 &&
         lastPage >= firstPage)
     {
         var inputDocument = new iTextSharpPDF.PdfReader(inputFile);
         try
         {
             // Page numbers specified must not be greater
             // than the number of pages in the document
             if (firstPage <= inputDocument.NumberOfPages &&
                 lastPage <= inputDocument.NumberOfPages)
             {
                 iTextSharpText.Document extractOutputDocument = null;
                 iTextSharpPDF.PdfCopy   extractOutputFile     = null;
                 try
                 {
                     extractOutputDocument = new iTextSharpText.Document();
                     extractOutputFile     = new iTextSharpPDF.PdfCopy(extractOutputDocument, new FileStream(outputFile, FileMode.Create, FileAccess.ReadWrite));
                     extractOutputDocument.Open();
                     for (int loop = firstPage; loop <= lastPage; loop++)
                     {
                         extractOutputDocument.SetPageSize(inputDocument.GetPageSizeWithRotation(loop));
                         extractOutputFile.AddPage(extractOutputFile.GetImportedPage(inputDocument, loop));
                     }
                 }
                 finally
                 {
                     if (extractOutputDocument != null && extractOutputDocument.IsOpen())
                     {
                         extractOutputDocument.Close();
                     }
                     if (extractOutputFile != null)
                     {
                         extractOutputFile.Close();
                         extractOutputFile.FreeReader(inputDocument);
                     }
                 }
             }
             else
             {
                 if (firstPage > inputDocument.NumberOfPages)
                 {
                     throw new ArgumentOutOfRangeException("firstPage", String.Format(exceptionParameterCannotBeGreaterThan, "firstPage", "the number of pages in the document."));
                 }
                 throw new ArgumentOutOfRangeException("lastPage", String.Format(exceptionParameterCannotBeGreaterThan, "firstPage", "the number of pages in the document."));
             }
         }
         catch
         {
             try
             {
                 File.Delete(outputFile);
             }
             catch { }
             throw;
         }
         finally
         {
             if (inputDocument != null)
             {
                 inputDocument.Close();
             }
             inputDocument = null;
         }
     }
     else
     {
         if (String.IsNullOrEmpty(inputFile) || String.IsNullOrWhiteSpace(inputFile))
         {
             throw new ArgumentNullException("inputFile", exceptionArgumentNullOrEmptyString);
         }
         if (String.IsNullOrEmpty(outputFile) || String.IsNullOrWhiteSpace(outputFile))
         {
             throw new ArgumentNullException("outputFile", exceptionArgumentNullOrEmptyString);
         }
         if (firstPage < 1)
         {
             throw new ArgumentOutOfRangeException("firstPage", exceptionArgumentZeroOrNegative);
         }
         if (lastPage < 1)
         {
             throw new ArgumentOutOfRangeException("lastPage", exceptionArgumentZeroOrNegative);
         }
         if (lastPage < firstPage)
         {
             throw new ArgumentOutOfRangeException("lastPage", String.Format(exceptionParameterCannotBeLessThan, "lastPage", "firstPage"));
         }
     }
 }
Пример #49
-1
 /// <summary>
 /// Concatenates two or more PDF files into one file.
 /// </summary>
 /// <param name="inputFiles">A string array containing the names of the pdf files to concatenate</param>
 /// <param name="outputFile">Name of the concatenated file.</param>
 public void ConcatenatePDFFiles(String[] inputFiles, String outputFile)
 {
     if (inputFiles != null && inputFiles.Length > 0)
     {
         if (!String.IsNullOrEmpty(outputFile) && !String.IsNullOrWhiteSpace(outputFile))
         {
             var concatDocument = new iTextSharpText.Document();
             var outputCopy = new iTextSharpPDF.PdfCopy(concatDocument, new FileStream(outputFile, FileMode.Create, FileAccess.ReadWrite));
             concatDocument.Open();
             try
             {
                 for (int loop = 0; loop <= inputFiles.GetUpperBound(0); loop++)
                 {
                     var inputDocument = new iTextSharpPDF.PdfReader(inputFiles[loop]);
                     for (int pageLoop = 1; pageLoop <= inputDocument.NumberOfPages; pageLoop++)
                     {
                         concatDocument.SetPageSize(inputDocument.GetPageSizeWithRotation(pageLoop));
                         outputCopy.AddPage(outputCopy.GetImportedPage(inputDocument, pageLoop));
                     }
                     inputDocument.Close();
                     outputCopy.FreeReader(inputDocument);
                     inputDocument = null;
                 }
                 concatDocument.Close();
                 outputCopy.Close();
             }
             catch
             {
                 if (concatDocument != null && concatDocument.IsOpen()) concatDocument.Close();
                 if (outputCopy != null) outputCopy.Close();
                 if (File.Exists(outputFile))
                 {
                     try
                     {
                         File.Delete(outputFile);
                     }
                     catch { }
                 }
                 throw;
             }
         }
         else
         {
             throw new ArgumentNullException("outputFile", exceptionArgumentNullOrEmptyString);
         }
     }
     else
     {
         throw new ArgumentNullException("inputFiles", exceptionArgumentNullOrEmptyString);
     }
 }