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


C# Document.SaveToFile方法代码示例

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


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

示例1: Button1_Click

		protected void Button1_Click(object sender, System.EventArgs e)
		{
            //Create word document
            Document document = new Document();

            InsertWatermark(document);

            //Save doc file.
            document.SaveToFile("Sample.doc", FileFormat.Doc,Response, HttpContentType.Attachment);
		}
开发者ID:e-iceblue,项目名称:Spire.Office-for-.NET,代码行数:10,代码来源:Default.aspx.cs

示例2: Convert

        public String Convert(String sourceFile)
        {
            Document document = new Document();
            document.LoadFromFile(sourceFile);

            var fileName = String.Format("{0}.pdf",Path.GetFileNameWithoutExtension(sourceFile));
            var fullPath = String.Format("{0}{1}", _storageRootTemp, fileName);

            document.SaveToFile(fullPath, FileFormat.PDF);

            return fileName;
        }
开发者ID:slaq777,项目名称:lmsystem,代码行数:12,代码来源:WordToPdfConvertor.cs

示例3: DocTest

 public void DocTest()
 {
     const string fileName = "shay.pdf";
     var doc = new Document();
     var section = doc.AddSection();
     //            var table = section.AddTable(false);
     //            var row = table.AddRow();
     //            var cell = row.AddCell();
     var baseArea = section.AddParagraph();
     var rang = baseArea.AppendText("试卷标题123456【A卷】");
     rang.CharacterFormat.FontSize = 14;
     rang.CharacterFormat.Bold = true;
     rang.CharacterFormat.FontName = "宋体";
     doc.SaveToFile(fileName, FileFormat.PDF);
     Process.Start(fileName);
 }
开发者ID:shoy160,项目名称:Shoy.Common,代码行数:16,代码来源:SpireTest.cs

示例4: autoFillDocument

        public static void autoFillDocument(string templateURL, string filepath, Claim claim, bool isHeader = false)
        {
            Document document = new Document();

            // load document template
            //document.LoadFromFile(templateURL, FileFormat.Doc);
            document.LoadFromFile(templateURL, FileFormat.Auto);

            // load merge fields
            loadFieldValues(claim);

            //if (isHeader)
            //     setHeader(document, lead.Client);

            document.MailMerge.Execute(fieldNames, fieldValues);

            document.SaveToFile(filepath, FileFormat.Doc);
            //document.SaveToFile(filepath, FileFormat.Auto);

            document.Close();

            document = null;
        }
开发者ID:Antoniotoress1992,项目名称:asp,代码行数:23,代码来源:MergeDocumentHelper.cs

示例5: CameraReadySubmission

        public ActionResult CameraReadySubmission([Bind(Include = "PaperId,ConferenceId,UserId,PaperTitle,AuthorList,Co_Author,Affiliation,Presenter,Abstract,PaperDescription,AbstractFile,FullPaperFile,CameraReadyPaperFile,Keywords,TopicId,Prefix,AbstractSubmissionDate,FullPaperSubmissionDate,CameraReadyPaperSubmissionDate,AbstractSubmissionNotification,TotalNumberOfPages,Marks")] Paper paper)
        {
            try
            {
                Conference conference = db.Conferences.FirstOrDefault(u => u.ConferenceId == paper.ConferenceId);
                AbstractFileFormat fileformat = db.AbstractFileFormats.FirstOrDefault(u => u.ConferenceId == paper.ConferenceId);
                string filePath = FileUrl(paper.CameraReadyPaperFile, paper.Prefix);
                string wordFilePath = WordFileUrl(paper.CameraReadyPaperFile, paper.Prefix);

                if (fileformat != null)
                {
                    Document doc = new Document();
                    doc.LoadFromFile(wordFilePath);
                    int count = 0;
                    int styleName = 0;

                    foreach (Section section in doc.Sections)
                    {
                        foreach (Paragraph paragraph in section.Paragraphs)
                        {
                            paragraph.Format.LineSpacing = (float)fileformat.LineSpacing;
                            string text = paragraph.Text.ToLower();
                            if (text.Length > 0 && text.Equals("abstract"))
                            {
                                count = 1;
                            }
                            if (text.Length > 1 && count == 1)
                            {
                                ParagraphStyle style = new ParagraphStyle(doc);
                                paragraph.Format.HorizontalAlignment = HorizontalAlignment.Left;
                                style.Name = styleName.ToString();
                                style.CharacterFormat.FontName = fileformat.FontName.Name;
                                style.CharacterFormat.FontSize = fileformat.FontSize;
                                doc.Styles.Add(style);
                                paragraph.ApplyStyle(style.Name);
                            }
                            styleName++;
                        }
                        section.PageSetup.Margins.Top = (float)fileformat.Margin_Top;
                        section.PageSetup.Margins.Bottom = (float)fileformat.Margin_Bottom;
                        section.PageSetup.Margins.Left = (float)fileformat.Margin_Left;
                        section.PageSetup.Margins.Right = (float)fileformat.Margin_Right;
                    }
                    doc.SaveToFile(wordFilePath);
                }
                paper.CameraReadyPaperSubmissionDate = DateTime.Now.ToString();
                paper.CameraReadyPaperFile = filePath;
                if (ModelState.IsValid)
                {
                    db.Entry(paper).State = EntityState.Modified;
                    db.SaveChanges();
                }
                return RedirectToAction("CameraReadyIndex", new { id = paper.ConferenceId });
            }
            catch
            {
                ViewBag.ConferenceId = new SelectList(db.Conferences, "ConferenceId", "Username", paper.ConferenceId);
                ViewBag.TopicId = new SelectList(db.Topics, "TopicId", "Name", paper.TopicId);
                ViewBag.UserId = new SelectList(db.Users, "UserId", "Email", paper.UserId);
                return View(paper);
            }
        }
开发者ID:9mare,项目名称:123,代码行数:62,代码来源:PaperController.cs

示例6: Create

        public ActionResult Create([Bind(Include= "PaperTitle,AuthorList,Affiliation,Presenter,AbstractFile,Abstract,Keywords,TopicId,TotalNumberOfPages")] Paper paper)
        {
            try
            {
                int userId = (int)Session["sessionLoggedInUserId"];
                var submission = new Paper();
                submission.PaperTitle = paper.PaperTitle;
                submission.AuthorList = paper.AuthorList;
                submission.Affiliation = paper.Affiliation;
                submission.Presenter = paper.Presenter;
                submission.Abstract = paper.Abstract;
                submission.Keywords = paper.Keywords;
                submission.TopicId = paper.TopicId;
                submission.UserId = userId;
                submission.AbstractTotalNumberOfPages = paper.AbstractTotalNumberOfPages;
                submission.ConferenceId = (int)Session["ConferenceId"];
                Conference conference = db.Conferences.FirstOrDefault(u => u.ConferenceId == submission.ConferenceId);
                AbstractFileFormat fileformat = db.AbstractFileFormats.FirstOrDefault(u => u.ConferenceId == submission.ConferenceId);
                Paper papers = db.Papers.FirstOrDefault(u => u.ConferenceId == submission.ConferenceId);
                if(papers == null)
                {
                    submission.Prefix = conference.PaperPrefix + 1;
                }
                else
                {
                    Paper last = db.Papers.OrderByDescending(u => u.PaperId).FirstOrDefault(u => u.ConferenceId == submission.ConferenceId);
                    string[] word = last.Prefix.Split('-');
                    int paperNumber = Int32.Parse(word[1].ToString()) + 1;
                    submission.Prefix = conference.PaperPrefix + paperNumber;
                }
                string filePath = FileUrl(paper.AbstractFile, submission.Prefix);
                string wordFilePath = WordFileUrl(paper.AbstractFile, submission.Prefix);
                if (fileformat != null)
                {
                    Document doc = new Document();
                    doc.LoadFromFile(wordFilePath);
                    submission.AbstractTotalNumberOfPages = doc.PageCount;
                    int count = 0;
                    int styleName = 0;

                    foreach (Section section in doc.Sections)
                    {
                        foreach (Paragraph paragraph in section.Paragraphs)
                        {
                            paragraph.Format.LineSpacing = (float)fileformat.LineSpacing;
                            string text = paragraph.Text.ToLower();
                            if (text.Length > 0 && text.Equals("abstract"))
                            {
                                count = 1;
                            }
                            if (text.Length > 1 && count == 1)
                            {
                                ParagraphStyle style = new ParagraphStyle(doc);
                                paragraph.Format.HorizontalAlignment = HorizontalAlignment.Left;
                                style.Name = styleName.ToString();
                                style.CharacterFormat.FontName = fileformat.FontName.Name;
                                style.CharacterFormat.FontSize = fileformat.FontSize;
                                doc.Styles.Add(style);
                                paragraph.ApplyStyle(style.Name);
                            }
                            styleName++;
                        }
                        section.PageSetup.Margins.Top = (float)fileformat.Margin_Top;
                        section.PageSetup.Margins.Bottom = (float)fileformat.Margin_Bottom;
                        section.PageSetup.Margins.Left = (float)fileformat.Margin_Left;
                        section.PageSetup.Margins.Right = (float)fileformat.Margin_Right;
                    }
                    doc.SaveToFile(wordFilePath);
                }
                submission.AbstractSubmissionDate = DateTime.Now.ToString();
                submission.AbstractFile = filePath;
                db.Papers.Add(submission);
                db.SaveChanges();
                return RedirectToAction("Index", new { id = submission.UserId });
            }
            catch
            {
                ViewBag.ConferenceId = new SelectList(db.Conferences, "ConferenceId", "Username");
                ViewBag.TopicId = new SelectList(db.Topics, "TopicId", "Name");
                ViewBag.UserId = new SelectList(db.Users, "UserId", "Email");
                return View(paper);
            }
        }
开发者ID:9mare,项目名称:123,代码行数:83,代码来源:PaperController.cs


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