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


C# Document.Save方法代码示例

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


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

示例1: btnOK_Click

        private void btnOK_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(this.txtSaveDir.Text) &&
                !string.IsNullOrEmpty(this.txtProjectName.Text))
            {
                string selectDir = this.txtSaveDir.Text.Trim();
                string projectName = this.txtProjectName.Text.Trim();

                string path = System.IO.Path.Combine(selectDir, this.txtProjectName.Text.Trim());
                System.IO.Directory.CreateDirectory(path);

                DBGlobalService.ProjectFile = System.IO.Path.Combine(path, projectName+".xml");

                //doc.SetSchemaLocation(GlobalService.ConfigXsd);
                if (!System.IO.File.Exists(DBGlobalService.ProjectFile))
                {
                    var stream = System.IO.File.Create(DBGlobalService.ProjectFile);
                    stream.Close();
                }
                var doc = new Document();
                DBGlobalService.CurrentProjectDoc = doc;
                //doc.Load(GlobalService.ProjectFile);
                var prj = doc.CreateNode<ProjectType>();
                doc.Root = prj;
                DBGlobalService.CurrentProject = prj;
                DBGlobalService.CurrentProject.Name = projectName ;

                doc.Save(DBGlobalService.ProjectFile);

                this.DialogResult = System.Windows.Forms.DialogResult.OK;
                this.Close();
            }
        }
开发者ID:koksaver,项目名称:CodeHelper,代码行数:33,代码来源:CreatePorjectFrm.cs

示例2: SaveShapeTemplates

 public static void SaveShapeTemplates(ShapeTemplatesSet templates, string filepath)
 {
   string folder = Directory.GetParent(filepath).FullName;
   Document document = new Document("root");
   DataElement templatesEl = document.RootElement.CreateChild("templates");
   foreach(ShapeTemplate template in templates)
   {
     if(template is CircleTemplate)
     {
       SaveTemplate(templatesEl.CreateChild("circle"), folder, (CircleTemplate)template);
     }
     else if(template is ImageTemplate)
     {
       SaveTemplate(templatesEl.CreateChild("image"), folder, (ImageTemplate)template);
     }
     else if(template is RectTemplate)
     {
       SaveTemplate(templatesEl.CreateChild("rect"), folder, (RectTemplate)template);
     }
     else
     {
       throw new ArgumentException();
     }
   }
   
   document.Save(filepath);
 }
开发者ID:Paltr,项目名称:SceneEditor,代码行数:27,代码来源:SceneSerializer.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 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

示例4: SaveToPdfDefault

        public void SaveToPdfDefault()
        {
            //ExStart
            //ExFor:Document.Save(String)
            //ExSummary:Converts a whole document to PDF using default options.
            Document doc = new Document(MyDir + "Rendering.doc");

            doc.Save(MyDir + @"\Artifacts\Rendering.SaveToPdfDefault.pdf");
            //ExEnd
        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:10,代码来源:ExRendering.cs

示例5: 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

示例6: SaveScenes

 public static void SaveScenes(ScenesSet scenes,
   string filepath, string templatesFilepath)
 {
   Document document = new Document("root");
   DataElement templatesEl = document.RootElement.CreateChild("templates");
   templatesEl.CreateAttribute("filepath", templatesFilepath);
   DataElement scenesContainer = document.RootElement.CreateChild("scenes");
   foreach(Scene scene in scenes)
   {
     DataElement sceneElement = scenesContainer.CreateChild("scene");
     sceneElement.CreateAttribute("name", scene.Name);
     SaveScene(sceneElement, scene);
   }
   
   document.Save(filepath);
 }
开发者ID:Paltr,项目名称:SceneEditor,代码行数:16,代码来源:SceneSerializer.cs

示例7: SaveToPdfWithOutline

        public void SaveToPdfWithOutline()
        {
            //ExStart
            //ExFor:Document.Save(String, SaveOptions)
            //ExFor:PdfSaveOptions
            //ExFor:PdfSaveOptions.HeadingsOutlineLevels
            //ExFor:PdfSaveOptions.ExpandedOutlineLevels
            //ExSummary:Converts a whole document to PDF with three levels in the document outline.
            Document doc = new Document(MyDir + "Rendering.doc");

            PdfSaveOptions options = new PdfSaveOptions();
            options.OutlineOptions.HeadingsOutlineLevels = 3;
            options.OutlineOptions.ExpandedOutlineLevels = 1;

            doc.Save(MyDir + @"\Artifacts\Rendering.SaveToPdfWithOutline.pdf", options);
            //ExEnd
        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:17,代码来源:ExRendering.cs

示例8: SaveToPdfStreamOnePage

        public void SaveToPdfStreamOnePage()
        {
            //ExStart
            //ExFor:PdfSaveOptions.PageIndex
            //ExFor:PdfSaveOptions.PageCount
            //ExFor:Document.Save(Stream, SaveOptions)
            //ExSummary:Converts just one page (third page in this example) of the document to PDF.
            Document doc = new Document(MyDir + "Rendering.doc");

            using (Stream stream = File.Create(MyDir + @"\Artifacts\Rendering.SaveToPdfStreamOnePage.pdf"))
            {
                PdfSaveOptions options = new PdfSaveOptions();
                options.PageIndex = 2;
                options.PageCount = 1;
                doc.Save(stream, options);
            }
            //ExEnd
        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:18,代码来源:ExRendering.cs

示例9: button2_Click

        private void button2_Click(object sender, EventArgs e)
        {
            string path = this.textBox1.Text.Trim();

            if (path != string.Empty)
            {
                label1.Visible = false;

                ThreadPool.QueueUserWorkItem((userState) => {
                    // load PDF document
                    Document pdfDocument = new Document(path);

                    // instantiate Epub Save options
                    EpubSaveOptions options = new EpubSaveOptions();

                    // specify the layout for contents
                    options.ContentRecognitionMode = EpubSaveOptions.RecognitionMode.Flow;

                    // save the ePUB document
                    pdfDocument.Save(path + ".epub", options);

                    if (label1.InvokeRequired)
                    {
                        this.Invoke(new Action(() => { label1.Visible = true; }));
                    }
                    else 
                    {
                        label1.Visible = true;
                    }

                });
            }
            else 
            {
                MessageBox.Show("Please choose a pdf file firstly.");
            }
        }
开发者ID:NDChen,项目名称:MyDemoCode,代码行数:37,代码来源:Form1.cs

示例10: 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

示例11: btnReport_Click

        private void btnReport_Click(object sender, EventArgs e)
        {
            StudentByBus studentbus = new StudentByBus();
            StudentByBus CurrentStudentbus = new StudentByBus();
            string CurrentBusStopName = "";
            BusSetup bussetup = BusSetupDAO.SelectByBusYearAndRange(this.intSchoolYear.Value, cboBusRange.Text);
            //List<string> newStuNumberList = new List<string>();
            List<string> StudentIDList = K12.Presentation.NLDPanels.Student.SelectedSource;
            List<StudentRecord> stuRec = Student.SelectByIDs(StudentIDList);
            Dictionary<string, StudentByBus> studentbusRecord = new Dictionary<string, StudentByBus>();

            studentbus = StudentByBusDAO.SelectByBusYearAndTimeNameAndStudntID(this.intSchoolYear.Value, this.cboBusRange.Text, StudentIDList[0]);
            if (studentbus != null)
            {
                if (textBusStop.Text != "" && textBusStop.Text != studentbus.BusStopID)
                    studentbus.BusStopID = textBusStop.Text;
                BusStop buses = BusStopDAO.SelectByBusTimeNameAndByStopID(bussetup.BusTimeName, textBusStop.Text);
                CurrentBusStopName = buses.BusStopName;
                int total = 0;
                if (studentbus.DateCount > 0)
                    total = buses.BusMoney * studentbus.DateCount;
                else
                    total = buses.BusMoney * bussetup.DateCount;
                int div_value = total / 10;
                if ((total - div_value * 10) < 5)
                    studentbus.BusMoney = div_value * 10;
                else
                    studentbus.BusMoney = div_value * 10 + 10;
                studentbus.Save();
                CurrentStudentbus = studentbus;
            }
            else
            {
                StudentByBus newstudentbus = new StudentByBus();
                if (textBusStop.Text != "")
                    newstudentbus.BusStopID = textBusStop.Text;
                BusStop buses = BusStopDAO.SelectByBusTimeNameAndByStopID(bussetup.BusTimeName, textBusStop.Text);
                CurrentBusStopName = buses.BusStopName;
                newstudentbus.BusRangeName = cboBusRange.Text;
                newstudentbus.BusStopID = textBusStop.Text;
                newstudentbus.BusTimeName = bussetup.BusTimeName;
                newstudentbus.ClassName = stuRec[0].Class.Name;
                newstudentbus.ClassID = stuRec[0].Class.ID;
                newstudentbus.DateCount = bussetup.DateCount;
                newstudentbus.SchoolYear = bussetup.BusYear;
                newstudentbus.StudentID = stuRec[0].ID;
                int total = buses.BusMoney * bussetup.DateCount;
                int div_value = total / 10;
                if ((total - div_value * 10) < 5)
                    newstudentbus.BusMoney = div_value * 10;
                else
                    newstudentbus.BusMoney = div_value * 10 + 10;
                newstudentbus.Save();

                CurrentStudentbus = newstudentbus;
            }

            //if (!File.Exists(Application.StartupPath + "\\Customize\\校車繳費單樣版.doc"))
            //{
            //    MessageBox.Show("『" + Application.StartupPath + "\\Customize\\校車繳費單樣版.doc』檔案不存在,請確認後重新執行!");
            //    return;
            //}

            //if (!File.Exists(Application.StartupPath + "\\Customize\\校車繳費單樣版-現有學生.doc"))
            //{
            //    MessageBox.Show("『" + Application.StartupPath + "\\Customize\\校車繳費單樣版-現有學生.doc』檔案不存在,請確認後重新執行!");
            //    return;
            //}

            //Document Template = new Document(Application.StartupPath + "\\Customize\\校車繳費單樣版-現有學生.doc");
            Document Template = new Aspose.Words.Document(new MemoryStream(Properties.Resources.校車繳費單樣版_現有學生));
            //Document Template = new Document();
            //mPreference = TemplatePreference.GetInstance();
            //if (mPreference.UseDefaultTemplate)
            //    Template = new Aspose.Words.Document(new MemoryStream(Properties.Resources.校車繳費單樣版_新生));
            //else
            //    Template = new Aspose.Words.Document(mPreference.CustomizeTemplate);

            Document doc = new Document();

            Payment SelectPayment = cboPayment.SelectedItem as Payment;

            //新增收費明細。
            List<PaymentDetail> StudentDetails = new List<PaymentDetail>();

            SelectPayment.FillFull();
            List<PaymentDetail> AllStudentdetail = PaymentDetail.GetByTarget("Student", StudentIDList);
            List<PaymentDetail> Studentdetail = new List<PaymentDetail>();
            List<PaymentDetail> CurrentDetails = new List<PaymentDetail>();
            List<PaymentHistory> historys = new List<PaymentHistory>();
            List<string> ids = new List<string>();
            foreach (PaymentDetail var in AllStudentdetail)
            {
                if (var.Extensions["校車收費年度"] != intSchoolYear.Value.ToString() || var.Extensions["校車收費名稱"] != cboBusRange.SelectedItem.ToString())
                    continue;
                Studentdetail.Add(var);
            }

            if (Studentdetail.Count == 0)
            {
//.........这里部分代码省略.........
开发者ID:kobeaaron110,项目名称:mdhs,代码行数:101,代码来源:StudnetPaymentSheet.cs

示例12: 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

示例13: SetFontsFoldersSystemAndCustomFolder

        public void SetFontsFoldersSystemAndCustomFolder()
        {
            // Store the font sources currently used so we can restore them later.
            FontSourceBase[] origFontSources = FontSettings.GetFontsSources();

            //ExStart
            //ExFor:FontSettings
            //ExFor:FontSettings.GetFontsSources()
            //ExFor:FontSettings.SetFontsSources()
            //ExId:SetFontsFoldersSystemAndCustomFolder
            //ExSummary:Demonstrates how to set Aspose.Words to look for TrueType fonts in system folders as well as a custom defined folder when scanning for fonts.
            Document doc = new Document(MyDir + "Rendering.doc");

            // Retrieve the array of environment-dependent font sources that are searched by default. For example this will contain a "Windows\Fonts\" source on a Windows machines.
            // We add this array to a new ArrayList to make adding or removing font entries much easier.
            ArrayList fontSources = new ArrayList(FontSettings.GetFontsSources());

            // Add a new folder source which will instruct Aspose.Words to search the following folder for fonts.
            FolderFontSource folderFontSource = new FolderFontSource("C:\\MyFonts\\", true);

            // Add the custom folder which contains our fonts to the list of existing font sources.
            fontSources.Add(folderFontSource);

            // Convert the Arraylist of source back into a primitive array of FontSource objects.
            FontSourceBase[] updatedFontSources = (FontSourceBase[])fontSources.ToArray(typeof(FontSourceBase));

            // Apply the new set of font sources to use.
            FontSettings.SetFontsSources(updatedFontSources);

            doc.Save(MyDir + "Rendering.SetFontsFolders Out.pdf");
            //ExEnd

            // Verify that font sources are set correctly.
            Assert.IsInstanceOf(typeof(SystemFontSource), FontSettings.GetFontsSources()[0]); // The first source should be a system font source.
            Assert.IsInstanceOf(typeof(FolderFontSource), FontSettings.GetFontsSources()[1]); // The second source should be our folder font source.

            FolderFontSource folderSource = ((FolderFontSource)FontSettings.GetFontsSources()[1]);
            Assert.AreEqual(@"C:\MyFonts\", folderSource.FolderPath);
            Assert.True(folderSource.ScanSubfolders);

            // Restore the original sources used to search for fonts.
            FontSettings.SetFontsSources(origFontSources);
        }
开发者ID:nausherwan-aslam,项目名称:Aspose_Words_NET,代码行数:43,代码来源:ExRendering.cs

示例14: SetTrueTypeFontsFolder

        public void SetTrueTypeFontsFolder()
        {
            // Store the font sources currently used so we can restore them later.
            FontSourceBase[] fontSources = FontSettings.GetFontsSources();

            //ExStart
            //ExFor:FontSettings
            //ExFor:FontSettings.SetFontsFolder(String, Boolean)
            //ExId:SetFontsFolderCustomFolder
            //ExSummary:Demonstrates how to set the folder Aspose.Words uses to look for TrueType fonts during rendering or embedding of fonts.
            Document doc = new Document(MyDir + "Rendering.doc");

            // Note that this setting will override any default font sources that are being searched by default. Now only these folders will be searched for
            // fonts when rendering or embedding fonts. To add an extra font source while keeping system font sources then use both FontSettings.GetFontSources and
            // FontSettings.SetFontSources instead.
            FontSettings.SetFontsFolder(@"C:\MyFonts\", false);

            doc.Save(MyDir + "Rendering.SetFontsFolder Out.pdf");
            //ExEnd

            // Restore the original sources used to search for fonts.
            FontSettings.SetFontsSources(fontSources);
        }
开发者ID:nausherwan-aslam,项目名称:Aspose_Words_NET,代码行数:23,代码来源:ExRendering.cs

示例15: lnkChkMappingField_LinkClicked

        private void lnkChkMappingField_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            SaveFileDialog saveDialog = new SaveFileDialog();
            saveDialog.Filter = "Word (*.doc)|*.doc";
            saveDialog.FileName = "綜合表現紀錄表合併欄位說明";
            if (saveDialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    Document doc = new Document(new MemoryStream(Properties.Resources.綜合表現紀錄表合併欄位說明));
                    doc.Save(saveDialog.FileName);
                }
                catch (Exception ex)
                {
                    FISCA.Presentation.Controls.MsgBox.Show("儲存失敗。" + ex.Message);
                    return;
                }

                try
                {
                    System.Diagnostics.Process.Start(saveDialog.FileName);
                }
                catch (Exception ex)
                {
                    FISCA.Presentation.Controls.MsgBox.Show("開啟失敗。" + ex.Message);
                    return;
                }
            }
        }
开发者ID:ChunTaiChen,项目名称:Counsel_System,代码行数:29,代码来源:StudABCardReportForm.cs


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