Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            //Create a pdf document.
            PdfDocument doc = new PdfDocument();

            //Draw pages
            PdfPageBase lastPage = DrawPages(doc);

            //script
            String script
                = "app.alert({"
                + "    cMsg: \"I'll lead; you must follow me.\","
                + "    nIcon: 3,"
                + "    cTitle: \"JavaScript Action\""
                + "});";
            PdfJavaScriptAction action1 = new PdfJavaScriptAction(script);
            doc.AfterOpenAction = action1;

            //script
            script
                = "app.alert({"
                + "    cMsg: \"The firt page!\","
                + "    nIcon: 3,"
                + "    cTitle: \"JavaScript Action\""
                + "});";
            PdfJavaScriptAction action2 = new PdfJavaScriptAction(script);
            action1.NextAction = action2;

            PdfDestination dest = new PdfDestination(lastPage);
            dest.Zoom = 1;
            PdfGoToAction action3 = new PdfGoToAction(dest);
            action2.NextAction = action3;

            //script
            script
                = "app.alert({"
                + "    cMsg: \"Oh sorry, it's the last page. I'm missing!\","
                + "    nIcon: 3,"
                + "    cTitle: \"JavaScript Action\""
                + "});";
            PdfJavaScriptAction action4 = new PdfJavaScriptAction(script);
            action3.NextAction = action4;

            //Save pdf file.
            doc.SaveToFile("ActionChain.pdf");
            doc.Close();

            //Launching the Pdf file.
            PDFDocumentViewer("ActionChain.pdf");
        }
Пример #2
0
        static void GenDocument4(Dictionary <string, string> row)
        {
            string caseNo = row["CaseNo"];
            string html   = File.ReadAllText("doc10.html");

            /***********************************************************************************************/
            html = html.Replace("@caseNo", "*" + caseNo + "-S02*");
            html = html.Replace("@IeokNo", row["IeokNo"]);
            html = html.Replace("@Unit", getUnit(row["OccurPoliceUnit"]));
            html = html.Replace("@ProcessNo", caseNo);
            string[] sts = new string[5];
            for (int i = 0; i < 5; i++)
            {
                sts[i] = "";
            }
            switch (row["IeokNo"])
            {
            case "1": sts[1] = "V"; break;

            case "2": sts[2] = "V"; break;

            default: sts[3] = "V"; break;
            }
            html = html.Replace("@V1", sts[1]);
            html = html.Replace("@V2", sts[2]);
            html = html.Replace("@V3", sts[3]);

            /***********************************************************************************************/
            string     tmpfil = filePath + caseNo + "_10.pdf";
            Document   doc    = new Document(PageSize.A4.Rotate(), 15, 15, 15, 15);
            FileStream fs     = new FileStream(tmpfil, FileMode.Create);
            PdfWriter  pdf    = PdfWriter.GetInstance(doc, fs);

            doc.Open();
            /***********************************************************************************************/

            string OccurTime = row["OccurTime"];

            html = html.Replace("@YY", OccurTime.Substring(0, 3));
            html = html.Replace("@MM", OccurTime.Substring(3, 2));
            html = html.Replace("@DD", OccurTime.Substring(5, 2));
            html = html.Replace("@HH", OccurTime.Substring(7, 2));
            html = html.Replace("@MI", OccurTime.Substring(9, 2));
            html = html.Replace("@WW", getCWeek(OccurTime.Substring(0, 7)));

            html = html.Replace("@OccurAddr1_1", row["OccurAddr1_1"]);
            //string adr = "地點:" + getAddr(row);
            html = html.Replace("@Addr1", getSkip(getAddr(row), 35));
            html = html.Replace("@Addr2", "");
            html = html.Replace("@Addr3", "");
            html = html.Replace("@DieNum", row["DieNum"]);
            html = html.Replace("@HurtNum", row["HurtNum"]);
            html = html.Replace("@DieO24Num", row["DieO24Num"]);

            html = html.Replace("@OccurReport4", row["OccurReport4"]);
            html = html.Replace("@OccurReport5", row["OccurReport5"]);
            html = html.Replace("@OccurReport6", row["OccurReport6"]);
            html = html.Replace("@OccurReport7", row["OccurReport7"]);
            html = html.Replace("@OccurReport8", row["OccurReport8"]);
            html = html.Replace("@OccurReport9", row["OccurReport9"]);
            html = html.Replace("@OccurReport10_1", row["OccurReport10_1"]);
            html = html.Replace("@OccurReport10_2", row["OccurReport10_2"]);
            html = html.Replace("@OccurReport10_3", row["OccurReport10_3"]);
            html = html.Replace("@OccurReport11_1", row["OccurReport11_1"]);
            html = html.Replace("@OccurReport11_2", row["OccurReport11_2"]);
            html = html.Replace("@OccurReport12_1", row["OccurReport12_1"]);
            html = html.Replace("@OccurReport12_2", row["OccurReport12_2"]);
            html = html.Replace("@OccurReport13", row["OccurReport13"]);
            html = html.Replace("@OccurReport14_1", row["OccurReport14_1"]);
            html = html.Replace("@OccurReport14_2", row["OccurReport14_2"]);
            html = html.Replace("@OccurReport14_3", row["OccurReport14_3"]);
            html = html.Replace("@OccurReport15", row["OccurReport15"]);

            string gifx = "";

            for (int i = 1; i < 16; i++)
            {
                gifx = GifPath + "no" + i + ".gif";
                html = html.Replace("@no" + i.ToString("00"), gifx);
            }

            /***********************************************************************************************/
            byte[]       bytehtml = System.Text.Encoding.UTF8.GetBytes(html);
            MemoryStream mshtml   = new MemoryStream(bytehtml);

            byte[]       bytecss = System.Text.Encoding.UTF8.GetBytes(cssStr);
            MemoryStream mscss   = new MemoryStream(bytecss);

            XMLWorkerHelper.GetInstance().ParseXHtml(pdf, doc, mshtml, mscss);

            PdfDestination pdfDest = new PdfDestination(PdfDestination.XYZ, 0, doc.PageSize.Height, 1f);
            PdfAction      action  = PdfAction.GotoLocalPage(1, pdfDest, pdf);

            pdf.SetOpenAction(action);

            doc.Close();
            //EncryptPDF(tmpfil, filePath + row["ApplyNo"] + "_1.pdf", row["IdNo"]);
            //if (row["MailFlag1"] != "1") UpdateMailFlag(row["ApplyNo"], "1");
        }
Пример #3
0
        static void GenDocument3(Dictionary <string, string> row)
        {
            string caseNo  = row["CaseNo"];
            string html    = File.ReadAllText("doc3.html");
            string codeMsg = caseNo + ";" + row["OccurPoliceUnit"] + ";" + row["OccurPoliceStation"] + ";";
            string qrCode  = RQCodePath + caseNo + ".png";

            codeMsg += row["ProcessId"] + ";10.116.1.219;" + addDate(0);
            makeQRcode(codeMsg, qrCode);

            html = html.Replace("@caseNo", "*" + caseNo + "-S23*");
            //html = html.Replace("@appName", row["Name"]);
            html = html.Replace("@appName", "");
            html = html.Replace("@OccurTime", getDateFrm(row["OccurTime"], 1));
            html = html.Replace("@OccurAddr", getAddr(row));
            html = html.Replace("@QRCode", qrCode);
            string remake = "reference_only2.jpg";

            html = html.Replace("@reMake", remake);

            string sql = "select * from CasePerson where CaseNo = '" + caseNo + "'";
            List <Dictionary <string, string> > lsdy = ioCon.SelectDct(sql);

            if (lsdy.Count == 0)
            {
                return;
            }

            /***********************************************************************************************/
            string     tmpfil = filePath + caseNo + "_13.pdf";
            Document   doc    = new Document(PageSize.A4, 10, 10, 10, 10);
            FileStream fs     = new FileStream(tmpfil, FileMode.Create);
            PdfWriter  pdf    = PdfWriter.GetInstance(doc, fs);

            doc.Open();
            /***********************************************************************************************/
            for (int i = 1; i < 4; i++)
            {
                if (i > lsdy.Count)
                {
                    html = html.Replace("@PersonCname" + i, "");
                    html = html.Replace("@CarKind" + i, "");
                    html = html.Replace("@CarNo" + i, "");
                    html = html.Replace("@Name" + i, "");
                    html = html.Replace("@PerCause" + i, "");
                }
                else
                {
                    Dictionary <string, string> col = lsdy[i - 1];
                    html = html.Replace("@PersonCname" + i, col["PersonCname"]);
                    string carKind = getMItemVal("車種類別", col["OccurReport26"], 1);
                    if (carKind == "人")
                    {
                        carKind = getMItemVal("車種類別", col["OccurReport26"], 0);
                    }
                    else
                    {
                        carKind = getMItemVal("車種類別", col["OccurReport26"], 2);
                    }
                    html = html.Replace("@CarKind" + i, carKind);
                    string carNo = col["OccurReport27"];
                    html = html.Replace("@CarNo" + i, carNo);
                    string drName = col["PersonCname"];
                    html = html.Replace("@Name" + i, drName);
                    string perCause = col["PerCause"];
                    if (perCause == "")
                    {
                        perCause = getMItemVal("肇事因素", col["OccurReport34_1"], 0);
                        string otherA = getAAScp(col["OccurReport30"]);
                        string otherB = getBBScp(col["OccurReport32"]);
                        if (perCause != "")
                        {
                            if (otherA != "")
                            {
                                perCause += "," + otherA;
                            }
                            if (otherB != "")
                            {
                                perCause += "," + otherB;
                            }
                        }
                    }
                    html = html.Replace("@PerCause" + i, perCause);
                }
                string sysdat = DateTime.Now.ToString("yyyyMMdd");
                html = html.Replace("@sysDate", getDateFrm(sysdat, 0));
            }
            //string mark = getPsnMark(row["ProcessId"]);  //2018.11.16 處理人員改為結案人員
            string mark = getCh12IdMark(row["CaseNo"]);

            html = html.Replace("@Mark1", MarkPath + mark);
            mark = getUntMark(row["OccurPoliceStation"], row["OccurPoliceUnit"]);
            html = html.Replace("@Mark2", MarkPath + mark);

            /***********************************************************************************************/
            byte[]       bytehtml = System.Text.Encoding.UTF8.GetBytes(html);
            MemoryStream mshtml   = new MemoryStream(bytehtml);

            byte[]       bytecss = System.Text.Encoding.UTF8.GetBytes(cssStr);
            MemoryStream mscss   = new MemoryStream(bytecss);

            XMLWorkerHelper.GetInstance().ParseXHtml(pdf, doc, mshtml, mscss);

            PdfDestination pdfDest = new PdfDestination(PdfDestination.XYZ, 0, doc.PageSize.Height, 1f);
            PdfAction      action  = PdfAction.GotoLocalPage(1, pdfDest, pdf);

            pdf.SetOpenAction(action);

            doc.Close();
            //EncryptPDF(tmpfil, filePath + row["ApplyNo"] + "_3.pdf", row["IdNo"]);
            //if (row["MailFlag3"] != "1") UpdateMailFlag(row["ApplyNo"], "3");
        }
Пример #4
0
        static void GenDocument2(Dictionary <string, string> row)
        {
            string caseNo = row["CaseNo"];
            string head   = File.ReadAllText("doc20.html");
            string pict   = File.ReadAllText("doc21.html");
            string html   = "";

            /***********************************************************************************************/
            string mark = getPsnMark(row["ProcessId"]);

            head = head.Replace("@Mark", MarkPath + mark);

            string imgPath = PicPath + caseNo.Substring(0, 5) + "\\" + caseNo + "\\Media\\";

            head = head.Replace("@caseNo", "*" + caseNo + "-S15*");
            string sql = "select a.*,b.FSPath,b.FName from CaseRepData a,CaseMediaFile b ";

            sql += "where a.CaseNo = b.CaseNo and a.DocFld13 = b.MediaSno ";
            sql += "and a.DocNm='照片黏貼紀錄表' and  b.MediaNm='事故照片黏貼圖檔' ";
            sql += "and a.CaseNo='" + caseNo + "' order by a.DocSno";
            List <Dictionary <string, string> > lsdy = ioCon.SelectDct(sql);

            if (lsdy.Count == 0)
            {
                return;
            }

            /***********************************************************************************************/
            string     tmpfil = filePath + caseNo + "_03.pdf";
            Document   doc    = new Document(PageSize.A4, 15, 10, 10, 15);
            FileStream fs     = new FileStream(tmpfil, FileMode.Create);
            PdfWriter  pdf    = PdfWriter.GetInstance(doc, fs);

            doc.Open();
            /***********************************************************************************************/
            for (int i = 0; i < lsdy.Count; i++)
            {
                Dictionary <string, string> col = lsdy[i];
                if (i % 2 == 0)
                {
                    html += head;
                    html += pict;
                }
                else
                {
                    html += "<div style=\"height:10px\"></div>";
                    html += pict;
                }
                html = html.Replace("@Pic", imgPath + col["FName"]);
                html = html.Replace("@OccurTime", getDateFrm(col["DocTime1"], 2));
                html = html.Replace("@Seq", col["DocSno"]);
                html = html.Replace("@Remake", getScp(col));
            }

            /***********************************************************************************************/
            byte[]       bytehtml = System.Text.Encoding.UTF8.GetBytes(html);
            MemoryStream mshtml   = new MemoryStream(bytehtml);

            byte[]       bytecss = System.Text.Encoding.UTF8.GetBytes(cssStr);
            MemoryStream mscss   = new MemoryStream(bytecss);

            XMLWorkerHelper.GetInstance().ParseXHtml(pdf, doc, mshtml, mscss);

            PdfDestination pdfDest = new PdfDestination(PdfDestination.XYZ, 0, doc.PageSize.Height, 1f);
            PdfAction      action  = PdfAction.GotoLocalPage(1, pdfDest, pdf);

            pdf.SetOpenAction(action);

            doc.Close();
            //EncryptPDF(tmpfil, filePath + row["ApplyNo"] + "_2.pdf", row["IdNo"]);
            //if (row["MailFlag2"] != "1") UpdateMailFlag(row["ApplyNo"], "2");
        }
Пример #5
0
        public Chap1107()
        {
            Console.WriteLine("Chapter 11 example 7: Outlines and Destinations");

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

            try
            {
                // step 2:
                // we create a writer that listens to the document
                // and directs a PDF-stream to a file
                PdfWriter writer = PdfWriter.GetInstance(document, new FileStream("Chap1107.pdf", FileMode.Create));

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

                // step 4: we grab the ContentByte and do some stuff with it
                PdfContentByte cb = writer.DirectContent;

                // we create a PdfTemplate
                PdfTemplate template = cb.CreateTemplate(25, 25);

                // we add some crosses to visualize the destinations
                template.MoveTo(13, 0);
                template.LineTo(13, 25);
                template.MoveTo(0, 13);
                template.LineTo(50, 13);
                template.Stroke();

                // we add the template on different positions
                cb.AddTemplate(template, 287, 787);
                cb.AddTemplate(template, 187, 487);
                cb.AddTemplate(template, 487, 287);
                cb.AddTemplate(template, 87, 87);

                // we define the destinations
                PdfDestination d1 = new PdfDestination(PdfDestination.XYZ, 300, 800, 0);
                PdfDestination d2 = new PdfDestination(PdfDestination.FITH, 500);
                PdfDestination d3 = new PdfDestination(PdfDestination.FITR, 200, 300, 400, 500);
                PdfDestination d4 = new PdfDestination(PdfDestination.FITBV, 100);
                PdfDestination d5 = new PdfDestination(PdfDestination.FIT);

                // we define the outlines
                PdfOutline out1 = new PdfOutline(cb.RootOutline, d1, "root");
                PdfOutline out2 = new PdfOutline(out1, d2, "sub 1");
                PdfOutline out3 = new PdfOutline(out1, d3, "sub 2");
                PdfOutline out4 = new PdfOutline(out2, d4, "sub 2.1");
                PdfOutline out5 = new PdfOutline(out2, d5, "sub 2.2");

                cb.AddOutline(out1);
                cb.AddOutline(out2);
                cb.AddOutline(out3);
                cb.AddOutline(out4);
                cb.AddOutline(out5);
            }
            catch (DocumentException de)
            {
                Console.Error.WriteLine(de.Message);
            }
            catch (IOException ioe)
            {
                Console.Error.WriteLine(ioe.Message);
            }

            // step 5: we close the document
            document.Close();
        }
Пример #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            //Create a pdf document.
            PdfDocument doc = new PdfDocument();

            //margin
            PdfUnitConvertor unitCvtr = new PdfUnitConvertor();
            PdfMargins margin = new PdfMargins();
            margin.Top = unitCvtr.ConvertUnits(2.54f, PdfGraphicsUnit.Centimeter, PdfGraphicsUnit.Point);
            margin.Bottom = margin.Top;
            margin.Left = unitCvtr.ConvertUnits(3.17f, PdfGraphicsUnit.Centimeter, PdfGraphicsUnit.Point);
            margin.Right = margin.Left;

            //create section
            PdfSection section = doc.Sections.Add();
            section.PageSettings.Size = PdfPageSize.A4;
            section.PageSettings.Margins = margin;

            // Create one page
            PdfPageBase page = section.Pages.Add();

            float y = 10;

            //title
            PdfBrush brush1 = PdfBrushes.Black;
            PdfTrueTypeFont font1 = new PdfTrueTypeFont(new Font("Arial", 16f, FontStyle.Bold));
            PdfStringFormat format1 = new PdfStringFormat(PdfTextAlignment.Center);
            page.Canvas.DrawString("Sales Report", font1, brush1, page.Canvas.ClientSize.Width / 2, y, format1);
            y = y + font1.MeasureString("Sales Report", format1).Height;
            y = y + 5;

            PdfTrueTypeFont font2 = new PdfTrueTypeFont(new Font("Arial", 11f, FontStyle.Bold));
            PdfTrueTypeFont font3 = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Bold));
            using (OleDbConnection conn = new OleDbConnection())
            {
                conn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=..\..\..\..\..\..\Data\demo.mdb";
                conn.Open();

                OleDbCommand partQueryCommand = PreparePartQueryCommand(conn);
                OleDbCommand orderItemQueryCommand = PrepareOrderItemQueryCommand(conn);

                DataTable vendors = GetVendors(conn);
                for (int i = 0;  i < vendors.Rows.Count; i++)
                {
                    if (i > 0)
                    {
                        //next page
                        page = section.Pages.Add();
                        y = 0;
                    }
                    //draw vendor
                    String vendorTitle = String.Format("{0}. {1}", i + 1, vendors.Rows[i].ItemArray[1]);
                    PdfLayoutResult drawVendorLayoutResult = DrawVendor(page, vendors, i, vendorTitle, y);

                    //add vendor bookmark
                    PdfDestination vendorBookmarkDest = new PdfDestination(page, new PointF(0, y));
                    PdfBookmark vendorBookmark = doc.Bookmarks.Add(vendorTitle);
                    vendorBookmark.Color = Color.SaddleBrown;
                    vendorBookmark.DisplayStyle = PdfTextStyle.Bold;
                    vendorBookmark.Action = new PdfGoToAction(vendorBookmarkDest);

                    y = drawVendorLayoutResult.Bounds.Bottom + 5;
                    page = drawVendorLayoutResult.Page;

                    //get parts of vendor
                    DataTable parts = GetParts(partQueryCommand, (double)vendors.Rows[i].ItemArray[0]);
                    for (int j = 0; j < parts.Rows.Count; j++)
                    {
                        if (j > 0)
                        {
                            //next page
                            page = section.Pages.Add();
                            y = 0;
                        }
                        //draw part
                        String partTitle = String.Format("{0}.{1}. {2}", i + 1, j + 1, parts.Rows[j].ItemArray[1]);
                        PdfLayoutResult drawPartLayoutResult = DrawPart(page, parts, j, partTitle, y);

                        //add part bookmark
                        PdfDestination partBookmarkDest = new PdfDestination(page, new PointF(0, y));
                        PdfBookmark partBookmark = vendorBookmark.Add(partTitle);
                        partBookmark.Color = Color.Coral;
                        partBookmark.DisplayStyle = PdfTextStyle.Italic;
                        partBookmark.Action = new PdfGoToAction(partBookmarkDest);

                        y = drawPartLayoutResult.Bounds.Bottom + 5;
                        page = drawPartLayoutResult.Page;

                        //get order items
                        String orderItemsTitle = String.Format("{0} - Order Items", parts.Rows[j].ItemArray[1]);
                        DataTable orderItems = GetOrderItems(orderItemQueryCommand, (double)parts.Rows[j].ItemArray[0]);
                        DrawOrderItems(page, orderItems, orderItemsTitle, y);
                    }
                }
            }

            //Save pdf file.
            doc.SaveToFile("Bookmark.pdf");
            doc.Close();

            //Launching the Pdf file.
            PDFDocumentViewer("Bookmark.pdf");
        }
Пример #7
0
        protected void buttonCreatePdf_Click(object sender, EventArgs e)
        {
            // create a PDF document
            PdfDocument document = new PdfDocument();

            // set a demo serial number
            document.SerialNumber = "YCgJMTAE-BiwJAhIB-EhlWTlBA-UEBRQFBA-U1FOUVJO-WVlZWQ==";

            // create the true type fonts that can be used in document
            System.Drawing.Font ttfFont           = new System.Drawing.Font("Times New Roman", 10, System.Drawing.GraphicsUnit.Point);
            PdfFont             newTimesFont      = document.CreateFont(ttfFont);
            PdfFont             newTimesFontEmbed = document.CreateFont(ttfFont, true);

            // create page 1
            PdfPage page1 = document.AddPage();
            // create a text object to be laid out on this page
            PdfText text1 = new PdfText(10, 10, "This is the Page 1 of the document with Open action", newTimesFontEmbed);

            // layout the text
            page1.Layout(text1);

            // create page 2
            PdfPage page2 = document.AddPage();
            // create a text object to be laid out on this page
            PdfText text2 = new PdfText(10, 10, "This is the Page 2 of the document with Open action", newTimesFontEmbed);

            // layout the text
            page2.Layout(text2);

            // create page 1
            PdfPage page3 = document.AddPage();
            // create a text object to be laid out on this page
            PdfText text3 = new PdfText(10, 10, "This is the Page 3 of the document with Open action", newTimesFontEmbed);

            // layout the text
            page3.Layout(text3);

            if (radioButtonJavaScript.Checked)
            {
                // display an alert message when the document is opened

                string alertMessage   = textBoxAlertMessage.Text;
                string javaScriptCode = "app.alert({cMsg: \"" + alertMessage + "\", cTitle: \"Open Document JavaScript Action\"});";

                // create the JavaScript action to display the alert
                PdfJavaScriptAction javaScriptAction = new PdfJavaScriptAction(javaScriptCode);

                // set the document JavaScript open action
                document.SetOpenAction(javaScriptAction);
            }
            else
            {
                // go to a given page in document and set the given zoom level when the document is opened

                int pageIndex = radioButtonPage1.Checked ? 0 : (radioButtonPage2.Checked ? 1 : 2);
                int zoomLevel = int.Parse(textBoxZoomLevel.Text);

                PdfDestination openDestination = new PdfDestination(document.Pages[pageIndex], new System.Drawing.PointF(10, 10));
                openDestination.Zoom = zoomLevel;
                PdfGoToAction goToAction = new PdfGoToAction(openDestination);

                // set the document GoTo open action
                document.SetOpenAction(goToAction);
            }

            try
            {
                // write the PDF document to a memory buffer
                byte[] pdfBuffer = document.WriteToMemory();

                // inform the browser about the binary data format
                HttpContext.Current.Response.AddHeader("Content-Type", "application/pdf");

                // let the browser know how to open the PDF document and the file name
                HttpContext.Current.Response.AddHeader("Content-Disposition", String.Format("attachment; filename=OpenAction.pdf; size={0}",
                                                                                            pdfBuffer.Length.ToString()));

                // write the PDF buffer to HTTP response
                HttpContext.Current.Response.BinaryWrite(pdfBuffer);

                // call End() method of HTTP response to stop ASP.NET page processing
                HttpContext.Current.Response.End();
            }
            finally
            {
                document.Close();
            }
        }
Пример #8
0
        private void button1_Click(object sender, EventArgs e)
        {
            //Create a pdf document.
            PdfDocument doc = new PdfDocument();

            //margin
            PdfUnitConvertor unitCvtr = new PdfUnitConvertor();
            PdfMargins margin = new PdfMargins();
            margin.Top = unitCvtr.ConvertUnits(2.54f, PdfGraphicsUnit.Centimeter, PdfGraphicsUnit.Point);
            margin.Bottom = margin.Top;
            margin.Left = unitCvtr.ConvertUnits(3.17f, PdfGraphicsUnit.Centimeter, PdfGraphicsUnit.Point);
            margin.Right = margin.Left;

            // Create one page
            PdfPageBase page = doc.Pages.Add(PdfPageSize.A4, margin);

            float y = 10;

            //title
            PdfBrush brush1 = PdfBrushes.Black;
            PdfTrueTypeFont font1 = new PdfTrueTypeFont(new Font("Arial", 16f, FontStyle.Bold));
            PdfStringFormat format1 = new PdfStringFormat(PdfTextAlignment.Center);
            page.Canvas.DrawString("Part List", font1, brush1, page.Canvas.ClientSize.Width / 2, y, format1);
            y = y + font1.MeasureString("Part List", format1).Height;
            y = y + 2;

            //table top
            PdfDestination tableTopDest = new PdfDestination(page);
            tableTopDest.Location = new PointF(0, y);
            tableTopDest.Mode = PdfDestinationMode.Location;
            tableTopDest.Zoom = 1f;

            //Draw table            
            PdfTrueTypeFont buttonFont = new PdfTrueTypeFont(new Font("Arial", 10f, FontStyle.Bold));
            float buttonWidth = 70;
            float buttonHeight = buttonFont.Height * 1.5f;
            float tableTop = y;
            PdfLayoutResult tableLayoutResult = DrawTable(page, y + buttonHeight + 5);

            //table bottom
            PdfDestination tableBottomDest = new PdfDestination(tableLayoutResult.Page);
            tableBottomDest.Location = new PointF(0, tableLayoutResult.Bounds.Bottom);
            tableBottomDest.Mode = PdfDestinationMode.Location;
            tableBottomDest.Zoom = 1f;

            //go to table bottom
            float x = page.Canvas.ClientSize.Width - buttonWidth;
            PdfStringFormat format2 = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
            RectangleF buttonBounds = new RectangleF(x, tableTop, buttonWidth, buttonHeight);
            page.Canvas.DrawRectangle(PdfBrushes.DarkGray, buttonBounds);
            page.Canvas.DrawString("To Bottom", buttonFont, PdfBrushes.CadetBlue, buttonBounds, format2);
            PdfGoToAction action1 = new PdfGoToAction(tableBottomDest);
            PdfActionAnnotation annotation1
                = new PdfActionAnnotation(buttonBounds, action1);
            annotation1.Border = new PdfAnnotationBorder(0.75f);
            annotation1.Color = Color.LightGray;
            (page as PdfNewPage).Annotations.Add(annotation1);

            //go to table top
            float tableBottom = tableLayoutResult.Bounds.Bottom + 5;
            buttonBounds = new RectangleF(x, tableBottom, buttonWidth, buttonHeight);
            tableLayoutResult.Page.Canvas.DrawRectangle(PdfBrushes.DarkGray, buttonBounds);
            tableLayoutResult.Page.Canvas.DrawString("To Top", buttonFont, PdfBrushes.CadetBlue, buttonBounds, format2);
            PdfGoToAction action2 = new PdfGoToAction(tableTopDest);
            PdfActionAnnotation annotation2
                = new PdfActionAnnotation(buttonBounds, action2);
            annotation2.Border = new PdfAnnotationBorder(0.75f);
            annotation2.Color = Color.LightGray;
            (tableLayoutResult.Page as PdfNewPage).Annotations.Add(annotation2);

            //goto last page
            PdfNamedAction action3 = new PdfNamedAction(PdfActionDestination.LastPage);
            doc.AfterOpenAction = action3;

            //script
            String script
                = "app.alert({"
                + "    cMsg: \"Oh no, you want to leave me.\","
                + "    nIcon: 3,"
                + "    cTitle: \"JavaScript Action\""
                + "});";
            PdfJavaScriptAction action4 = new PdfJavaScriptAction(script);
            doc.BeforeCloseAction = action4;

            //Save pdf file.
            doc.SaveToFile("Action.pdf");
            doc.Close();

            //Launching the Pdf file.
            PDFDocumentViewer("Action.pdf");
        }
Пример #9
0
 /// <summary>Creates a GoToR action, or remote action (section 12.6.4.3 of ISO 32000-1).</summary>
 /// <param name="fileSpec">the file in which the destination shall be located</param>
 /// <param name="destination">the destination in the remote document to jump to</param>
 /// <param name="newWindow">a flag specifying whether to open the destination document in a new window</param>
 /// <returns>created action</returns>
 public static iText.Kernel.Pdf.Action.PdfAction CreateGoToR(PdfFileSpec fileSpec, PdfDestination destination
                                                             , bool newWindow)
 {
     return(CreateGoToR(fileSpec, destination).Put(PdfName.NewWindow, PdfBoolean.ValueOf(newWindow)));
 }
Пример #10
0
 /// <summary>Creates a GoTo action (section 12.6.4.2 of ISO 32000-1) via a given destination.</summary>
 /// <param name="destination">the desired destination of the action</param>
 /// <returns>created action</returns>
 public static iText.Kernel.Pdf.Action.PdfAction CreateGoTo(PdfDestination destination)
 {
     ValidateNotRemoteDestination(destination);
     return(new iText.Kernel.Pdf.Action.PdfAction().Put(PdfName.S, PdfName.GoTo).Put(PdfName.D, destination.GetPdfObject
                                                                                         ()));
 }
Пример #11
0
        /// <summary>
        /// 產生PDF byte[]
        /// </summary>
        /// <param name="htmlText"></param>
        /// <param name="exportFile">匯出檔案</param>
        /// <returns></returns>
        public static byte[] exportPDF(string htmlText, IDocSetting ds, string SplithtmlText = "我是分頁", bool exportFile = false)
        {
            byte[] buf = null;

            if (string.IsNullOrEmpty(htmlText))
            {
                return(null);
            }
            //避免當htmlText無任何html tag標籤的純文字時,轉PDF時會掛掉,所以一律加上<p>標籤
            //htmlText = "<p>" + htmlText + "</p>";
            string[] pageHtml = System.Text.RegularExpressions.Regex.Split(htmlText, SplithtmlText);

            Document doc = new Document(iTextSharp.text.PageSize.A4);//要寫PDF的文件,建構子沒填的話預設直式A4
            //指定文件預設開檔時的縮放為100%
            PdfDestination pdfDest = new PdfDestination(PdfDestination.XYZ, 0, doc.PageSize.Height, 1f);

            //開啟Document文件
            if (ds.SetMargins)
            {
                doc.SetMargins(ds.marginLeft, ds.marginRight, ds.marginTop, ds.marginBottom);
            }


            MemoryStream outputStream = new MemoryStream();//要把PDF寫到哪個串流
            PdfWriter    writer       = PdfWriter.GetInstance(doc, outputStream);

            doc.Open();

            foreach (string str in pageHtml)
            {
                if (str == "\r\n" && pageHtml.Length > 1)
                {
                    continue;
                }
                doc.NewPage();
                int          page    = 1;
                string       text    = string.Format("{0}" + str + "{1}", "<p>", "</p>");
                byte[]       data    = Encoding.UTF8.GetBytes(text);//字串轉成byte[]
                MemoryStream msInput = new MemoryStream(data);



                //使用XMLWorkerHelper把Html parse到PDF檔裡
                Stream fs         = null;
                string sourcePath = "";
                string sourceFile = "";
                if (!string.IsNullOrWhiteSpace(ds.cssFile))
                {
                    sourcePath = System.Web.Hosting.HostingEnvironment.MapPath("~\\StyleSheet\\");
                    sourceFile = System.IO.Path.Combine(sourcePath, ds.cssFile);
                    fs         = System.IO.File.OpenRead(sourceFile);
                }

                //使用XMLWorkerHelper把Html parse到PDF檔裡
                try
                {
                    XMLWorkerHelper.GetInstance().ParseXHtml(writer, doc, msInput, fs, Encoding.UTF8, new UnicodeFontFactory());
                }
                catch (Exception ex)
                {
                    Com.Mayaminer.LogTool.SaveLogMessage(ex, "exportPDF", "exportPDF");
                }

                //將pdfDest設定的資料寫到PDF檔
                PdfAction action = PdfAction.GotoLocalPage(page, pdfDest, writer);
                writer.SetOpenAction(action);
                msInput.Close();
                page++;
            }
            doc.Close();
            outputStream.Close();
            //回傳PDF檔案
            buf = outputStream.ToArray();


            return(buf);
        }
Пример #12
0
 /// <summary>Creates a Link to another location in the document.</summary>
 /// <param name="text">the textual contents of the link</param>
 /// <param name="destination">
 /// a
 /// <see cref="iText.Kernel.Pdf.Navigation.PdfDestination"/>
 /// </param>
 public Link(String text, PdfDestination destination)
     : this(text, (PdfLinkAnnotation) new PdfLinkAnnotation(new Rectangle(0, 0, 0, 0)).SetDestination(destination
                                                                                                      ).SetFlags(PdfAnnotation.PRINT))
 {
 }
        /// <summary>
        /// 產生PDF byte[]
        /// </summary>
        /// <param name="htmlText"></param>
        /// <param name="ds"></param>
        /// <param name="exportFile">匯出檔案</param>
        /// <returns></returns>
        public FileContentResult exportPDF(string htmlText, IDocSetting ds, bool exportFile = false)
        {
            byte[] buf        = null;
            string actionName = "exportPDF";

            setFileContentType(fileType.pdf);
            try
            {
                if (string.IsNullOrEmpty(htmlText))
                {
                    return(null);
                }
                //避免當htmlText無任何html tag標籤的純文字時,轉PDF時會掛掉,所以一律加上<p>標籤
                //htmlText = "<p>" + htmlText + "</p>";
                string[] pageHtml = System.Text.RegularExpressions.Regex.Split(htmlText, ds.pageSplit);

                Document doc = new Document(iTextSharp.text.PageSize.A4);//要寫PDF的文件,建構子沒填的話預設直式A4
                if (ds.SetMargins)
                {
                    doc.SetMargins(ds.marginLeft, ds.marginRight, ds.marginTop, ds.marginBottom);
                }
                //指定文件預設開檔時的縮放為100%
                PdfDestination pdfDest = new PdfDestination(PdfDestination.XYZ, 0, doc.PageSize.Height, 1f);
                //開啟Document文件

                MemoryStream outputStream = new MemoryStream();//要把PDF寫到哪個串流
                PdfWriter    writer       = PdfWriter.GetInstance(doc, outputStream);
                doc.Open();

                foreach (string str in pageHtml)
                {
                    if (str == "\r\n" && pageHtml.Length > 1)
                    {
                        continue;
                    }
                    doc.NewPage();
                    int          page    = 1;
                    string       text    = string.Format("{0}" + str + "{1}", "<p>", "</p>");
                    byte[]       data    = Encoding.UTF8.GetBytes(text);//字串轉成byte[]
                    MemoryStream msInput = new MemoryStream(data);

                    //使用XMLWorkerHelper把Html parse到PDF檔裡
                    Stream fs         = null;
                    string sourcePath = "";
                    string sourceFile = "";
                    if (!string.IsNullOrWhiteSpace(ds.cssFile))
                    {
                        sourcePath = System.Web.Hosting.HostingEnvironment.MapPath("~\\StyleSheet\\");
                        sourceFile = System.IO.Path.Combine(sourcePath, ds.cssFile);
                        fs         = System.IO.File.OpenRead(sourceFile);
                    }

                    /*------------------------- Cxr繪圖 2018.09.13 [下] -------------------------*/
                    #region Cxr
                    //1.版面配置CSS
                    CssFilesImpl cssFiles = new CssFilesImpl();
                    cssFiles.Add(XMLWorkerHelper.GetCSS(File.OpenRead(sourceFile))); // [File.OpenRead] 新增 [StyleAttrCSSResolver]
                    StyleAttrCSSResolver cssResolver = new StyleAttrCSSResolver(cssFiles);

                    //2.重新撰寫底層Image功能Tag
                    DefaultTagProcessorFactory tagProcessors = (DefaultTagProcessorFactory)Tags.GetHtmlTagProcessorFactory();
                    tagProcessors.RemoveProcessor(HTML.Tag.IMG);                             // remove the default processor
                    tagProcessors.AddProcessor(HTML.Tag.IMG, new CustomImageTagProcessor()); // use new processor

                    //3.重新編譯
                    //HtmlPipelineContext hpc = new HtmlPipelineContext(new CssAppliersImpl(new XMLWorkerFontProvider()));
                    HtmlPipelineContext hpc = new HtmlPipelineContext(new CssAppliersImpl(new UnicodeFontFactory()));
                    hpc.SetAcceptUnknown(true).AutoBookmark(true).SetTagFactory(tagProcessors); // inject the tagProcessors
                    HtmlPipeline        htmlPipeline = new HtmlPipeline(hpc, new PdfWriterPipeline(doc, writer));
                    CssResolverPipeline pipeline     = new CssResolverPipeline(cssResolver, htmlPipeline);
                    XMLWorker           worker       = new XMLWorker(pipeline, true);
                    XMLParser           xmlParser    = new XMLParser(true, worker, Encoding.UTF8);
                    xmlParser.Parse(new StringReader(text));
                    #endregion
                    /*------------------------- Cxr繪圖 2018.09.13 [上] -------------------------*/

                    /* 2018.09.13 恢復舊有功能
                     *  //使用XMLWorkerHelper把Html parse到PDF檔裡
                     *  XMLWorkerHelper.GetInstance().ParseXHtml(writer, doc, msInput, fs, Encoding.UTF8, new UnicodeFontFactory());
                     *  //將pdfDest設定的資料寫到PDF檔
                     *  PdfAction action = PdfAction.GotoLocalPage(page, pdfDest, writer);
                     *  writer.SetOpenAction(action);
                     */
                    msInput.Close();
                    page++;
                }
                doc.Close();
                outputStream.Close();
                //回傳PDF檔案
                buf = outputStream.ToArray();
            }
            catch (Exception ex)
            {
                RESPONSE_MSG.message = "產生PDF發生錯誤,請洽資訊人員,錯誤訊息如下所示:" + ex.Message;
                RESPONSE_MSG.status  = RESPONSE_STATUS.EXCEPTION;
                LogTool.SaveLogMessage(ex, actionName, csName);
            }
            return(retunFile(buf));
        }
Пример #14
0
 /// <summary>
 /// Sets
 /// <see cref="iText.Kernel.Pdf.Navigation.PdfDestination"/>.
 /// </summary>
 /// <param name="destination">
 /// instance of
 /// <see cref="iText.Kernel.Pdf.Navigation.PdfDestination"/>.
 /// </param>
 internal virtual void SetDestination(PdfDestination destination)
 {
     this.destination = destination;
 }
Пример #15
0
 /// <summary>
 /// Adds
 /// <see cref="iText.Kernel.Pdf.Navigation.PdfDestination"/>
 /// for the outline,
 /// <c>Dest</c>
 /// key.
 /// </summary>
 /// <param name="destination">
 /// instance of
 /// <see cref="iText.Kernel.Pdf.Navigation.PdfDestination"/>.
 /// </param>
 public virtual void AddDestination(PdfDestination destination)
 {
     SetDestination(destination);
     content.Put(PdfName.Dest, destination.GetPdfObject());
 }
Пример #16
0
        static void GenDocument5(Dictionary <string, string> row)
        {
            string caseNo  = row["CaseNo"];
            string html    = File.ReadAllText("doc11.html");
            string NullStr = "&nbsp;";

            /***********************************************************************************************/
            string imgPath = PicPath + caseNo.Substring(0, 5) + "\\" + caseNo + "\\Media\\";

            html = html.Replace("@caseNo", "*" + caseNo + "-S03*");
            html = html.Replace("@IeokNo", row["IeokNo"]);
            html = html.Replace("@Unit", getUnit(row["OccurPoliceUnit"]));
            html = html.Replace("@ProcessNo", caseNo);
            //html = html.Replace("@OccurReport34_2", row["OccurReport34_2"]);
            html = html.Replace("@OccurReport34_2", row["OccurReport34_2"].Equals("") ? NullStr : row["OccurReport34_2"]);

            string sql = "select * from CasePerson where CaseNo = '" + caseNo + "' order by PersonSno ";
            List <Dictionary <string, string> > lsdy = ioCon.SelectDct(sql);

            if (lsdy.Count == 0)
            {
                return;
            }

            /***********************************************************************************************/
            string     tmpfil = filePath + caseNo + "_11.pdf";
            Document   doc    = new Document(PageSize.A4.Rotate(), 15, 15, 15, 15);
            FileStream fs     = new FileStream(tmpfil, FileMode.Create);
            PdfWriter  pdf    = PdfWriter.GetInstance(doc, fs);

            doc.Open();
            /***********************************************************************************************/

            for (int i = 1; i < 5; i++)
            {
                if (i > lsdy.Count)
                {
                    html = html.Replace("@PersonSno" + i, NullStr);
                    html = html.Replace("@PersonName" + i, NullStr);
                    html = html.Replace("@PersonFlag" + i, NullStr);
                    html = html.Replace("@IdNo" + i, NullStr);
                    html = html.Replace("@Birthday" + i, NullStr);
                    html = html.Replace("@Addr" + i, NullStr);
                    html = html.Replace("@Tel" + i, NullStr);
                    html = html.Replace("@Remark" + i, NullStr);
                }
                else
                {
                    Dictionary <string, string> col = lsdy[i - 1];
                    html = html.Replace("@PersonSno" + i, col["PersonSno"]);
                    html = html.Replace("@PersonName" + i, col["PersonCname"].Equals("") ? col["PersonEname"] : col["PersonCname"]);
                    html = html.Replace("@PersonFlag" + i, col["PersonFlag"]);
                    html = html.Replace("@IdNo" + i, col["IdNo"]);
                    //html = html.Replace("@Birthday" + i, getDateFrm(col["Birthday"], 4));
                    string dat = col["Birthday"];
                    if (!dat.Trim().Equals(""))
                    {
                        dat = dat.Substring(0, 3) + "年" + dat.Substring(3, 2) + "月" + dat.Substring(5, 2) + "日";
                    }
                    html = html.Replace("@Birthday" + i, dat);
                    html = html.Replace("@Addr" + i, col["Addr"]);
                    html = html.Replace("@Tel" + i, col["Tel2"] + "  " + col["Tel1"]);
                    html = html.Replace("@Remark" + i, col["Remark"]);
                }
            }

            string[] ss = new string[4] {
                "a", "b", "c", "d"
            };
            for (int i = 0; i < 4; i++)
            {
                if (i >= lsdy.Count)
                {
                    html = html.Replace("@OccurReport22" + ss[i], NullStr);
                    html = html.Replace("@OccurReport23" + ss[i], NullStr);
                    html = html.Replace("@OccurReport24" + ss[i], NullStr);
                    html = html.Replace("@OccurReport25" + ss[i], NullStr);
                    html = html.Replace("@OccurReport26" + ss[i], NullStr);
                    html = html.Replace("@OccurReport27" + ss[i], NullStr);
                    html = html.Replace("@OccurReport28" + ss[i], NullStr);
                    html = html.Replace("@OccurReport29" + ss[i], NullStr);
                    html = html.Replace("@OccurReport30" + ss[i], NullStr);
                    html = html.Replace("@OccurReport31" + ss[i], NullStr);
                    html = html.Replace("@OccurReport32" + ss[i], NullStr);
                    html = html.Replace("@OccurReport33_1" + ss[i], NullStr);
                    html = html.Replace("@OccurReport33_2" + ss[i], NullStr);
                    html = html.Replace("@OccurReport34_1" + ss[i], NullStr);
                    html = html.Replace("@OccurReport35" + ss[i], NullStr);
                    html = html.Replace("@OccurReport36" + ss[i], NullStr);
                    html = html.Replace("@OccurReport37" + ss[i], NullStr);
                }
                else
                {
                    Dictionary <string, string> col = lsdy[i];
                    html = html.Replace("@OccurReport22" + ss[i], col["OccurReport22"].Equals("") ? NullStr : col["OccurReport22"]);
                    html = html.Replace("@OccurReport23" + ss[i], col["OccurReport23"].Equals("") ? NullStr : col["OccurReport23"]);
                    html = html.Replace("@OccurReport24" + ss[i], col["OccurReport24"].Equals("") ? NullStr : col["OccurReport24"]);
                    html = html.Replace("@OccurReport25" + ss[i], col["OccurReport25"].Equals("") ? NullStr : col["OccurReport25"]);
                    html = html.Replace("@OccurReport26" + ss[i], col["OccurReport26"].Equals("") ? NullStr : col["OccurReport26"]);
                    html = html.Replace("@OccurReport27" + ss[i], col["OccurReport27"].Equals("") ? NullStr : col["OccurReport27"]);
                    html = html.Replace("@OccurReport28" + ss[i], col["OccurReport28"].Equals("") ? NullStr : col["OccurReport28"]);
                    html = html.Replace("@OccurReport29" + ss[i], col["OccurReport29"].Equals("") ? NullStr : col["OccurReport29"]);
                    html = html.Replace("@OccurReport30" + ss[i], col["OccurReport30"].Equals("") ? NullStr : col["OccurReport30"]);
                    html = html.Replace("@OccurReport31" + ss[i], col["OccurReport31"].Equals("") ? NullStr : col["OccurReport31"]);
                    html = html.Replace("@OccurReport32" + ss[i], col["OccurReport32"].Equals("") ? NullStr : col["OccurReport32"]);
                    html = html.Replace("@OccurReport33_1" + ss[i], col["OccurReport33_1"].Equals("") ? NullStr : col["OccurReport33_1"]);
                    html = html.Replace("@OccurReport33_2" + ss[i], col["OccurReport33_2"].Equals("") ? NullStr : col["OccurReport33_2"]);
                    html = html.Replace("@OccurReport34_1" + ss[i], col["OccurReport34_1"].Equals("") ? NullStr : col["OccurReport34_1"]);
                    html = html.Replace("@OccurReport35" + ss[i], col["OccurReport35"].Equals("") ? NullStr : col["OccurReport35"]);
                    html = html.Replace("@OccurReport36" + ss[i], col["OccurReport36"].Equals("") ? NullStr : col["OccurReport36"]);
                    html = html.Replace("@OccurReport37" + ss[i], col["OccurReport37"].Equals("") ? NullStr : col["OccurReport37"]);
                    //html = html.Replace("@OccurReport23" + ss[i], col["OccurReport22"]);
                    //html = html.Replace("@OccurReport23" + ss[i], col["OccurReport23"]);
                    //html = html.Replace("@OccurReport24" + ss[i], col["OccurReport24"]);
                    //html = html.Replace("@OccurReport25" + ss[i], col["OccurReport25"]);
                    //html = html.Replace("@OccurReport26" + ss[i], col["OccurReport26"]);
                    //html = html.Replace("@OccurReport27" + ss[i], col["OccurReport27"]);
                    //html = html.Replace("@OccurReport28" + ss[i], col["OccurReport28"]);
                    //html = html.Replace("@OccurReport29" + ss[i], col["OccurReport29"]);
                    //html = html.Replace("@OccurReport30" + ss[i], col["OccurReport30"]);
                    //html = html.Replace("@OccurReport31" + ss[i], col["OccurReport31"]);
                    //html = html.Replace("@OccurReport32" + ss[i], col["OccurReport32"]);
                    //html = html.Replace("@OccurReport33_1" + ss[i], col["OccurReport33_1"]);
                    //html = html.Replace("@OccurReport33_2" + ss[i], col["OccurReport33_2"]);
                    //html = html.Replace("@OccurReport34_1" + ss[i], col["OccurReport34_1"]);
                    //html = html.Replace("@OccurReport35" + ss[i], col["OccurReport35"]);
                    //html = html.Replace("@OccurReport36" + ss[i], col["OccurReport36"]);
                    //html = html.Replace("@OccurReport37" + ss[i], col["OccurReport37"]);
                }
            }

            string gifx = "";

            for (int i = 16; i < 38; i++)
            {
                gifx = GifPath + "no" + i + ".gif";
                html = html.Replace("@no" + i.ToString("00"), gifx);
            }
            string car = GifPath + "car.gif";

            html = html.Replace("@car", car);

            string mark = getPsnMark(row["ProcessId"]);

            html = html.Replace("@Mark1", MarkPath + mark);
            mark = getChfMark(row["CaseNo"]);
            html = html.Replace("@Mark2", MarkPath + mark);
            mark = getUntMark(row["OccurPoliceStation"], row["OccurPoliceUnit"]);
            html = html.Replace("@Mark3", MarkPath + mark);

            string codeMsg = caseNo + ";" + row["OccurPoliceUnit"] + ";" + row["OccurPoliceStation"] + ";";
            string qrCode  = RQCodePath + caseNo + ".png";

            codeMsg += row["ProcessId"] + ";10.116.1.219;" + addDate(0);
            makeQRcode(codeMsg, qrCode);

            html = html.Replace("@QRCode", qrCode);

            /***********************************************************************************************/
            byte[]       bytehtml = System.Text.Encoding.UTF8.GetBytes(html);
            MemoryStream mshtml   = new MemoryStream(bytehtml);

            byte[]       bytecss = System.Text.Encoding.UTF8.GetBytes(cssStr);
            MemoryStream mscss   = new MemoryStream(bytecss);

            XMLWorkerHelper.GetInstance().ParseXHtml(pdf, doc, mshtml, mscss);

            PdfDestination pdfDest = new PdfDestination(PdfDestination.XYZ, 0, doc.PageSize.Height, 1f);
            PdfAction      action  = PdfAction.GotoLocalPage(1, pdfDest, pdf);

            pdf.SetOpenAction(action);

            doc.Close();
            //EncryptPDF(tmpfil, filePath + row["ApplyNo"] + "_1.pdf", row["IdNo"]);
            //if (row["MailFlag1"] != "1") UpdateMailFlag(row["ApplyNo"], "1");
        }
Пример #17
0
        static void GenDocument1(Dictionary <string, string> row)
        {
            string caseNo = row["CaseNo"];
            string html   = File.ReadAllText("doc1.html");

            /***********************************************************************************************/
            string imgPath = PicPath + caseNo.Substring(0, 5) + "\\" + caseNo + "\\Media\\";

            html = html.Replace("@caseNo", "*" + caseNo + "-S01*");
            html = html.Replace("@IeokNo", row["IeokNo"]);
            html = html.Replace("@Unit", getUnit(row["OccurPoliceUnit"]));
            html = html.Replace("@ProcessNo", caseNo);
            string[] sts = new string[5];
            for (int i = 0; i < 5; i++)
            {
                sts[i] = "";
            }
            switch (row["CaseFlag"])
            {
            case "1": sts[1] = "V"; break;

            case "2": sts[2] = "V"; break;

            default: sts[3] = "V"; break;
            }
            html = html.Replace("@V1", sts[1]);
            html = html.Replace("@V2", sts[2]);
            html = html.Replace("@V3", sts[3]);

            string sql = "select a.*,b.FSPath,b.FName from CaseRepData a,CaseMediaFile b ";

            sql += "where a.CaseNo = b.CaseNo and a.DocFld13 = b.MediaSno ";
            sql += "and a.DocNm='現場圖' and  b.MediaNm='現場圖' ";
            sql += "and a.CaseNo='" + caseNo + "' order by a.DocSno";
            List <Dictionary <string, string> > lsdy = ioCon.SelectDct(sql);

            if (lsdy.Count == 0)
            {
                return;
            }

            /***********************************************************************************************/
            string     tmpfil = filePath + caseNo + "_04.pdf";
            Document   doc    = new Document(PageSize.A4.Rotate(), 15, 15, 15, 15);
            FileStream fs     = new FileStream(tmpfil, FileMode.Create);
            PdfWriter  pdf    = PdfWriter.GetInstance(doc, fs);

            doc.Open();
            /***********************************************************************************************/
            Dictionary <string, string> col = lsdy[0];

            html = html.Replace("@OccurTime", getDateFrm(row["OccurTime"], 3));
            html = html.Replace("@DocFld5", getLigthScp(col["DocFld5"]));
            string adr = "地點:" + getAddr(row);

            if (row["CaseType"] == "3")
            {
                adr += "<br/>[事後報案]";
            }

            html = html.Replace("@Pich", imgPath + col["FName"]);
            html = html.Replace("@Addr", getSkip(adr, 35));
            html = html.Replace("@Point", getPoint(col["DocFld14"]));
            html = html.Replace("@Per", getPer(col["DocFld4"], col["DocFld15"]));
            html = html.Replace("@DocFld6", col["DocFld7"]);
            html = html.Replace("@DocFld7", col["DocFld6"]);
            html = html.Replace("@Scrip", row["Course"].Replace("<", "&lt;").Replace(">", "&gt;"));
            html = html.Replace("@Remake", col["DocTxt2"]);
            html = html.Replace("@CreatDate", getDateFrm(col["DocDate1"], 4));
            string mark = getPsnMark(row["ProcessId"]);

            html = html.Replace("@Mark1", MarkPath + mark);
            mark = getChfMark(row["CaseNo"]);
            html = html.Replace("@Mark2", MarkPath + mark);
            mark = getUntMarkh(row["OccurPoliceStation"], row["OccurPoliceUnit"]);
            html = html.Replace("@Mark3", MarkPath + mark);
            /***********************************************************************************************/
            byte[]       bytehtml = System.Text.Encoding.UTF8.GetBytes(html);
            MemoryStream mshtml   = new MemoryStream(bytehtml);

            byte[]       bytecss = System.Text.Encoding.UTF8.GetBytes(cssStr);
            MemoryStream mscss   = new MemoryStream(bytecss);

            XMLWorkerHelper.GetInstance().ParseXHtml(pdf, doc, mshtml, mscss);

            PdfDestination pdfDest = new PdfDestination(PdfDestination.XYZ, 0, doc.PageSize.Height, 1f);
            PdfAction      action  = PdfAction.GotoLocalPage(1, pdfDest, pdf);

            pdf.SetOpenAction(action);

            doc.Close();
            //EncryptPDF(tmpfil, filePath + row["ApplyNo"] + "_1.pdf", row["IdNo"]);
            //if (row["MailFlag1"] != "1") UpdateMailFlag(row["ApplyNo"], "1");
        }
Пример #18
0
 /// <summary>Creates a GoToR action, or remote action (section 12.6.4.3 of ISO 32000-1).</summary>
 /// <param name="fileSpec">the file in which the destination shall be located</param>
 /// <param name="destination">the destination in the remote document to jump to</param>
 /// <returns>created action</returns>
 public static iText.Kernel.Pdf.Action.PdfAction CreateGoToR(PdfFileSpec fileSpec, PdfDestination destination
                                                             )
 {
     ValidateRemoteDestination(destination);
     return(new iText.Kernel.Pdf.Action.PdfAction().Put(PdfName.S, PdfName.GoToR).Put(PdfName.F, fileSpec.GetPdfObject
                                                                                          ()).Put(PdfName.D, destination.GetPdfObject()));
 }
Пример #19
0
 public virtual iText.Kernel.Pdf.Annot.PdfLinkAnnotation SetDestination(PdfDestination destination)
 {
     return(SetDestination(destination.GetPdfObject()));
 }
Пример #20
0
 /// <summary>Creates a GoToE action, or embedded file action (section 12.6.4.4 of ISO 32000-1).</summary>
 /// <param name="destination">the destination in the target to jump to</param>
 /// <param name="newWindow">
 /// if true, the destination document should be opened in a new window;
 /// if false, the destination document should replace the current document in the same window
 /// </param>
 /// <param name="targetDictionary">
 /// A target dictionary specifying path information to the target document.
 /// Each target dictionary specifies one element in the full path to the target and
 /// may have nested target dictionaries specifying additional elements
 /// </param>
 /// <returns>created action</returns>
 public static iText.Kernel.Pdf.Action.PdfAction CreateGoToE(PdfDestination destination, bool newWindow, PdfTarget
                                                             targetDictionary)
 {
     return(CreateGoToE(null, destination, newWindow, targetDictionary));
 }
Пример #21
0
 /// <summary>Creates a GoToE action, or embedded file action (section 12.6.4.4 of ISO 32000-1).</summary>
 /// <param name="fileSpec">The root document of the target relative to the root document of the source</param>
 /// <param name="destination">the destination in the target to jump to</param>
 /// <param name="newWindow">
 /// if true, the destination document should be opened in a new window;
 /// if false, the destination document should replace the current document in the same window
 /// </param>
 /// <param name="targetDictionary">
 /// A target dictionary specifying path information to the target document.
 /// Each target dictionary specifies one element in the full path to the target and
 /// may have nested target dictionaries specifying additional elements
 /// </param>
 /// <returns>created action</returns>
 public static iText.Kernel.Pdf.Action.PdfAction CreateGoToE(PdfFileSpec fileSpec, PdfDestination destination
                                                             , bool newWindow, PdfTarget targetDictionary)
 {
     iText.Kernel.Pdf.Action.PdfAction action = new iText.Kernel.Pdf.Action.PdfAction().Put(PdfName.S, PdfName.
                                                                                            GoToE).Put(PdfName.NewWindow, PdfBoolean.ValueOf(newWindow));
     if (fileSpec != null)
     {
         action.Put(PdfName.F, fileSpec.GetPdfObject());
     }
     if (destination != null)
     {
         ValidateRemoteDestination(destination);
         action.Put(PdfName.D, destination.GetPdfObject());
     }
     else
     {
         LogManager.GetLogger(typeof(iText.Kernel.Pdf.Action.PdfAction)).Warn(iText.IO.LogMessageConstant.EMBEDDED_GO_TO_DESTINATION_NOT_SPECIFIED
                                                                              );
     }
     if (targetDictionary != null)
     {
         action.Put(PdfName.T, targetDictionary.GetPdfObject());
     }
     return(action);
 }
Пример #22
0
 public virtual iText.Kernel.Pdf.PdfCatalog SetOpenAction(PdfDestination destination)
 {
     return(Put(PdfName.OpenAction, destination.GetPdfObject()));
 }
Пример #23
0
		private void ProcessDestination(PdfDestination pdfDestination)
		{
			ScrollToPage(pdfDestination.PageIndex);
			InvalidateVisual();
		}
Пример #24
0
        /// <summary>
        ///     <param name="htmlText"></param>
        ///     將Html文字輸出到PDF檔裡
        /// </summary>
        /// <returns></returns>
        public byte[] ConvertHtmlTextToPDF(string htmlText)
        {
            if (string.IsNullOrEmpty(htmlText))
            {
                return(null);
            }
            //避免當htmlText無任何html tag標籤的純文字時,轉PDF時會掛掉,所以一律加上<p>標籤
            //htmlText = "<p>" + htmlText + "</p>";

            var outputStream = new MemoryStream();               //要把PDF寫到哪個串流
            var data         = Encoding.UTF8.GetBytes(htmlText); //字串轉成byte[]
            var msInput      = new MemoryStream(data);

            var doc    = new Document(); //要寫PDF的文件,建構子沒填的話預設直式A4
            var writer = PdfWriter.GetInstance(doc, outputStream);
            //指定文件預設開檔時的縮放為100%
            var pdfDest = new PdfDestination(PdfDestination.XYZ, 0, doc.PageSize.Height, 1f);

            //開啟Document文件
            doc.Open();
            //使用XMLWorkerHelper把Html parse到PDF檔裡
            //try
            //{
            //XMLWorkerHelper.GetInstance()
            //    .ParseXHtml(writer, doc, msInput, null, Encoding.UTF8, new UnicodeFontFactory());
            ////}
            //catch(Exception e)
            //{ }
            ////將pdfDest設定的資料寫到PDF檔
            //PdfAction action = PdfAction.GotoLocalPage(1, pdfDest, writer);
            //writer.SetOpenAction(action);

            var font   = new Font(baseFont, 15);
            var table1 = new PdfPTable(12);                   //创建表格实例4列

            int[] a = { 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 2, 2 }; //设置列宽比例
            table1.SetWidths(a);
            table1.TotalWidth  = 500;
            table1.LockedWidth = true;
            //电子流程卡标题
            var para = new Paragraph("电子流程卡查询", font);
            var cell = new PdfPCell(para);

            cell.MinimumHeight       = 30;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cell.Colspan             = 12;
            cell.BackgroundColor     = BaseColor.GRAY;
            table1.AddCell(cell);

            //总成信息标题
            font = new Font(baseFont, 10);
            para = new Paragraph("总成信息", font);
            cell = new PdfPCell(para);
            cell.MinimumHeight       = 15;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cell.Colspan             = 12;
            cell.BackgroundColor     = BaseColor.LIGHT_GRAY;
            table1.AddCell(cell);

            para = new Paragraph("图号/零件号", font);
            cell = new PdfPCell(para);
            cell.MinimumHeight       = 17;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cell.Colspan             = 2;
            table1.AddCell(cell);

            para = new Paragraph("图号/零件号内容", font);
            cell = new PdfPCell(para);
            cell.MinimumHeight       = 17;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cell.Colspan             = 6;
            table1.AddCell(cell);

            para = new Paragraph("物料编号", font);
            cell = new PdfPCell(para);
            cell.MinimumHeight       = 17;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            table1.AddCell(cell);

            para = new Paragraph("物料编号内容", font);
            cell = new PdfPCell(para);
            cell.MinimumHeight       = 17;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cell.Colspan             = 3;
            table1.AddCell(cell);

            para = new Paragraph("总成名称", font);
            cell = new PdfPCell(para);
            cell.MinimumHeight       = 17;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cell.Colspan             = 2;
            table1.AddCell(cell);

            para = new Paragraph("总成名称内容", font);
            cell = new PdfPCell(para);
            cell.MinimumHeight       = 17;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cell.Colspan             = 7;
            table1.AddCell(cell);

            para = new Paragraph("质量状态", font);
            cell = new PdfPCell(para);
            cell.MinimumHeight       = 17;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            table1.AddCell(cell);

            para = new Paragraph("质量状态内容", font);
            cell = new PdfPCell(para);
            cell.MinimumHeight       = 17;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cell.Colspan             = 2;
            table1.AddCell(cell);

            para = new Paragraph("SN", font);
            cell = new PdfPCell(para);
            cell.MinimumHeight       = 17;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cell.Colspan             = 2;
            table1.AddCell(cell);
            para = new Paragraph("SN内容", font);
            cell = new PdfPCell(para);
            cell.MinimumHeight       = 17;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cell.Colspan             = 10;
            table1.AddCell(cell);
            para = new Paragraph("出厂编号", font);
            cell = new PdfPCell(para);
            cell.MinimumHeight       = 17;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cell.Colspan             = 2;
            table1.AddCell(cell);

            para = new Paragraph("出厂编号内容", font);
            cell = new PdfPCell(para);
            cell.MinimumHeight       = 17;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cell.Colspan             = 7;
            table1.AddCell(cell);

            para = new Paragraph("物料系列", font);
            cell = new PdfPCell(para);
            cell.MinimumHeight       = 17;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            table1.AddCell(cell);

            para = new Paragraph("物料系列内容", font);
            cell = new PdfPCell(para);
            cell.MinimumHeight       = 17;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cell.Colspan             = 2;
            table1.AddCell(cell);

            para = new Paragraph("当前群组", font);
            cell = new PdfPCell(para);
            cell.MinimumHeight       = 17;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cell.Colspan             = 2;
            table1.AddCell(cell);

            para = new Paragraph("当前群组内容", font);
            cell = new PdfPCell(para);
            cell.MinimumHeight       = 17;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cell.Colspan             = 7;
            table1.AddCell(cell);

            para = new Paragraph("生产方式", font);
            cell = new PdfPCell(para);
            cell.MinimumHeight       = 17;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            table1.AddCell(cell);

            para = new Paragraph("生产方式内容", font);
            cell = new PdfPCell(para);
            cell.MinimumHeight       = 17;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cell.Colspan             = 2;
            table1.AddCell(cell);

            //扫描信息标题
            font = new Font(baseFont, 10);
            para = new Paragraph("扫描信息", font);
            cell = new PdfPCell(para);
            cell.MinimumHeight       = 17;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cell.Colspan             = 12;
            cell.BackgroundColor     = BaseColor.LIGHT_GRAY;
            table1.AddCell(cell);

            para = new Paragraph("序号", font);
            cell = new PdfPCell(para);
            cell.MinimumHeight       = 17;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            table1.AddCell(cell);

            para = new Paragraph("时间", font);
            cell = new PdfPCell(para);
            cell.MinimumHeight       = 17;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cell.Colspan             = 2;
            table1.AddCell(cell);

            para = new Paragraph("扫描点", font);
            cell = new PdfPCell(para);
            cell.MinimumHeight       = 17;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cell.Colspan             = 6;
            table1.AddCell(cell);

            para = new Paragraph("员工", font);
            cell = new PdfPCell(para);
            cell.MinimumHeight       = 17;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            table1.AddCell(cell);

            para = new Paragraph("质量", font);
            cell = new PdfPCell(para);
            cell.MinimumHeight       = 17;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            table1.AddCell(cell);

            para = new Paragraph("生产状态", font);
            cell = new PdfPCell(para);
            cell.MinimumHeight       = 17;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            table1.AddCell(cell);

            for (var index = 0; index < 5; index++)
            {
                para = new Paragraph((index + 1).ToString(), font);
                cell = new PdfPCell(para);
                cell.MinimumHeight       = 17;
                cell.HorizontalAlignment = Element.ALIGN_CENTER;
                cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
                table1.AddCell(cell);

                para = new Paragraph("时间" + (index + 1), font);
                cell = new PdfPCell(para);
                cell.MinimumHeight       = 17;
                cell.HorizontalAlignment = Element.ALIGN_CENTER;
                cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
                cell.Colspan             = 2;
                table1.AddCell(cell);

                para = new Paragraph("扫描点" + (index + 1), font);
                cell = new PdfPCell(para);
                cell.MinimumHeight       = 17;
                cell.HorizontalAlignment = Element.ALIGN_CENTER;
                cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
                cell.Colspan             = 6;
                table1.AddCell(cell);

                para = new Paragraph("员工" + (index + 1), font);
                cell = new PdfPCell(para);
                cell.MinimumHeight       = 17;
                cell.HorizontalAlignment = Element.ALIGN_CENTER;
                cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
                table1.AddCell(cell);

                para = new Paragraph("质量" + (index + 1), font);
                cell = new PdfPCell(para);
                cell.MinimumHeight       = 17;
                cell.HorizontalAlignment = Element.ALIGN_CENTER;
                cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
                table1.AddCell(cell);

                para = new Paragraph("生产状态" + (index + 1), font);
                cell = new PdfPCell(para);
                cell.MinimumHeight       = 17;
                cell.HorizontalAlignment = Element.ALIGN_CENTER;
                cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
                table1.AddCell(cell);
            }

            //扫描信息标题
            font = new Font(baseFont, 10);
            para = new Paragraph("装配信息", font);
            cell = new PdfPCell(para);
            cell.MinimumHeight       = 17;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cell.Colspan             = 12;
            cell.BackgroundColor     = BaseColor.LIGHT_GRAY;
            table1.AddCell(cell);

            para = new Paragraph("序号", font);
            cell = new PdfPCell(para);
            cell.MinimumHeight       = 17;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            table1.AddCell(cell);

            para = new Paragraph("应装部件", font);
            cell = new PdfPCell(para);
            cell.MinimumHeight       = 17;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cell.Colspan             = 2;
            table1.AddCell(cell);

            para = new Paragraph("实装部件", font);
            cell = new PdfPCell(para);
            cell.MinimumHeight       = 17;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cell.Colspan             = 2;
            table1.AddCell(cell);

            para = new Paragraph("部件追溯码", font);
            cell = new PdfPCell(para);
            cell.MinimumHeight       = 17;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cell.Colspan             = 2;
            table1.AddCell(cell);

            para = new Paragraph("追溯", font);
            cell = new PdfPCell(para);
            cell.MinimumHeight       = 17;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            table1.AddCell(cell);

            para = new Paragraph("差异件", font);
            cell = new PdfPCell(para);
            cell.MinimumHeight       = 17;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            table1.AddCell(cell);

            para = new Paragraph("拆散", font);
            cell = new PdfPCell(para);
            cell.MinimumHeight       = 17;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            table1.AddCell(cell);

            para = new Paragraph("装配时间", font);
            cell = new PdfPCell(para);
            cell.MinimumHeight       = 17;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cell.Colspan             = 2;
            table1.AddCell(cell);

            for (var index = 0; index < 5; index++)
            {
                para = new Paragraph((index + 1).ToString(), font);
                cell = new PdfPCell(para);
                cell.MinimumHeight       = 17;
                cell.HorizontalAlignment = Element.ALIGN_CENTER;
                cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
                table1.AddCell(cell);

                para = new Paragraph("应装部件" + (index + 1), font);
                cell = new PdfPCell(para);
                cell.MinimumHeight       = 17;
                cell.HorizontalAlignment = Element.ALIGN_CENTER;
                cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
                cell.Colspan             = 2;
                table1.AddCell(cell);

                para = new Paragraph("实装部件" + (index + 1), font);
                cell = new PdfPCell(para);
                cell.MinimumHeight       = 17;
                cell.HorizontalAlignment = Element.ALIGN_CENTER;
                cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
                cell.Colspan             = 2;
                table1.AddCell(cell);

                para = new Paragraph("部件追溯码" + (index + 1), font);
                cell = new PdfPCell(para);
                cell.MinimumHeight       = 17;
                cell.HorizontalAlignment = Element.ALIGN_CENTER;
                cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
                cell.Colspan             = 2;
                table1.AddCell(cell);

                para = new Paragraph("追溯" + (index + 1), font);
                cell = new PdfPCell(para);
                cell.MinimumHeight       = 17;
                cell.HorizontalAlignment = Element.ALIGN_CENTER;
                cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
                table1.AddCell(cell);

                para = new Paragraph("差异件" + (index + 1), font);
                cell = new PdfPCell(para);
                cell.MinimumHeight       = 17;
                cell.HorizontalAlignment = Element.ALIGN_CENTER;
                cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
                table1.AddCell(cell);

                para = new Paragraph("拆散" + (index + 1), font);
                cell = new PdfPCell(para);
                cell.MinimumHeight       = 17;
                cell.HorizontalAlignment = Element.ALIGN_CENTER;
                cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
                table1.AddCell(cell);

                para = new Paragraph("装配时间" + (index + 1), font);
                cell = new PdfPCell(para);
                cell.MinimumHeight       = 17;
                cell.HorizontalAlignment = Element.ALIGN_CENTER;
                cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
                cell.Colspan             = 2;
                table1.AddCell(cell);
            }

            //制造参数信息
            font = new Font(baseFont, 10);
            para = new Paragraph("制造参数信息", font);
            cell = new PdfPCell(para);
            cell.MinimumHeight       = 17;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cell.Colspan             = 12;
            cell.BackgroundColor     = BaseColor.LIGHT_GRAY;
            table1.AddCell(cell);

            para = new Paragraph("序号", font);
            cell = new PdfPCell(para);
            cell.MinimumHeight       = 17;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            table1.AddCell(cell);

            para = new Paragraph("应采集制造参数", font);
            cell = new PdfPCell(para);
            cell.MinimumHeight       = 17;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cell.Colspan             = 2;
            table1.AddCell(cell);

            para = new Paragraph("编号", font);
            cell = new PdfPCell(para);
            cell.MinimumHeight       = 17;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            table1.AddCell(cell);

            para = new Paragraph("实采集制造参数", font);
            cell = new PdfPCell(para);
            cell.MinimumHeight       = 17;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cell.Colspan             = 2;
            table1.AddCell(cell);

            para = new Paragraph("拧紧值", font);
            cell = new PdfPCell(para);
            cell.MinimumHeight       = 17;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            table1.AddCell(cell);

            para = new Paragraph("角度值", font);
            cell = new PdfPCell(para);
            cell.MinimumHeight       = 17;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            table1.AddCell(cell);

            para = new Paragraph("结果", font);
            cell = new PdfPCell(para);
            cell.MinimumHeight       = 17;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            table1.AddCell(cell);

            para = new Paragraph("拆散", font);
            cell = new PdfPCell(para);
            cell.MinimumHeight       = 17;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            table1.AddCell(cell);

            para = new Paragraph("时间", font);
            cell = new PdfPCell(para);
            cell.MinimumHeight       = 17;
            cell.HorizontalAlignment = Element.ALIGN_CENTER;
            cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
            cell.Colspan             = 2;
            table1.AddCell(cell);

            for (var index = 0; index < 5; index++)
            {
                para = new Paragraph((index + 1).ToString(), font);
                cell = new PdfPCell(para);
                cell.MinimumHeight       = 17;
                cell.HorizontalAlignment = Element.ALIGN_CENTER;
                cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
                table1.AddCell(cell);

                para = new Paragraph("应采集制造参数" + (index + 1), font);
                cell = new PdfPCell(para);
                cell.MinimumHeight       = 17;
                cell.HorizontalAlignment = Element.ALIGN_CENTER;
                cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
                cell.Colspan             = 2;
                table1.AddCell(cell);

                para = new Paragraph("编号" + (index + 1), font);
                cell = new PdfPCell(para);
                cell.MinimumHeight       = 17;
                cell.HorizontalAlignment = Element.ALIGN_CENTER;
                cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
                table1.AddCell(cell);

                para = new Paragraph("实采集制造参数" + (index + 1), font);
                cell = new PdfPCell(para);
                cell.MinimumHeight       = 17;
                cell.HorizontalAlignment = Element.ALIGN_CENTER;
                cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
                cell.Colspan             = 2;
                table1.AddCell(cell);

                para = new Paragraph("拧紧值" + (index + 1), font);
                cell = new PdfPCell(para);
                cell.MinimumHeight       = 17;
                cell.HorizontalAlignment = Element.ALIGN_CENTER;
                cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
                table1.AddCell(cell);

                para = new Paragraph("角度值" + (index + 1), font);
                cell = new PdfPCell(para);
                cell.MinimumHeight       = 17;
                cell.HorizontalAlignment = Element.ALIGN_CENTER;
                cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
                table1.AddCell(cell);

                para = new Paragraph("结果" + (index + 1), font);
                cell = new PdfPCell(para);
                cell.MinimumHeight       = 17;
                cell.HorizontalAlignment = Element.ALIGN_CENTER;
                cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
                table1.AddCell(cell);

                para = new Paragraph("拆散" + (index + 1), font);
                cell = new PdfPCell(para);
                cell.MinimumHeight       = 17;
                cell.HorizontalAlignment = Element.ALIGN_CENTER;
                cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
                table1.AddCell(cell);

                para = new Paragraph("时间" + (index + 1), font);
                cell = new PdfPCell(para);
                cell.MinimumHeight       = 17;
                cell.HorizontalAlignment = Element.ALIGN_CENTER;
                cell.VerticalAlignment   = Element.ALIGN_MIDDLE;
                cell.Colspan             = 2;
                table1.AddCell(cell);
            }

            doc.Add(table1);

            doc.Close();
            msInput.Close();
            outputStream.Close();
            //回傳PDF檔案
            return(outputStream.ToArray());
        }