当前位置: 首页>>代码示例>>C#>>正文


C# Document.Close方法代码示例

本文整理汇总了C#中System.Windows.Forms.Document.Close方法的典型用法代码示例。如果您正苦于以下问题:C# Document.Close方法的具体用法?C# Document.Close怎么用?C# Document.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.Document的用法示例。


在下文中一共展示了Document.Close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: btnCreatePdf_Click

        private void btnCreatePdf_Click(object sender, EventArgs e)
        {
            // create a PDF document
            Document document = new Document();

            // set the license key
            document.LicenseKey = "B4mYiJubiJiInIaYiJuZhpmahpGRkZE=";

            // add a page to the PDF document
            PdfPage firstPage = document.AddPage();

            string logoImagePath = System.IO.Path.Combine(Application.StartupPath, @"..\..\img\evologo-250.png");
            string certificateFilePath = System.IO.Path.Combine(Application.StartupPath, @"..\..\certificates\evopdf.pfx");

            PdfFont pdfFont = document.Fonts.Add(new Font("Arial", 10, FontStyle.Regular, GraphicsUnit.Point));
            TextElement descriptionTextElement = new TextElement(0, 0,
                "A digital signature was applied on the logo image below. Click on the image to see the signature details", pdfFont);
            AddElementResult addResult = firstPage.AddElement(descriptionTextElement);

            // create the area where the digital signature will be displayed in the PDF document
            // in this sample the area is a logo image but it could be anything else
            ImageElement logoElement = new ImageElement(0, addResult.EndPageBounds.Bottom + 10, 100, logoImagePath);
            addResult = firstPage.AddElement(logoElement);

            //get the #PKCS 12 certificate from file
            DigitalCertificatesCollection certificates = DigitalCertificatesStore.GetCertificates(certificateFilePath, "evopdf");
            DigitalCertificate certificate = certificates[0];

            // create the digital signature over the logo image element
            DigitalSignatureElement signature = new DigitalSignatureElement(addResult.EndPageBounds, certificate);
            signature.Reason = "Protect the document from unwanted changes";
            signature.ContactInfo = "The contact email is [email protected]";
            signature.Location = "Development server";
            firstPage.AddElement(signature);

            string outFilePath = System.IO.Path.Combine(Application.StartupPath, "DigitalSignature.pdf");

            // save the PDF document to disk
            document.Save(outFilePath);

            // close the PDF document to release the resources
            document.Close();

            DialogResult dr = MessageBox.Show("Open the saved file in an external viewer?", "Open Rendered File", MessageBoxButtons.YesNo);
            if (dr == DialogResult.Yes)
            {
                try
                {
                    System.Diagnostics.Process.Start(outFilePath);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    return;
                }
            }
        }
开发者ID:ParallaxIT,项目名称:tdb-ws,代码行数:57,代码来源:DigitalSignature.cs

示例2: ExtractTextFromImage

 private string ExtractTextFromImage(string filePath)
 {
     Document modiDocument = new Document();
     modiDocument.Create(filePath);
     modiDocument.OCR(MiLANGUAGES.miLANG_ENGLISH);
     MODI.Image modiImage = (modiDocument.Images[0] as MODI.Image);
     string extractedText = modiImage.Layout.Text;
     modiDocument.Close();
     return extractedText;
 }
开发者ID:bakasura980,项目名称:EVOTE-PROJECT,代码行数:10,代码来源:Form1.cs

示例3: btnCreatePdf_Click

        private void btnCreatePdf_Click(object sender, EventArgs e)
        {
            // create a PDF document
            Document document = new Document();

            // set the license key
            document.LicenseKey = "B4mYiJubiJiInIaYiJuZhpmahpGRkZE=";

            // add a page to the PDF document
            PdfPage firstPage = document.AddPage();

            string imagesPath = System.IO.Path.Combine(Application.StartupPath, @"..\..\Img");

            // display image in the available space in page and with a auto determined height to keep the aspect ratio
            ImageElement imageElement1 = new ImageElement(0, 0, System.IO.Path.Combine(imagesPath, "evologo-250.png"));
            AddElementResult addResult = firstPage.AddElement(imageElement1);

            // display image with the specified width and the height auto determined to keep the aspect ratio
            // the images is displayed to the right of the previous image and the bounds of the image inside the current page
            // are taken from the AddElementResult object
            ImageElement imageElement2 = new ImageElement(addResult.EndPageBounds.Right + 10, 0, 100,
                    System.IO.Path.Combine(imagesPath, "evologo-250.png"));
            addResult = firstPage.AddElement(imageElement2);

            // Display image with the specified width and the specified height. It is possible for the image to not preserve the aspect ratio
            // The images is displayed to the right of the previous image and the bounds of the image inside the current page
            // are taken from the AddElementResult object
            ImageElement imageElement3 = new ImageElement(addResult.EndPageBounds.Right + 10, 0, 100, 50,
                    System.IO.Path.Combine(imagesPath, "evologo-250.png"));
            addResult = firstPage.AddElement(imageElement3);

            string outFilePath = System.IO.Path.Combine(Application.StartupPath, "ImageElementDemo.pdf");

            // save the PDF document to disk
            document.Save(outFilePath);

            // close the PDF document to release the resources
            document.Close();

            DialogResult dr = MessageBox.Show("Open the saved file in an external viewer?", "Open Rendered File", MessageBoxButtons.YesNo);
            if (dr == DialogResult.Yes)
            {
                try
                {
                    System.Diagnostics.Process.Start(outFilePath);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    return;
                }
            }
        }
开发者ID:ParallaxIT,项目名称:tdb-ws,代码行数:53,代码来源:ImageElementDemo.cs

示例4: ImprimirEtiquetas

        public void ImprimirEtiquetas(String Titulo, String Modelo, String Gramos, String ID)
        {
            String sPath = "C:\\Users\\Adan Cervera\\Desktop\\TestGit\\TestGit\\POS.View\\VentasView\\CONTENEDORES.lbx";
            bpac.Document objDoc = new Document();
            objDoc = new Document();
            if (objDoc.Open(sPath) != null)
            {
                objDoc.GetObject("objTitulo").Text = Titulo;
                objDoc.GetObject("modelo").Text = Modelo;
                objDoc.GetObject("gramos").Text = Gramos;
                objDoc.GetObject("codebar").Text = ID.ToString() + '-' + Gramos;

                objDoc.StartPrint("", bpac.PrintOptionConstants.bpoDefault);
                objDoc.PrintOut(1, bpac.PrintOptionConstants.bpoDefault);
                objDoc.EndPrint();
                objDoc.Close();
            }
        }
开发者ID:Chepzalcoatl,项目名称:TestGit,代码行数:18,代码来源:frmContenedoresList.cs

示例5: CloseDocument

 private void CloseDocument(Document document)
 {
     if (delayedCodeBehindClose)
     {
         documentCloseTimer = CreateTimer(() =>
             {
                 documentCloseTimer = null;
                 document.Close();
             }, 500);
     }
     else
     {
         document.Close();
     }
 }
开发者ID:paulroho,项目名称:SpecFlow.VisualStudio,代码行数:15,代码来源:CommandBasedTestRunnerGateway.cs

示例6: btnConvert_Click


//.........这里部分代码省略.........
                AddElementResult addResult;

                // Get the specified location and size of the rendered content
                // A negative value for width and height means to auto determine
                // The auto determined width is the available width in the PDF page
                // and the auto determined height is the height necessary to render all the content
                float xLocation = float.Parse(textBoxXLocation.Text.Trim());
                float yLocation = float.Parse(textBoxYLocation.Text.Trim());
                float width = float.Parse(textBoxWidth.Text.Trim());
                float height = float.Parse(textBoxHeight.Text.Trim());

                if (radioConvertToSelectablePDF.Checked)
                {
                    // convert HTML to PDF
                    HtmlToPdfElement htmlToPdfElement;

                    // convert a URL to PDF
                    string urlToConvert = textBoxWebPageURL.Text.Trim();

                    htmlToPdfElement = new HtmlToPdfElement(xLocation, yLocation, width, height, urlToConvert);

                    //optional settings for the HTML to PDF converter
                    htmlToPdfElement.FitWidth = cbFitWidth.Checked;
                    htmlToPdfElement.EmbedFonts = cbEmbedFonts.Checked;
                    htmlToPdfElement.LiveUrlsEnabled = cbLiveLinks.Checked;
                    htmlToPdfElement.JavaScriptEnabled = cbScriptsEnabled.Checked;
                    htmlToPdfElement.PdfBookmarkOptions.HtmlElementSelectors = cbBookmarks.Checked ? new string[] { "H1", "H2" } : null;

                    // add theHTML to PDF converter element to page
                    addResult = page.AddElement(htmlToPdfElement);
                }
                else
                {
                    HtmlToImageElement htmlToImageElement;

                    // convert HTML to image and add image to PDF document

                    // convert a URL to PDF
                    string urlToConvert = textBoxWebPageURL.Text.Trim();

                    htmlToImageElement = new HtmlToImageElement(xLocation, yLocation, width, height, urlToConvert);

                    //optional settings for the HTML to PDF converter
                    htmlToImageElement.FitWidth = cbFitWidth.Checked;
                    htmlToImageElement.LiveUrlsEnabled = cbLiveLinks.Checked;
                    htmlToImageElement.JavaScriptEnabled = cbScriptsEnabled.Checked;
                    htmlToImageElement.PdfBookmarkOptions.HtmlElementSelectors = cbBookmarks.Checked ? new string[] { "H1", "H2" } : null;

                    addResult = page.AddElement(htmlToImageElement);
                }

                if (cbAdditionalContent.Checked)
                {
                    // The code below can be used add some other elements right under the conversion result
                    // like texts or another HTML to PDF conversion

                    // add a text element right under the HTML to PDF document
                    PdfPage endPage = document.Pages[addResult.EndPageIndex];
                    TextElement nextTextElement = new TextElement(0, addResult.EndPageBounds.Bottom + 10, "Below there is another HTML to PDF Element", font);
                    nextTextElement.ForeColor = Color.Green;
                    addResult = endPage.AddElement(nextTextElement);

                    // add another HTML to PDF converter element right under the text element
                    endPage = document.Pages[addResult.EndPageIndex];
                    HtmlToPdfElement nextHtmlToPdfElement = new HtmlToPdfElement(0, addResult.EndPageBounds.Bottom + 10, "http://www.google.com");
                    addResult = endPage.AddElement(nextHtmlToPdfElement);
                }

                // save the PDF document to disk
                document.Save(outFilePath);

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }
            finally
            {
                // close the PDF document to release the resources
                if (document != null)
                    document.Close();

                this.Cursor = Cursors.Arrow;
            }

            DialogResult dr = MessageBox.Show("Open the saved file in an external viewer?", "Open Rendered File", MessageBoxButtons.YesNo);
            if (dr == DialogResult.Yes)
            {
                try
                {
                    System.Diagnostics.Process.Start(outFilePath);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    return;
                }
            }
        }
开发者ID:ParallaxIT,项目名称:tdb-ws,代码行数:101,代码来源:HtmlToPdfElementDemo.cs

示例7: btnCreatePdf_Click


//.........这里部分代码省略.........
                        System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point);

            // Create a Sim Sun .NET font of 10 points
            System.Drawing.Font ttfCJKFont = new System.Drawing.Font("SimSun", 10,
                        System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);

            // Create the PDF fonts based on the .NET true type fonts
            PdfFont newTimesFont = document.AddFont(ttfFont);
            PdfFont newTimesFontItalic = document.AddFont(ttfFontItalic);
            PdfFont newTimesFontBold = document.AddFont(ttfFontBold);
            PdfFont newTimesFontBoldItalic = document.AddFont(ttfFontBoldItalic);

            // Create the embedded PDF fonts based on the .NET true type fonts
            PdfFont newTimesEmbeddedFont = document.AddFont(ttfFont, true);
            PdfFont newTimesItalicEmbeddedFont = document.AddFont(ttfFontItalic, true);
            PdfFont newTimesBoldEmbeddedFont = document.AddFont(ttfFontBold, true);
            PdfFont newTimesBoldItalicEmbeddedFont = document.AddFont(ttfFontBoldItalic, true);

            PdfFont cjkEmbeddedFont = document.AddFont(ttfCJKFont, true);

            // Create a standard Times New Roman Type 1 Font
            PdfFont stdTimesFont = document.AddFont(StdFontBaseFamily.TimesRoman);
            PdfFont stdTimesFontItalic = document.AddFont(StdFontBaseFamily.TimesItalic);
            PdfFont stdTimesFontBold = document.AddFont(StdFontBaseFamily.TimesBold);
            PdfFont stdTimesFontBoldItalic = document.AddFont(StdFontBaseFamily.TimesBoldItalic);

            // Create CJK standard Type 1 fonts
            PdfFont cjkJapaneseStandardFont = document.AddFont(StandardCJKFont.HeiseiKakuGothicW5);
            PdfFont cjkChineseTraditionalStandardFont = document.AddFont(StandardCJKFont.MonotypeHeiMedium);

            // Add text elements to the document

            TextElement trueTypeText = new TextElement(0, 10, "True Type Fonts Demo:", newTimesFontBold);
            AddElementResult addResult = firstPage.AddElement(trueTypeText);

            // Create the text element
            TextElement textElement1 = new TextElement(20, addResult.EndPageBounds.Bottom + 10, "Hello World !!!!", newTimesFont);
            // Add element to page. The result of adding the text element is stored into the addResult object
            // which can be used to get information about the rendered size in PDF page.
            addResult = firstPage.AddElement(textElement1);

            // Add another element 5 points below the text above. The bottom of the text above is taken from the AddElementResult object
            // set the font size
            newTimesFontItalic.Size = 15;
            TextElement textElement2 = new TextElement(20, addResult.EndPageBounds.Bottom + 5, "Hello World !!!!", newTimesFontItalic);
            textElement2.ForeColor = System.Drawing.Color.Green;
            addResult = firstPage.AddElement(textElement2);

            newTimesFontBoldItalic.Size = 20;
            TextElement textElement3 = new TextElement(20, addResult.EndPageBounds.Bottom + 5, "Hello World !!!!", newTimesFontBoldItalic);
            textElement3.ForeColor = System.Drawing.Color.Blue;
            addResult = firstPage.AddElement(textElement3);

            TextElement stdTypeText = new TextElement(0, addResult.EndPageBounds.Bottom + 10, "Standard PDF Fonts Demo:", newTimesFontBold);
            addResult = firstPage.AddElement(stdTypeText);

            TextElement textElement4 = new TextElement(20, addResult.EndPageBounds.Bottom + 10, "Hello World !!!!", stdTimesFont);
            addResult = firstPage.AddElement(textElement4);

            stdTimesFontItalic.Size = 15;
            TextElement textElement5 = new TextElement(20, addResult.EndPageBounds.Bottom + 5, "Hello World !!!!", stdTimesFontItalic);
            textElement5.ForeColor = System.Drawing.Color.Green;
            addResult = firstPage.AddElement(textElement5);

            stdTimesFontBoldItalic.Size = 20;
            TextElement textElement6 = new TextElement(20, addResult.EndPageBounds.Bottom + 5, "Hello World !!!!", stdTimesFontBoldItalic);
            textElement6.ForeColor = System.Drawing.Color.Blue;
            addResult = firstPage.AddElement(textElement6);

            // embedded true type fonts

            TextElement embeddedTtfText = new TextElement(0, addResult.EndPageBounds.Bottom + 10, "Embedded True Type Fonts Demo:", newTimesFontBold);
            addResult = firstPage.AddElement(embeddedTtfText);

            // russian text
            TextElement textElement8 = new TextElement(20, addResult.EndPageBounds.Bottom + 5, "Появление на свет!!", newTimesEmbeddedFont);
            addResult = firstPage.AddElement(textElement8);

            string outFilePath = System.IO.Path.Combine(Application.StartupPath, "TextsAndFontsDemo.pdf");

            // save the PDF document to disk
            document.Save(outFilePath);

            // close the PDF document to release the resources
            document.Close();

            DialogResult dr = MessageBox.Show("Open the saved file in an external viewer?", "Open Rendered File", MessageBoxButtons.YesNo);
            if (dr == DialogResult.Yes)
            {
                try
                {
                    System.Diagnostics.Process.Start(outFilePath);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    return;
                }
            }
        }
开发者ID:ParallaxIT,项目名称:tdb-ws,代码行数:101,代码来源:TextAndFonts.cs

示例8: ImprimirEtiqueta

        private static void ImprimirEtiqueta(Int32 CodigoBarras, String Titulo, String Descripcion)
        {
            String sPath = "C:\\Users\\Adan Cervera\\Desktop\\TestGit\\TestGit\\POS.View\\VentasView\\RECARGAS.lbx";
            Document objDoc = new Document();
            objDoc = new Document();
            if (objDoc.Open(sPath) != null)
            {
                objDoc.GetObject("codebar").Text = CodigoBarras.ToString();
                objDoc.GetObject("modelo").Text = Titulo;
                objDoc.GetObject("marca").Text = Descripcion;

                objDoc.StartPrint("", bpac.PrintOptionConstants.bpoDefault);
                objDoc.PrintOut(1, bpac.PrintOptionConstants.bpoDefault);
                objDoc.EndPrint();
                objDoc.Close();
            }
        }
开发者ID:Chepzalcoatl,项目名称:TestGit,代码行数:17,代码来源:frmPOS.cs

示例9: CloseWordApp

 private static void CloseWordApp(Document wordDoc, Application wordApp)
 {
     wordDoc.Close(false, false, false);
     wordApp.Application.Quit();
 }
开发者ID:jobando89,项目名称:SharpLabelPrinter,代码行数:5,代码来源:Printer.cs

示例10: ConvertWord2PDF

        private void ConvertWord2PDF(string inputFile, string outputPath)
        {
            try
            {
                if (outputPath.Equals("") || !File.Exists(inputFile))
                {
                    throw new Exception("Either file does not exist or invalid output path");
                }

                // app to open the document belower
                Microsoft.Office.Interop.Word.Application wordApp = new Microsoft.Office.Interop.Word.Application();
                Document wordDocument = new Document();

                // input variables
                object objInputFile = inputFile;
                object missParam = Type.Missing;

                wordDocument = wordApp.Documents.Open(ref objInputFile, ref missParam, ref missParam, ref missParam,
                    ref missParam, ref missParam, ref missParam, ref missParam, ref missParam, ref missParam,
                    ref missParam, ref missParam, ref missParam, ref missParam, ref missParam, ref missParam);

                if (wordDocument != null)
                {
                    // make the convertion
                    wordDocument.ExportAsFixedFormat(outputPath, WdExportFormat.wdExportFormatPDF, false,
                        WdExportOptimizeFor.wdExportOptimizeForOnScreen, WdExportRange.wdExportAllDocument,
                        0, 0, WdExportItem.wdExportDocumentContent, true, true,
                        WdExportCreateBookmarks.wdExportCreateWordBookmarks, true, true, false, ref missParam);
                }

                // close document and quit application
                wordDocument.Close();
                wordApp.Quit();

                MessageBox.Show("File successfully converted");
                ClearTextBoxes();
            }
            catch (Exception e)
            {
                throw e;
            }
        }
开发者ID:fpgentil,项目名称:Word2PDF,代码行数:42,代码来源:Form1.cs

示例11: btnTestTable_Click

        private void btnTestTable_Click(object sender, EventArgs e)
        {
            tabControl2.SelectTab("tabPageTest");

            string regFileName = cbxRegDoc.Text;
            if (testFileName == null || testFileName.Trim() == "")
            {
                MessageBox.Show("请选择一个目标文档");
            }
            else if (regFileName == null || regFileName.Trim() == "")
            {
                MessageBox.Show("请选择一个规程文档");
            }
            else if (!isTextMode())
            {
                MessageBox.Show("非文本文档检测模式不支持表格匹配,请在目录检测中选择文本模式");
            }
            else
            {
                HandleTable handleTable = new HandleTable(testWord);

                string path = System.Environment.CurrentDirectory;
                string name = regFileName;
                name = path + "\\resources\\" + name + ".doc";

                Document regDoc = new Document();
                HandleDocument handleDocument = new HandleDocument();

                WaitingForm wf = new WaitingForm();
                HandleWaitingForm.startWaitingForm(wf);

                if (!testDocIsOpen)
                {
                    testDocIsOpen = true;
                    testDoc = handleDocument.openDocument(testFileName, testWord);
                }

                regDoc = handleDocument.openDocument(name, testWord);

                handleTable.contrastTablesOfDocs(regDoc, testDoc, showItemInfo, tvRegTable
                    , tvTestTable, null, null, null);

                Object saveChanges = false;
                object unknow = Type.Missing;

                regDoc.Close(ref saveChanges, ref unknow, ref unknow);

                HandleWaitingForm.closeWaitingForm(wf);

                plTOC.Hide();
                plKeyWord.Hide();
                plMultiInfo.Hide();

                plTableTest.Show();
                showTableTreeView();
                hideTOCTreeView();

                isMultiple = false;
                tabCalculateTable.Show();
                tabControlMulti.Hide();
            }
        }
开发者ID:v02zk,项目名称:Mycoding,代码行数:62,代码来源:Form1.cs

示例12: btnCreatePdf_Click

        private void btnCreatePdf_Click(object sender, EventArgs e)
        {
            string pdfToModify = textBoxPdfFilePath.Text.Trim();

            // create a PDF document
            Document document = new Document(pdfToModify);

            // set the license key
            document.LicenseKey = "B4mYiJubiJiInIaYiJuZhpmahpGRkZE=";

            // get the first page the PDF document
            PdfPage firstPage = document.Pages[0];

            string logoTransImagePath = System.IO.Path.Combine(Application.StartupPath, @"..\..\img\evologo-100-trans.png");
            string logoOpaqueImagePath = System.IO.Path.Combine(Application.StartupPath, @"..\..\img\evologo-100.jpg");

            // add an opaque image stamp in the top left corner of the first page
            // and make it semitransparent when rendered in PDF
            ImageElement imageStamp = new ImageElement(1, 1, logoOpaqueImagePath);
            imageStamp.Opacity = 50;
            AddElementResult addResult = firstPage.AddElement(imageStamp);

            // add a border for the image stamp
            RectangleElement imageBorderRectangleElement = new RectangleElement(1, 1, addResult.EndPageBounds.Width,
                                addResult.EndPageBounds.Height);
            firstPage.AddElement(imageBorderRectangleElement);

            // add a template stamp to the document repeated on each document page
            // the template contains an image and a text

            System.Drawing.Image logoImg = System.Drawing.Image.FromFile(logoTransImagePath);

            // calculate the template stamp location and size
            System.Drawing.SizeF imageSizePx = logoImg.PhysicalDimension;

            float imageWidthPoints = UnitsConverter.PixelsToPoints(imageSizePx.Width);
            float imageHeightPoints = UnitsConverter.PixelsToPoints(imageSizePx.Height);

            float templateStampXLocation = (firstPage.ClientRectangle.Width - imageWidthPoints) / 2;
            float templateStampYLocation = firstPage.ClientRectangle.Height / 4;

            // the stamp size is equal to image size in points
            Template templateStamp = document.AddTemplate(new System.Drawing.RectangleF(templateStampXLocation, templateStampYLocation,
                    imageWidthPoints, imageHeightPoints + 20));

            // set a semitransparent background color for template
            RectangleElement background = new RectangleElement(0, 0, templateStamp.ClientRectangle.Width, templateStamp.ClientRectangle.Height);
            background.BackColor = Color.White;
            background.Opacity = 25;
            templateStamp.AddElement(background);

            // add a true type font to the document
            System.Drawing.Font ttfFontBoldItalic = new System.Drawing.Font("Times New Roman", 10,
                        System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Point);
            PdfFont templateStampTextFont = document.AddFont(ttfFontBoldItalic, true);

            // Add a text element to the template. You can add any other types of elements to a template like a HtmlToPdfElement.
            TextElement templateStampTextElement = new TextElement(3, 0, "This is the Stamp Text", templateStampTextFont);
            templateStampTextElement.ForeColor = System.Drawing.Color.DarkBlue;
            templateStamp.AddElement(templateStampTextElement);

            // Add an image with transparency to the template. You can add any other types of elements to a template like a HtmlToPdfElement.
            ImageElement templateStampImageElement = new ImageElement(0, 20, logoImg);
            // instruct the library to use transparency information
            templateStampImageElement.RenderTransparentImage = true;
            templateStamp.AddElement(templateStampImageElement);

            // add a border to template
            RectangleElement templateStampRectangleElement = new RectangleElement(0, 0, templateStamp.ClientRectangle.Width,
                        templateStamp.ClientRectangle.Height);
            templateStamp.AddElement(templateStampRectangleElement);

            // dispose the image
            logoImg.Dispose();

            string outFilePath = System.IO.Path.Combine(Application.StartupPath, "PdfStamps.pdf");

            // save the PDF document to disk
            try
            {
                document.Save(outFilePath);
            }
            finally
            {
                document.Close();
            }

            DialogResult dr = MessageBox.Show("Open the saved file in an external viewer?", "Open Rendered File", MessageBoxButtons.YesNo);
            if (dr == DialogResult.Yes)
            {
                try
                {
                    System.Diagnostics.Process.Start(outFilePath);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    return;
                }
            }
//.........这里部分代码省略.........
开发者ID:ParallaxIT,项目名称:tdb-ws,代码行数:101,代码来源:PdfStamps.cs

示例13: generateSpecificationRegTOC

        public Dictionary<string, List<string>> generateSpecificationRegTOC(string filepath)
        {
            ApplicationClass app = new ApplicationClass();
            Document doc = new Document();
            HandleDocument handleDocument = new HandleDocument();
            doc = handleDocument.openDocument(filepath,app);

            Dictionary<string,List<string>> dict  = new Dictionary<string,List<string>>();
            int c = doc.Paragraphs.Count;
            bool isStart = false;
            string chapter = "";
            Regex regNum = new Regex("^[0-9]");
            Regex reg = new Regex(@"[\u4e00-\u9fa5]");//

            
            for (int i = 1; i <= c; i++)
            {
                string s = doc.Paragraphs[i].Range.Text;
      
                //int ccc = Convert.ToInt32(s[s.Length - 1]);
                //MessageBox.Show(ccc.ToString());

                if(s.IndexOf("第") == 0 && (s.IndexOf("章") ==  2 || s.IndexOf("章") == 3))
                {
                    isStart = true;
                }
                if (isStart)
                {
                    if (s.IndexOf("第") == 0 && (s.IndexOf("章") == 2 || s.IndexOf("章") == 3))
                    {
                        s = s.Replace("\r", "");
                        chapter = s;
                        dict.Add(s,new List<string>());
                    }
                    else if (regNum.IsMatch(s) && reg.IsMatch(s))
                    {
                        s = s.Replace("\r", "");
                        dict[chapter].Add(s);
                    }
                }
            }
            

            Object saveChanges = false;
            object unknow = Type.Missing;

            doc.Close(ref saveChanges, ref unknow, ref unknow);
            app.Quit(ref saveChanges, ref unknow, ref unknow);

            return dict;
        }
开发者ID:v02zk,项目名称:Mycoding,代码行数:51,代码来源:HandleDocument.cs

示例14: quit

 private void quit(ApplicationClass word, Document doc )
 {
     Object saveChanges = false;
     object unknow = Type.Missing;
    
     doc.Close(ref saveChanges, ref unknow, ref unknow);
     word.Quit(ref saveChanges, ref unknow, ref unknow);
 }
开发者ID:v02zk,项目名称:Mycoding,代码行数:8,代码来源:TableOfContents.cs

示例15: closeDoc

        private void closeDoc(Document doc)
        {
            Object saveChanges = false;
            object unknow = Type.Missing;

            doc.Close(ref saveChanges, ref unknow, ref unknow);
        }
开发者ID:v02zk,项目名称:Mycoding,代码行数:7,代码来源:keyWord.cs


注:本文中的System.Windows.Forms.Document.Close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。