private void buttonExport_Click(object sender, EventArgs e) { UseWaitCursor = true; Application.DoEvents(); try { if (saveEvidenceNotice == null) { saveEvidenceNotice = new SaveEvidenceNotice(); saveEvidenceNotice.FilePath = Utility.GetFileSavePath() + Utility.BuilderFileName(); } saveEvidenceNotice.Status = 1; SaveData(); WordDocument doc = new WordDocument("先行登记保存证据通知书"); doc.AddField("DocTitle", saveEvidenceNotice.DocTitle); doc.AddField("FieldECompanyName", saveEvidenceNotice.FieldECompanyName); doc.AddField("IllegalTypeName", saveEvidenceNotice.IllegalTypeName); doc.AddField("ToTime", saveEvidenceNotice.ToTime.ToString("yyyy年MM月dd日")); doc.AddField("QFirstPerson", saveEvidenceNotice.QFirstPerson); doc.AddFootField("DocManageArea", saveEvidenceNotice.DocManageArea); OnNavigationRequest(new Maleos.NavigationRequestEventArgs("Maleos.Modules.OutputDocuemnt", new object[] { doc, "EnforceForm.frmSaveEvidenceNotices", saveEvidenceNotice.FilePath })); } catch (Exception ex) { CommonInvoke.ErrorMessageBox(ex); } UseWaitCursor = false; }
private void buttonExport_Click(object sender, EventArgs e) { UseWaitCursor = true; Application.DoEvents(); try { if (hearingInform == null) { hearingInform = new HearingInform(); hearingInform.FilePath = Utility.GetFileSavePath() + Utility.BuilderFileName(); } hearingInform.Status = 1; SaveData(); WordDocument doc = new WordDocument("听证会报告书"); doc.AddField("DocTitle", hearingInform.DocTitle); doc.AddField("CaseName", hearingInform.CaseName); doc.AddField("CompereName", hearingInform.CompereName); doc.AddField("SecretaryName", hearingInform.SecretaryName); doc.AddField("HearName", hearingInform.HearName); doc.AddField("Summary", hearingInform.Summary); doc.AddField("Suggest", hearingInform.Suggest); doc.AddField("PrincipalSuggest", hearingInform.PrincipalSuggest); OnNavigationRequest(new Maleos.NavigationRequestEventArgs("Maleos.Modules.OutputDocuemnt", new object[] { doc, "EnforceForm.frmHearingInforms", hearingInform.FilePath })); } catch (Exception ex) { CommonInvoke.ErrorMessageBox(ex); } UseWaitCursor = false; }
private void buttonExport_Click(object sender, EventArgs e) { UseWaitCursor = true; Application.DoEvents(); try { if (saveEvidenceProceAudit == null) { saveEvidenceProceAudit = new SaveEvidenceProceAudit(); saveEvidenceProceAudit.FilePath = Utility.GetFileSavePath() + Utility.BuilderFileName(); } saveEvidenceProceAudit.Status = 1; SaveData(); WordDocument doc = new WordDocument("先行登记保存证据处理审批表"); doc.AddField("PutOnRecordCaseName", saveEvidenceProceAudit.PutOnRecordCaseName); doc.AddField("PutOnRecordCasePeopleInfo", saveEvidenceProceAudit.PutOnRecordCasePeopleInfo); doc.AddField("PutOnRecordCaseContent", saveEvidenceProceAudit.PutOnRecordCaseContent); doc.AddField("SamplingID", saveEvidenceProceAudit.SamplingID); doc.AddField("ReasonBasis", saveEvidenceProceAudit.ReasonBasis); doc.AddField("UndertakerOpinion", saveEvidenceProceAudit.UndertakerOpinion); //doc.AddFootField("FirstPageTest", "测试"); //doc.AddFootField("Test", "测试"); OnNavigationRequest(new Maleos.NavigationRequestEventArgs("Maleos.Modules.OutputDocuemnt", new object[] { doc, "EnforceForm.frmSaveEvidenceProceAudits", saveEvidenceProceAudit.FilePath })); } catch (Exception ex) { CommonInvoke.ErrorMessageBox(ex); } UseWaitCursor = false; }
private void buttonExport_Click(object sender, EventArgs e) { UseWaitCursor = true; Application.DoEvents(); try { if (obj == null) { obj = new CaseExtensionClosedApprovalToSibling(); obj.FilePath = Utility.GetFileSavePath() + Utility.BuilderFileName(); } obj.Status = 1; SaveData(); WordDocument doc = new WordDocument("案件延期办结毕审批表"); doc.AddField("CaseName", obj.CaseName); doc.AddField("Party", obj.Party); doc.AddField("Legal", obj.Legal); doc.AddField("CaseStartDate", obj.CaseStartDate.ToString("yyyy年MM月dd日")); doc.AddField("ExtensionApproval", obj.ExtensionApproval); doc.AddField("Address", obj.Address); doc.AddField("Tel", obj.Tel); doc.AddField("CaseSourceName", obj.CaseSourceName); OnNavigationRequest(new Maleos.NavigationRequestEventArgs("Maleos.Modules.OutputDocuemnt", new object[] { doc, "EnforceForm.frmEditCaseExtensionClosedApprovalToSibling", obj.FilePath })); } catch (Exception ex) { CommonInvoke.ErrorMessageBox(ex); } UseWaitCursor = false; }
private void buttonExport_Click(object sender, EventArgs e) { UseWaitCursor = true; Application.DoEvents(); try { if (fineCallsNotice == null) { fineCallsNotice = new FineCallsNotice(); fineCallsNotice.FilePath = Utility.GetFileSavePath() + Utility.BuilderFileName(); } fineCallsNotice.Status = 1; SaveData(); WordDocument doc = new WordDocument("罚款催缴通知书"); doc.AddField("CompanyName", fineCallsNotice.CompanyName); doc.AddField("SendCallsDate", fineCallsNotice.SendCallsDate.ToString("yyyy年MM月dd日")); doc.AddField("DecideNumber", fineCallsNotice.DecideNumber); doc.AddField("EndDate", fineCallsNotice.EndDate.ToString("yyyy年MM月dd日")); doc.AddField("Location", fineCallsNotice.Location); doc.AddField("DocTitle", fineCallsNotice.DocTitle); doc.AddFootField("DocManageArea", InvokeUtil.ActiveUser.FullName); OnNavigationRequest(new Maleos.NavigationRequestEventArgs("Maleos.Modules.OutputDocuemnt", new object[] { doc, "EnforceForm.frmFineCallsNotice", fineCallsNotice.FilePath })); } catch (Exception ex) { CommonInvoke.ErrorMessageBox(ex); } UseWaitCursor = false; }
private void buttonExport_Click(object sender, EventArgs e) { UseWaitCursor = true; Application.DoEvents(); try { if (caseTransferred == null) { caseTransferred = new CaseTransferred(); caseTransferred.FilePath = Utility.GetFileSavePath() + Utility.BuilderFileName(); } caseTransferred.Status = 1; SaveData(); WordDocument doc = new WordDocument("案件移送书"); doc.AddField("UnitName", caseTransferred.UnitName); doc.AddField("TransferredDate", caseTransferred.TransferredDate.ToString("yyyy年MM月dd日")); doc.AddField("CaseName", caseTransferred.CaseName); doc.AddField("TransferredReason", caseTransferred.TransferredReason); doc.AddField("TransferredLaw", caseTransferred.TransferredLaw); doc.AddField("CaseMaterial", caseTransferred.CaseMaterial); doc.AddField("DocTitle", caseTransferred.DocTitle); doc.AddFootField("DocManageArea", InvokeUtil.ActiveUser.FullName); OnNavigationRequest(new Maleos.NavigationRequestEventArgs("Maleos.Modules.OutputDocuemnt", new object[] { doc, "EnforceForm.frmCaseTransferred", caseTransferred.FilePath })); } catch (Exception ex) { CommonInvoke.ErrorMessageBox(ex); } UseWaitCursor = false; }
private void buttonExport_Click(object sender, EventArgs e) { UseWaitCursor = true; Application.DoEvents(); try { if (sealDecideApproval == null) { sealDecideApproval = new SealDecideApproval(); sealDecideApproval.FilePath = Utility.GetFileSavePath() + Utility.BuilderFileName(); } sealDecideApproval.Status = 1; SaveData(); WordDocument doc = new WordDocument("查封(扣押)决定审批表"); doc.AddField("CaseName", sealDecideApproval.CaseName); doc.AddField("CaseStatus", sealDecideApproval.CaseStatus); doc.AddField("PartyBaseInfo", sealDecideApproval.PartyBaseInfo); doc.AddField("SealContent", sealDecideApproval.SealContent); doc.AddField("SealReason", sealDecideApproval.SealReason); doc.AddField("UserName1", sealDecideApproval.UserName1); doc.AddField("UserName2", sealDecideApproval.UserName2); doc.AddField("UserReason", sealDecideApproval.UserReason); OnNavigationRequest(new Maleos.NavigationRequestEventArgs("Maleos.Modules.OutputDocuemnt", new object[] { doc, "EnforceForm.frmSealDecideApproval", sealDecideApproval.FilePath })); } catch (Exception ex) { CommonInvoke.ErrorMessageBox(ex); } UseWaitCursor = false; }
private void buttonExport_Click(object sender, EventArgs e) { UseWaitCursor = true; Application.DoEvents(); try { if (caseTransferredApproval == null) { caseTransferredApproval = new CaseTransferredApproval(); caseTransferredApproval.FilePath = Utility.GetFileSavePath() + Utility.BuilderFileName(); } caseTransferredApproval.Status = 1; SaveData(); WordDocument doc = new WordDocument("案件移送审批表"); doc.AddField("CaseName", caseTransferredApproval.CaseName); doc.AddField("Party", caseTransferredApproval.Party); doc.AddField("Address", caseTransferredApproval.Address); doc.AddField("ReceiverUnit", caseTransferredApproval.ReceiverUnit); doc.AddField("CaseInfo", caseTransferredApproval.CaseInfo); doc.AddField("TransferredReason", caseTransferredApproval.TransferredReason); doc.AddField("UserReason", caseTransferredApproval.UserReason); OnNavigationRequest(new Maleos.NavigationRequestEventArgs("Maleos.Modules.OutputDocuemnt", new object[] { doc, "EnforceForm.frmCaseTransferredApproval", caseTransferredApproval.FilePath })); } catch (Exception ex) { CommonInvoke.ErrorMessageBox(ex); } UseWaitCursor = false; }
private void buttonExport_Click(object sender, EventArgs e) { UseWaitCursor = true; Application.DoEvents(); try { if (enquireQuestion == null) { enquireQuestion = new EnquireQuestion(); enquireQuestion.FilePath = Utility.GetFileSavePath() + Utility.BuilderFileName(); } enquireQuestion.Status = 1; SaveData(); WordDocument doc = new WordDocument("询问笔录"); OnNavigationRequest(new Maleos.NavigationRequestEventArgs("Maleos.Modules.OutputDocuemnt", new object[] { doc, "EnforceForm.frmEnquireQuestions", enquireQuestion.FilePath })); } catch (Exception ex) { CommonInvoke.ErrorMessageBox(ex); } UseWaitCursor = false; }
private void buttonExport_Click(object sender, EventArgs e) { UseWaitCursor = true; Application.DoEvents(); try { if (contributeFineApproval == null) { contributeFineApproval = new ContributeFineApproval(); contributeFineApproval.FilePath = Utility.GetFileSavePath() + Utility.BuilderFileName(); } contributeFineApproval.Status = 1; SaveData(); WordDocument doc = new WordDocument("延期(分期)缴纳罚款审批表"); doc.AddField("CaseName", contributeFineApproval.CaseName); doc.AddField("PunishInstrumentNo", contributeFineApproval.PunishInstrumentNo); doc.AddField("Party", contributeFineApproval.Party); doc.AddField("Address", contributeFineApproval.Address); doc.AddField("LawFactPunish", contributeFineApproval.LawFactPunish); doc.AddField("ExtensionReason", contributeFineApproval.ExtensionReason); doc.AddField("UserOpinion", contributeFineApproval.UserOpinion); OnNavigationRequest(new Maleos.NavigationRequestEventArgs("Maleos.Modules.OutputDocuemnt", new object[] { doc, "EnforceForm.frmContributeFineApproval", contributeFineApproval.FilePath })); } catch (Exception ex) { CommonInvoke.ErrorMessageBox(ex); } UseWaitCursor = false; }
public OutputDocuemnt(WordDocument wordDoc, string moduleName) : this() { this.docObj = wordDoc; Fill(); _moduleName = moduleName; }
private void buttonExport_Click(object sender, EventArgs e) { UseWaitCursor = true; Application.DoEvents(); try { SaveData(); WordDocument doc = new WordDocument("延期(分期)缴纳罚款批准书"); doc.AddField("CompanyName", contributeFine.CompanyName); doc.AddField("DocTitle", contributeFine.DocTitle); doc.AddField("ContributionsDate", contributeFine.ContributionsDate.ToString("yyyy年MM月dd日")); doc.AddField("InstrumentNo", contributeFine.InstrumentNo); doc.AddField("FineSumString", contributeFine.FineSumString); doc.AddField("FineSum", contributeFine.FineSum.ToString()); doc.AddField("ExtensionDate", contributeFine.ExtensionDate.ToString("yyyy年MM月dd日")); doc.AddField("ExtensionDateString", contributeFine.ExtensionDateString); doc.AddField("Period", contributeFine.Period); doc.AddField("InstallmentsDate", contributeFine.InstallmentsDate.ToString("yyyy年MM月dd日")); doc.AddField("InstallmentsDateString", contributeFine.InstallmentsDateString); doc.AddField("InstallmentsSum", contributeFine.InstallmentsSum.ToString()); doc.AddField("InstallmentsSumString", contributeFine.InstallmentsSumString); doc.AddField("InstallmentsBalance", contributeFine.InstallmentsBalance.ToString()); doc.AddField("InstallmentsBalanceString", contributeFine.InstallmentsBalanceString); doc.AddFootField("DocManageArea", InvokeUtil.ActiveUser.FullName); OutputDocuemnt frm = new OutputDocuemnt(doc); frm.OpenWindow(this); } catch (Exception ex) { CommonInvoke.ErrorMessageBox(ex); } UseWaitCursor = false; }
private void buttonExport_Click(object sender, EventArgs e) { UseWaitCursor = true; Application.DoEvents(); try { if (sampling == null) { sampling = new Sampling(); sampling.FilePath = Utility.GetFileSavePath() + Utility.BuilderFileName(); } sampling.Status = 1; SaveData(); WordDocument doc = new WordDocument("抽样取证凭证"); doc.AddField("DocTitle", sampling.DocTitle); doc.AddField("FieldECompanyName", sampling.FieldECompanyName); doc.AddField("FieldEPeopleName", sampling.FieldEPeopleName); doc.AddField("FieldEAddress", sampling.FieldEAddress); doc.AddField("FieldEPeoplePhone", sampling.FieldEPeoplePhone); doc.AddField("FieldEPeopleZio", sampling.FieldEPeopleZio); doc.AddField("BeganTimeYear", sampling.BeganTime.Year.ToString()); doc.AddField("BeganTimeMonth", sampling.BeganTime.Month.ToString()); doc.AddField("BeganTimeDay", sampling.BeganTime.Day.ToString()); doc.AddField("BeganTimeHour", sampling.BeganTime.Hour.ToString()); doc.AddField("BeganTimeMinute", sampling.BeganTime.Minute.ToString()); doc.AddField("ToTimeDay", sampling.ToTime.Day.ToString()); doc.AddField("ToTimeHour", sampling.ToTime.Hour.ToString()); doc.AddField("ToTimeMinute", sampling.ToTime.Minute.ToString()); doc.AddField("SamplingAddress", sampling.SamplingAddress); doc.AddFootField("DocManageArea", sampling.DocManageArea); //doc.AddFootField("FirstPageTest", "测试"); //doc.AddFootField("Test", "测试"); Grid grid = doc.NewGrid(); grid.TableMark = "Table"; int i = 0; foreach (SamplingContent sc in sampling.Items) { i++; GridRow row = grid.NewRow(); row.AddRowItem(i.ToString()); row.AddRowItem(sc.SDocTitle); row.AddRowItem(sc.ItemName); row.AddRowItem(sc.ItemRule); row.AddRowItem(sc.Count.ToString() + sc.ItemUnit); } OnNavigationRequest(new Maleos.NavigationRequestEventArgs("Maleos.Modules.OutputDocuemnt", new object[] { doc, "EnforceForm.frmSamplings", sampling.FilePath })); } catch (Exception ex) { CommonInvoke.ErrorMessageBox(ex); } UseWaitCursor = false; }
private void buttonExport_Click(object sender, EventArgs e) { UseWaitCursor = true; Application.DoEvents(); try { if (spotCheck == null) { spotCheck = new SpotCheck(); spotCheck.FilePath = Utility.GetFileSavePath() + Utility.BuilderFileName(); } spotCheck.Status = 1; SaveData(); WordDocument doc = new WordDocument("现场检查记录"); doc.Entity = spotCheck; doc.AddField("CompanyName", spotCheck.CompanyName); doc.AddField("CompanyAddress", spotCheck.CompanyAddress); doc.AddField("CheckAddress", spotCheck.CheckAddress); doc.AddField("JuridicalName", spotCheck.JuridicalName); doc.AddField("JuridicalJob", spotCheck.JuridicalJob); doc.AddField("JuridicalTel", spotCheck.JuridicalTel); doc.AddField("CheckStartTimeYear", spotCheck.CheckStartTime.Year.ToString()); doc.AddField("CheckStartTimeMonth", spotCheck.CheckStartTime.Month.ToString()); doc.AddField("CheckStartTimeDay", spotCheck.CheckStartTime.Day.ToString()); doc.AddField("CheckStartTimeHours", spotCheck.CheckStartTime.Hour.ToString()); doc.AddField("CheckStartTimeMinute", spotCheck.CheckStartTime.Minute.ToString()); doc.AddField("CheckEndTimeDay", spotCheck.CheckEndTime.Day.ToString()); doc.AddField("CheckEndTimeHours", spotCheck.CheckEndTime.Hour.ToString()); doc.AddField("CheckEndTimeMinute", spotCheck.CheckEndTime.Minute.ToString()); doc.AddField("Area", spotCheck.Area); doc.AddField("OfficerName1", spotCheck.OfficerName1); doc.AddField("OfficerName2", spotCheck.OfficerName2); doc.AddField("CID1", spotCheck.CID1); doc.AddField("CID2", spotCheck.CID2); doc.AddField("CheckCondition", spotCheck.CheckCondition); doc.AddField("SpotCondition", spotCheck.SpotCondition); //doc.AddField("CheckPerson1", spotCheck.CheckPerson1); //doc.AddField("CheckPerson2", spotCheck.CheckPerson2); //doc.AddField("SiteJuridical", spotCheck.SiteJuridical); //doc.AddField("CheckDate", spotCheck.CheckDate.ToString("yyyy年M月d日")); //doc.AddFootField("FirstPageTest", "测试"); //doc.AddFootField("Test", "测试"); //OutputDocuemnt frm = new OutputDocuemnt(doc); //frm.OpenWindow(this); OnNavigationRequest(new Maleos.NavigationRequestEventArgs("Maleos.Modules.OutputDocuemnt", new object[] { doc, "EnforceForm.frmSpotChecks", spotCheck.FilePath })); } catch (Exception ex) { CommonInvoke.ErrorMessageBox(ex); } UseWaitCursor = false; }
private void buttonExport_Click(object sender, EventArgs e) { UseWaitCursor = true; Application.DoEvents(); try { if (defenseRecords == null) { defenseRecords = new DefenseRecords(); defenseRecords.FilePath = Utility.GetFileSavePath() + Utility.BuilderFileName(); } defenseRecords.Status = 1; SaveData(); WordDocument doc = new WordDocument("当事人陈述申辩笔录"); doc.AddField("DefenseStartDateYear", defenseRecords.DefenseStartDate.Year.ToString()); doc.AddField("DefenseStartDateMonth", defenseRecords.DefenseStartDate.Month.ToString()); doc.AddField("DefenseStartDateDay", defenseRecords.DefenseStartDate.Day.ToString()); doc.AddField("DefenseStartDateHour", defenseRecords.DefenseStartDate.Hour.ToString()); doc.AddField("DefenseStartDateMinute", defenseRecords.DefenseStartDate.Minute.ToString()); doc.AddField("DefenseEndDateDay", defenseRecords.DefenseEndDate.Day.ToString()); doc.AddField("DefenseEndDateHour", defenseRecords.DefenseEndDate.Hour.ToString()); doc.AddField("DefenseEndDateMinute", defenseRecords.DefenseEndDate.Minute.ToString()); doc.AddField("Location", defenseRecords.Location); doc.AddField("DefenseUser", defenseRecords.DefenseUser); doc.AddField("Sex", defenseRecords.Sex); doc.AddField("Position", defenseRecords.Position); doc.AddField("WorkUnit", defenseRecords.WorkUnit); doc.AddField("Tel", defenseRecords.Tel); doc.AddField("Address", defenseRecords.Address); doc.AddField("ZipCode", defenseRecords.ZipCode); string UserNameStr = defenseRecords.UserName1 + (defenseRecords.UserName2 != "" ? "、" + defenseRecords.UserName2 : ""); doc.AddField("UserName1", UserNameStr); doc.AddField("UserName3", defenseRecords.UserName3); doc.AddField("LawUnit", defenseRecords.LawUnit); doc.AddField("ProblemResult1", defenseRecords.ProblemResult1); doc.AddField("ProblemResult2", defenseRecords.ProblemResult2); doc.AddField("ProblemResult3", defenseRecords.ProblemResult3); doc.AddField("CaseName", defenseRecords.CaseName); doc.AddField("ProblemUser1", defenseRecords.ProblemUser1); doc.AddField("ProblemUser2", defenseRecords.ProblemUser2); doc.AddField("ProblemUserCode1", defenseRecords.ProblemUserCode1); doc.AddField("ProblemUserCode2", defenseRecords.ProblemUserCode2); doc.AddField("ProblemResult4", defenseRecords.ProblemResult4); doc.AddField("ProblemContent", defenseRecords.ProblemContent); doc.AddFootField("DocManageArea", InvokeUtil.ActiveUser.FullName); OnNavigationRequest(new Maleos.NavigationRequestEventArgs("Maleos.Modules.OutputDocuemnt", new object[] { doc, "EnforceForm.frmDefenseRecords", defenseRecords.FilePath })); } catch (Exception ex) { CommonInvoke.ErrorMessageBox(ex); } UseWaitCursor = false; }
private void buttonExport_Click(object sender, EventArgs e) { UseWaitCursor = true; Application.DoEvents(); try { if (explorationRecord == null) { explorationRecord = new ExplorationRecord(); explorationRecord.FilePath = Utility.GetFileSavePath() + Utility.BuilderFileName(); } explorationRecord.Status = 1; SaveData(); WordDocument doc = new WordDocument("勘验笔录"); doc.AddField("DocTitle", explorationRecord.DocTitle); doc.AddField("BeganTimeYear", explorationRecord.BeganTime.Year.ToString()); doc.AddField("BeganTimeMonth", explorationRecord.BeganTime.Month.ToString()); doc.AddField("BeganTimeDay", explorationRecord.BeganTime.Day.ToString()); doc.AddField("BeganTimeHour", explorationRecord.BeganTime.Hour.ToString()); doc.AddField("BeganTimeMinute", explorationRecord.BeganTime.Minute.ToString()); doc.AddField("ToTimeDay", explorationRecord.ToTime.Day.ToString()); doc.AddField("ToTimeHour", explorationRecord.ToTime.Hour.ToString()); doc.AddField("ToTimeMinute", explorationRecord.ToTime.Minute.ToString()); doc.AddField("Address", explorationRecord.Address); doc.AddField("Weather", explorationRecord.Weather); doc.AddField("EUserName1", explorationRecord.EUserName1); doc.AddField("ECompanyName1", explorationRecord.ECompanyName1); doc.AddField("EUserName2", explorationRecord.EUserName2); doc.AddField("ECompanyName2", explorationRecord.ECompanyName2); doc.AddField("TheEPeopleName1", explorationRecord.TheEPeopleName1); doc.AddField("TheECompanyName1", explorationRecord.TheECompanyName1); doc.AddField("TheEPeopleName2", explorationRecord.TheEPeopleName2); doc.AddField("TheECompanyName2", explorationRecord.TheECompanyName2); doc.AddField("InvitedEPeopleName", explorationRecord.InvitedEPeopleName); doc.AddField("InvitedECompanyName", explorationRecord.InvitedECompanyName); doc.AddField("RecordUserName", explorationRecord.RecordUserName); doc.AddField("RecordCompanyName", explorationRecord.RecordCompanyName); doc.AddField("QFirstPerson1", explorationRecord.QFirstPerson1); doc.AddField("QFirstPersonUser1", explorationRecord.QFirstPersonUser1); doc.AddField("QFirstPerson2", explorationRecord.QFirstPerson2); doc.AddField("QFirstPersonIDC1", explorationRecord.QFirstPersonIDC1); doc.AddField("QFirstPerson2IDC2", explorationRecord.QFirstPerson2IDC2); doc.AddField("ESituation", explorationRecord.ESituation); //doc.AddFootField("FirstPageTest", "测试"); //doc.AddFootField("Test", "测试"); OnNavigationRequest(new Maleos.NavigationRequestEventArgs("Maleos.Modules.OutputDocuemnt", new object[] { doc, "EnforceForm.frmExplorationRecords", explorationRecord.FilePath })); } catch (Exception ex) { CommonInvoke.ErrorMessageBox(ex); } UseWaitCursor = false; }
private void buttonExport_Click(object sender, EventArgs e) { UseWaitCursor = true; Application.DoEvents(); try { if (noticeOfEnquiry == null) { noticeOfEnquiry = new NoticeOfEnquiry(); noticeOfEnquiry.FilePath = Utility.GetFileSavePath() + Utility.BuilderFileName(); } noticeOfEnquiry.Status = 1; SaveData(); WordDocument doc = new WordDocument("询问通知书"); doc.AddField("DocTitle", noticeOfEnquiry.DocTitle); doc.AddField("CompanyName", noticeOfEnquiry.CompanyName); doc.AddField("IllegalTypeName", noticeOfEnquiry.IllegalTypeName); doc.AddField("ToDateTimeYear", noticeOfEnquiry.ToDateTime.Year.ToString()); doc.AddField("ToDateTimeMonth", noticeOfEnquiry.ToDateTime.Month.ToString()); doc.AddField("ToDateTimeDay", noticeOfEnquiry.ToDateTime.Day.ToString()); string Cord = ""; //if (noticeOfEnquiry.IfID == true) // Cord += "√ 身份证 "; //if (noticeOfEnquiry.IfBusinessLicense == true) // Cord += "√ 营业执照 "; //if (noticeOfEnquiry.IfLawID == true) // Cord += "√ 法定代表人身份证明 "; //if (noticeOfEnquiry.IfOther == true) // Cord += "√ " + noticeOfEnquiry.OtherDocument; if (noticeOfEnquiry.IfID == true) Cord += "<font style=\"font-family:fangsong_GB2312;font-size:12pz;line-height:26px;\">√ 身份证</font><br/>"; if (noticeOfEnquiry.IfBusinessLicense == true) Cord += "<font style=\"font-family:fangsong_GB2312;font-size:12pz;line-height:26px;\">√ 营业执照</font><br/>"; if (noticeOfEnquiry.IfLawID == true) Cord += "<font style=\"font-family:fangsong_GB2312;font-size:12pz;line-height:26px;\">√ 法定代表人身份证明</font><br/>"; if (noticeOfEnquiry.IfOther == true) Cord += "<font style=\"font-family:fangsong_GB2312;font-size:12pz;line-height:26px;\">√ " + noticeOfEnquiry.OtherDocument + "</font>"; doc.AddField("Cord", Cord, EFieldType.Html); doc.AddField("DetpAddress", noticeOfEnquiry.DetpAddress); doc.AddField("DetpName", noticeOfEnquiry.DetpName); doc.AddField("DetpPhone", noticeOfEnquiry.DetpPhone); doc.AddFootField("DocManageArea", noticeOfEnquiry.DocManageArea); //doc.AddFootField("FirstPageTest", "测试"); //doc.AddFootField("Test", "测试"); OnNavigationRequest(new Maleos.NavigationRequestEventArgs("Maleos.Modules.OutputDocuemnt", new object[] { doc, "EnforceForm.frmNoticeOfEnquirys", noticeOfEnquiry.FilePath })); } catch (Exception ex) { CommonInvoke.ErrorMessageBox(ex); } UseWaitCursor = false; }
private void buttonExport_Click(object sender, EventArgs e) { UseWaitCursor = true; Application.DoEvents(); try { if (appraisalEntrust == null) { appraisalEntrust = new AppraisalEntrust(); appraisalEntrust.FilePath = Utility.GetFileSavePath() + Utility.BuilderFileName(); } appraisalEntrust.Status = 1; SaveData(); WordDocument doc = new WordDocument("鉴定委托书"); doc.AddField("DocTitle", appraisalEntrust.DocTitle); doc.AddField("AppraisalUnit", appraisalEntrust.AppraisalUnit); doc.AddField("AppraisalPoints", appraisalEntrust.AppraisalPoints); doc.AddField("AppraisaDate", appraisalEntrust.AppraisaDate.ToString("yyyy年MM月dd日")); doc.AddField("ContactUserName", appraisalEntrust.ContactUserName); doc.AddField("ContactUserPhone", appraisalEntrust.ContactUserPhone); doc.AddFootField("DocManageArea", appraisalEntrust.DocManageArea); //doc.AddFootField("FirstPageTest", "测试"); //doc.AddFootField("Test", "测试"); Grid grid = doc.NewGrid(); grid.TableMark = "Table"; int i = 0; foreach (SamplingContent sc in appraisalEntrust.Items) { i++; GridRow row = grid.NewRow(); row.AddRowItem(i.ToString()); row.AddRowItem(sc.SDocTitle); row.AddRowItem(sc.ItemName); row.AddRowItem(sc.ItemRule); row.AddRowItem(sc.Count.ToString() + sc.ItemUnit); } OnNavigationRequest(new Maleos.NavigationRequestEventArgs("Maleos.Modules.OutputDocuemnt", new object[] { doc, "EnforceForm.frmAppraisalEntrust", appraisalEntrust.FilePath })); } catch (Exception ex) { CommonInvoke.ErrorMessageBox(ex); } UseWaitCursor = false; }
private void buttonExport_Click(object sender, EventArgs e) { UseWaitCursor = true; Application.DoEvents(); try { if (putOnRecord == null) { putOnRecord = new PutOnRecord(); putOnRecord.FilePath = Utility.GetFileSavePath() + Utility.BuilderFileName(); } putOnRecord.Status = 1; SaveData(); WordDocument doc = new WordDocument("立案审批表"); doc.AddField("DocTitle", putOnRecord.DocTitle); doc.AddField("IllegalTypeName", putOnRecord.IllegalTypeName); doc.AddField("CaseSourceName", putOnRecord.CaseSourceName); doc.AddField("ThisDate", putOnRecord.ThisDate.ToString("yyyy年M月d日")); doc.AddField("CaseName", putOnRecord.CaseName); doc.AddField("CompanyName", putOnRecord.CompanyName); doc.AddField("PeoplePhone", putOnRecord.PeoplePhone); doc.AddField("PeopleCondition", putOnRecord.PeopleCondition); doc.AddField("PeopleAddress", putOnRecord.PeopleAddress); doc.AddField("PeopleZip", putOnRecord.PeopleZip); doc.AddField("CaseStatus", putOnRecord.CaseStatus); doc.AddField("UndertakerOpinion", putOnRecord.UndertakerOpinion); doc.AddField("UndertakerUserName1", putOnRecord.UndertakerUserName1); doc.AddField("UndertakerUserName2", putOnRecord.UndertakerUserName2); doc.AddField("UndertakerDataDay", putOnRecord.UndertakerData.Day.ToString()); doc.AddField("UndertakerDataYear", putOnRecord.UndertakerData.Year.ToString()); doc.AddField("UndertakerDataMonth", putOnRecord.UndertakerData.Month.ToString()); //doc.AddFootField("FirstPageTest", "测试"); //doc.AddFootField("Test", "测试"); //OutputDocuemnt frm = new OutputDocuemnt(doc); //frm.OpenWindow(this); OnNavigationRequest(new Maleos.NavigationRequestEventArgs("Maleos.Modules.OutputDocuemnt", new object[] { doc, "EnforceForm.frmPutOnRecords", putOnRecord.FilePath })); } catch (Exception ex) { CommonInvoke.ErrorMessageBox(ex); } UseWaitCursor = false; }
private static void AddDocument(string[] attributes, string cmd) { Document textDocument; switch (cmd) { case "AddTextDocument": textDocument = new TextDocument(); break; case "AddPDFDocument": textDocument = new PDFDocument(); break; case "AddWordDocument": textDocument = new WordDocument(); break; case "AddExcelDocument": textDocument = new ExcelDocument(); break; case "AddAudioDocument": textDocument = new AudioDocument(); break; case "AddVideoDocument": textDocument = new VideoDocument(); break; default: textDocument = new TextDocument(); break; } if (attributes.Length > 0) { IList<KeyValuePair<string, object>> attrbList = new List<KeyValuePair<string, object>>(); foreach (var attribute in attributes) { string[] attrPair = attribute.Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries); attrbList.Add(new KeyValuePair<string, object>(attrPair[0], attrPair[1] as object)); } textDocument.SaveAllProperties(attrbList); allDocuments.Add(textDocument); Console.WriteLine("Document added: {0}", textDocument.Name); } else { Console.WriteLine("Document has no name"); } }
private void buttonExport_Click(object sender, EventArgs e) { UseWaitCursor = true; Application.DoEvents(); try { if (spotShoot == null) { spotShoot = new SpotShoot(); spotShoot.FilePath = Utility.GetFileSavePath() + Utility.BuilderFileName(); } spotShoot.Status = 1; SaveData(); WordDocument doc = new WordDocument("现场图片"); doc.AddField("SpotName", spotShoot.SpotName); //pictureBoxShoot1.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp); string dir = spotShoot.Items[0].SpotPhoto.Remove(0, 1); Image image = CommonInvoke.ResizeImageFile(LoadImage(dir).ToArray(), 330, 320); doc.AddField("SpotPhoto1",image , EFieldType.Image); doc.AddField("ShootAddress1", ShootAddress1.Text); doc.AddField("PhotoIllustr1", PhotoIllustr1.Text); //pictureBoxShoot2.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp); dir = spotShoot.Items[1].SpotPhoto.Remove(0, 1); image = CommonInvoke.ResizeImageFile(LoadImage(dir).ToArray(), 330, 320); doc.AddField("SpotPhoto2", image, EFieldType.Image); doc.AddField("ShootAddress2", ShootAddress2.Text); doc.AddField("PhotoIllustr2", PhotoIllustr2.Text); //OutputDocuemnt frm = new OutputDocuemnt(doc); //frm.OpenWindow(this); OnNavigationRequest(new Maleos.NavigationRequestEventArgs("Maleos.Modules.OutputDocuemnt", new object[] { doc, "EnforceForm.frmSpotShoots", spotShoot.FilePath })); } catch (Exception ex) { CommonInvoke.ErrorMessageBox(ex); } UseWaitCursor = false; }
private void buttonExport_Click(object sender, EventArgs e) { UseWaitCursor = true; Application.DoEvents(); try { if (writServiceReceipt == null) { writServiceReceipt = new WritServiceReceipt(); writServiceReceipt.FilePath = Utility.GetFileSavePath() + Utility.BuilderFileName(); } writServiceReceipt.Status = 1; SaveData(); WordDocument doc = new WordDocument("文书送达回执"); doc.AddField("DocTitle", writServiceReceipt.DocTitle); doc.AddField("CaseName", writServiceReceipt.CaseName); doc.AddField("ServiceCompany", writServiceReceipt.ServiceCompany); doc.AddField("DocManageArea", writServiceReceipt.DocManageArea); doc.AddField("Note", writServiceReceipt.Note); Grid grid = doc.NewGrid(); grid.TableMark = "Table"; foreach (WritServiceReceiptItem sc in writServiceReceipt.Items) { GridRow row = grid.NewRow(); row.AddRowItem(sc.WritName); row.AddRowItem(sc.Recipient); row.AddRowItem(sc.ServiceDate.ToString("yyyy年M月d日")); row.AddRowItem(sc.ServiceAddress); row.AddRowItem(sc.ServiceWay); row.AddRowItem(sc.ServicePerson); } OnNavigationRequest(new Maleos.NavigationRequestEventArgs("Maleos.Modules.OutputDocuemnt", new object[] { doc, "EnforceForm.frmWritServiceReceipts", writServiceReceipt.FilePath })); } catch (Exception ex) { CommonInvoke.ErrorMessageBox(ex); } UseWaitCursor = false; }
private void buttonExport_Click(object sender, EventArgs e) { UseWaitCursor = true; Application.DoEvents(); try { if (spotHandelDesision == null) { spotHandelDesision = new SpotHandelDesision(); spotHandelDesision.FilePath = Utility.GetFileSavePath() + Utility.BuilderFileName(); } spotHandelDesision.Status = 1; SaveData(); WordDocument doc = new WordDocument("现场处理措施决定书"); doc.AddField("DocTitle", spotHandelDesision.DocTitle); doc.AddField("CompanyName", spotHandelDesision.CompanyName); doc.AddField("CheckDate", spotHandelDesision.CheckDate.ToString("yyyy年MM月dd日")); doc.AddField("Violations", spotHandelDesision.Violations); doc.AddField("LegalBasis", spotHandelDesision.LegalBasis); doc.AddField("SitHandel", spotHandelDesision.SitHandel); doc.AddField("GovArea", spotHandelDesision.GovArea); doc.AddField("ManageArea", spotHandelDesision.ManageArea); doc.AddField("CourtArea", spotHandelDesision.CourtArea); doc.AddFootField("DocManageArea", spotHandelDesision.DocManageArea); doc.AddFootField("OfficerName1", spotHandelDesision.OfficerName1); doc.AddFootField("CID1", spotHandelDesision.CID1); doc.AddFootField("OfficerName2", spotHandelDesision.OfficerName2); doc.AddFootField("CID2", spotHandelDesision.CID2); //OutputDocuemnt frm = new OutputDocuemnt(doc); //frm.OpenWindow(this); OnNavigationRequest(new Maleos.NavigationRequestEventArgs("Maleos.Modules.OutputDocuemnt", new object[] { doc, "EnforceForm.frmSpotHandelDesisions", spotHandelDesision.FilePath })); } catch (Exception ex) { CommonInvoke.ErrorMessageBox(ex); } UseWaitCursor = false; }
private void buttonExport_Click(object sender, EventArgs e) { UseWaitCursor = true; Application.DoEvents(); try { if (punishmentDecisionUnit == null) { punishmentDecisionUnit = new PunishmentDecisionUnit(); punishmentDecisionUnit.FilePath = Utility.GetFileSavePath() + Utility.BuilderFileName(); } punishmentDecisionUnit.Status = 1; SaveData(); WordDocument doc = new WordDocument("行政处罚决定书"); doc.AddField("DocTitle", punishmentDecisionUnit.DocTitle); doc.AddField("PutOnRecordCaseName", punishmentDecisionUnit.PutOnRecordCaseName); doc.AddField("FieldEAddress", punishmentDecisionUnit.FieldEAddress); doc.AddField("FieldEPeopleZio", punishmentDecisionUnit.FieldEPeopleZio); doc.AddField("FieldEFName", punishmentDecisionUnit.FieldEFName); doc.AddField("FieldEPosition", punishmentDecisionUnit.FieldEPosition); doc.AddField("FieldEPeoplePhone", punishmentDecisionUnit.FieldEPeoplePhone); doc.AddField("IllegalEvidence", punishmentDecisionUnit.IllegalEvidence); doc.AddField("IllegalProvisions", punishmentDecisionUnit.IllegalProvisions); doc.AddField("According", punishmentDecisionUnit.According); doc.AddField("PunishmentAmount", punishmentDecisionUnit.PunishmentAmount); doc.AddField("BankName", punishmentDecisionUnit.BankName); doc.AddField("BankID", punishmentDecisionUnit.BankID); doc.AddField("ReconsiderationUnitName1", punishmentDecisionUnit.ReconsiderationUnitName1); doc.AddField("ReconsiderationUnitName2", punishmentDecisionUnit.ReconsiderationUnitName2); doc.AddField("LitigationUnitName", punishmentDecisionUnit.LitigationUnitName); doc.AddFootField("DocManageArea", punishmentDecisionUnit.DocManageArea); OnNavigationRequest(new Maleos.NavigationRequestEventArgs("Maleos.Modules.OutputDocuemnt", new object[] { doc, "EnforceForm.frmPunishmentDecisionUnits", punishmentDecisionUnit.FilePath })); } catch (Exception ex) { CommonInvoke.ErrorMessageBox(ex); } UseWaitCursor = false; }
private void buttonExport_Click(object sender, EventArgs e) { UseWaitCursor = true; Application.DoEvents(); try { if (orderDeadlineReform == null) { orderDeadlineReform = new OrderDeadlineReform(); orderDeadlineReform.FilePath = Utility.GetFileSavePath() + Utility.BuilderFileName(); } orderDeadlineReform.Status = 1; SaveData(); WordDocument doc = new WordDocument("责令限期整改指令书"); doc.AddField("DocTitle", orderDeadlineReform.DocTitle); doc.AddField("OrderCompany", orderDeadlineReform.OrderCompany); doc.AddField("Matter", orderDeadlineReform.Matter); doc.AddField("MatterCount", orderDeadlineReform.MatterCount); doc.AddField("ReformDate", orderDeadlineReform.ReformDate.ToString("yyyy年M月d日")); doc.AddField("GovArea", orderDeadlineReform.GovArea); doc.AddField("ManageArea", orderDeadlineReform.ManageArea); doc.AddField("CourtArea", orderDeadlineReform.CourtArea); doc.AddFootField("OfficerName1", orderDeadlineReform.OfficerName1); doc.AddFootField("CID1", orderDeadlineReform.CID1); doc.AddFootField("OfficerName2", orderDeadlineReform.OfficerName2); doc.AddFootField("CID2", orderDeadlineReform.CID2); doc.AddFootField("DocManageArea", orderDeadlineReform.DocManageArea); //doc.AddFootField("DocDate", orderDeadlineReform.DocDate.ToString("yyyy年M月d日")); //OutputDocuemnt frm = new OutputDocuemnt(doc); //frm.OpenWindow(this); OnNavigationRequest(new Maleos.NavigationRequestEventArgs("Maleos.Modules.OutputDocuemnt", new object[] { doc, "EnforceForm.frmOrderDeadlineReforms", orderDeadlineReform.FilePath })); } catch (Exception ex) { CommonInvoke.ErrorMessageBox(ex); } UseWaitCursor = false; }
private void buttonExport_Click(object sender, EventArgs e) { UseWaitCursor = true; Application.DoEvents(); try { if (punishmentDiscussRecord == null) { punishmentDiscussRecord = new PunishmentDiscussRecord(); punishmentDiscussRecord.FilePath = Utility.GetFileSavePath() + Utility.BuilderFileName(); } punishmentDiscussRecord.Status = 1; SaveData(); WordDocument doc = new WordDocument("行政处罚集体讨论记录"); doc.AddField("PutOnRecordCaseName", punishmentDiscussRecord.PutOnRecordCaseName); doc.AddField("DiscussDate", punishmentDiscussRecord.DiscussDate.ToString("yyyy年MM月dd日")); doc.AddField("DiscussAddress", punishmentDiscussRecord.DiscussAddress); doc.AddField("HostName", punishmentDiscussRecord.HostName); doc.AddField("ReportName", punishmentDiscussRecord.ReportName); doc.AddField("RecordUserName", punishmentDiscussRecord.RecordUserName); doc.AddField("PDRPeople1", punishmentDiscussRecord.PDRPeople1); doc.AddField("PDRPeople2", punishmentDiscussRecord.PDRPeople2); doc.AddField("DiscussContent", punishmentDiscussRecord.DiscussContent); doc.AddField("RecordContent", punishmentDiscussRecord.RecordContent); doc.AddField("Conclusion", punishmentDiscussRecord.Conclusion); //doc.AddFootField("FirstPageTest", "测试"); //doc.AddFootField("Test", "测试"); OnNavigationRequest(new Maleos.NavigationRequestEventArgs("Maleos.Modules.OutputDocuemnt", new object[] { doc, "EnforceForm.frmPunishmentDiscussRecords", punishmentDiscussRecord.FilePath })); } catch (Exception ex) { CommonInvoke.ErrorMessageBox(ex); } UseWaitCursor = false; }
private void buttonExport_Click(object sender, EventArgs e) { UseWaitCursor = true; Application.DoEvents(); try { if (hearingNotice == null) { hearingNotice = new HearingNotice(); hearingNotice.FilePath = Utility.GetFileSavePath() + Utility.BuilderFileName(); } hearingNotice.Status = 1; SaveData(); WordDocument doc = new WordDocument("听证会通知书"); doc.AddField("DocTitle", hearingNotice.DocTitle); doc.AddField("Informant", hearingNotice.Informant); doc.AddField("About", hearingNotice.About); doc.AddField("HearDate", hearingNotice.HearDate.ToString("yyyy年M月d日 H时 m分")); doc.AddField("HearAddress", hearingNotice.HearAddress); doc.AddField("CompereName", hearingNotice.CompereName); doc.AddField("CompereJob", hearingNotice.CompereJob); doc.AddField("HearName1", hearingNotice.HearName1); doc.AddField("HearJob1", hearingNotice.HearJob1); doc.AddField("HearName2", hearingNotice.HearName2); doc.AddField("HearJob2", hearingNotice.HearJob2); doc.AddField("SecretaryName", hearingNotice.SecretaryName); doc.AddField("SecretaryJob", hearingNotice.SecretaryJob); doc.AddFootField("DocManageArea", hearingNotice.DocManageArea); doc.AddFootField("DocManageArea1", hearingNotice.DocManageArea.Replace("(公章)", "")); OnNavigationRequest(new Maleos.NavigationRequestEventArgs("Maleos.Modules.OutputDocuemnt", new object[] { doc, "EnforceForm.frmHearingNotices", hearingNotice.FilePath })); } catch (Exception ex) { CommonInvoke.ErrorMessageBox(ex); } UseWaitCursor = false; }
private void buttonExport_Click(object sender, EventArgs e) { UseWaitCursor = true; Application.DoEvents(); try { if (caseCancel == null) { caseCancel = new CaseCancel(); caseCancel.FilePath = Utility.GetFileSavePath() + Utility.BuilderFileName(); } caseCancel.Status = 1; SaveData(); WordDocument doc = new WordDocument("案件终止(撤销)审批表"); doc.AddField("DocTitle", caseCancel.DocTitle); doc.AddField("PutOnRecordCaseName", caseCancel.PutOnRecordCaseName); doc.AddField("PutOnRecordThisDate", caseCancel.PutOnRecordThisDate.ToString("yyyy年MM月dd日")); doc.AddField("PutOnRecordDocTitle", caseCancel.PutOnRecordDocTitle); doc.AddField("PutOnRecordPeopleName", caseCancel.PutOnRecordPeopleName); doc.AddField("PutOnRecordFName", caseCancel.PutOnRecordFName); doc.AddField("PutOnRecordPeopleAddress", caseCancel.PutOnRecordPeopleAddress); doc.AddField("PutOnRecordPeoplePhone", caseCancel.PutOnRecordPeoplePhone); doc.AddField("PutOnRecordSourceName", caseCancel.PutOnRecordSourceName); doc.AddField("PutOnRecordUserNames1", caseCancel.PutOnRecordUserNames1 + (caseCancel.PutOnRecordUserNames2!=""?"、"+caseCancel.PutOnRecordUserNames2:"")); doc.AddField("ResearchDetail", caseCancel.ResearchDetail); doc.AddField("RevocationReason", caseCancel.RevocationReason); //doc.AddFootField("FirstPageTest", "测试"); //doc.AddFootField("Test", "测试"); OnNavigationRequest(new Maleos.NavigationRequestEventArgs("Maleos.Modules.OutputDocuemnt", new object[] { doc, "EnforceForm.frmCaseCancels", caseCancel.FilePath })); } catch (Exception ex) { CommonInvoke.ErrorMessageBox(ex); } UseWaitCursor = false; }
private void buttonExport_Click(object sender, EventArgs e) { UseWaitCursor = true; Application.DoEvents(); try { if (forceMeasureDecisionApprove == null) { forceMeasureDecisionApprove = new ForceMeasureDecisionApprove(); forceMeasureDecisionApprove.FilePath = Utility.GetFileSavePath() + Utility.BuilderFileName(); } forceMeasureDecisionApprove.Status = 1; SaveData(); WordDocument doc = new WordDocument("强制措施决定审批表"); doc.Entity = forceMeasureDecisionApprove; doc.AddField("Party", forceMeasureDecisionApprove.Party); doc.AddField("PartyAddress", forceMeasureDecisionApprove.PartyAddress); doc.AddField("LegalRepre", forceMeasureDecisionApprove.LegalRepre); doc.AddField("Tel", forceMeasureDecisionApprove.Tel); doc.AddField("Matter", forceMeasureDecisionApprove.Matter); doc.AddField("Accord", forceMeasureDecisionApprove.Accord); doc.AddField("Supervise", forceMeasureDecisionApprove.Supervise); doc.AddField("SuperviseDate", forceMeasureDecisionApprove.SuperviseDate.ToString("yyyy年M月d日")); doc.AddField("Undertake", forceMeasureDecisionApprove.Undertake); doc.AddField("Principal", forceMeasureDecisionApprove.Principal); doc.AddField("PrincipalDate", forceMeasureDecisionApprove.PrincipalDate.ToString("yyyy年M月d日")); //OutputDocuemnt frm = new OutputDocuemnt(doc); //frm.OpenWindow(this); OnNavigationRequest(new Maleos.NavigationRequestEventArgs("Maleos.Modules.OutputDocuemnt", new object[] { doc, "EnforceForm.frmForceMeasureDecisionApproves", forceMeasureDecisionApprove.FilePath })); } catch (Exception ex) { CommonInvoke.ErrorMessageBox(ex); } UseWaitCursor = false; }
private void buttonExport_Click(object sender, EventArgs e) { UseWaitCursor = true; Application.DoEvents(); try { SaveData(); WordDocument doc = new WordDocument("行政处罚决定书个人"); doc.AddField("DocTitle", punishmentDecisionPersonal.DocTitle); doc.AddField("FieldEPeopleName", punishmentDecisionPersonal.FieldEPeopleName); doc.AddField("FieldEPeopleSex", punishmentDecisionPersonal.FieldEPeopleSex); doc.AddField("FieldEPeopleAge", punishmentDecisionPersonal.FieldEPeopleAge); doc.AddField("FieldEPeoplePhone", punishmentDecisionPersonal.FieldEPeoplePhone); doc.AddField("FieldEPeopleAddress", punishmentDecisionPersonal.FieldEPeopleAddress); doc.AddField("FieldEPeopleCompanyName", punishmentDecisionPersonal.FieldEPeopleCompanyName); doc.AddField("FieldEPeoplePosition", punishmentDecisionPersonal.FieldEPeoplePosition); doc.AddField("FieldEPeopleCompanyAddress", punishmentDecisionPersonal.FieldEPeopleCompanyAddress); doc.AddField("FieldEPeopleZip", punishmentDecisionPersonal.FieldEPeopleZip); doc.AddField("IllegalEvidence", punishmentDecisionPersonal.IllegalEvidence); doc.AddField("IllegalProvisions", punishmentDecisionPersonal.IllegalProvisions); doc.AddField("According", punishmentDecisionPersonal.According); doc.AddField("PunishmentAmount", punishmentDecisionPersonal.PunishmentAmount); doc.AddField("BankName", punishmentDecisionPersonal.BankName); doc.AddField("BankID", punishmentDecisionPersonal.BankID); doc.AddField("ReconsiderationUnitName1", punishmentDecisionPersonal.ReconsiderationUnitName1); doc.AddField("ReconsiderationUnitName2", punishmentDecisionPersonal.ReconsiderationUnitName2); doc.AddField("LitigationUnitName", punishmentDecisionPersonal.LitigationUnitName); doc.AddFootField("DocManageArea", punishmentDecisionPersonal.DocManageArea); OutputDocuemnt frm = new OutputDocuemnt(doc); frm.OpenWindow(this); } catch (Exception ex) { CommonInvoke.ErrorMessageBox(ex); } UseWaitCursor = false; }
public Task <RuleCheckResult> CheckRuleAsync(WordDocument wordDocument) { return(_servant.CheckElementsAsync(RuleName, "Abbildung", wordDocument.Shapes)); }
private void button1_Click(object sender, System.EventArgs e) { try { //Getting Image files Path. string dataPath = Application.StartupPath + @"..\..\..\..\..\..\..\common\Images\DocIO\"; //Getting text files Path. string dataPath1 = Application.StartupPath + @"..\..\..\..\..\..\..\common\Data\"; //Creating a new document WordDocument document = new WordDocument(); //Adding a new section. IWSection section = document.AddSection(); IWParagraph paragraph = section.AddParagraph(); paragraph = section.AddParagraph(); section.PageSetup.Margins.All = 72f; IWTextRange text = paragraph.AppendText("Adventure products"); //Formatting Text text.CharacterFormat.FontName = "Bitstream Vera Sans"; text.CharacterFormat.FontSize = 12f; text.CharacterFormat.Bold = true; section.AddParagraph(); paragraph = section.AddParagraph(); paragraph.ParagraphFormat.LineSpacing = 20f; paragraph.AppendText("In 2000, Adventure Works Cycles bought a small manufacturing plant, Importadores Neptuno, located in Mexico. Importadores Neptuno manufactures several critical subcomponents for the Adventure Works Cycles product line. These subcomponents are shipped to the Bothell location for final product assembly. In 2001, Importadores Neptuno, became the sole manufacturer and distributor of the touring bicycle product group "); paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Justify; #region Line break paragraph.AppendBreak(BreakType.LineBreak); paragraph.AppendBreak(BreakType.LineBreak); #endregion section = document.AddSection(); section.BreakCode = SectionBreakCode.NoBreak; section.PageSetup.Margins.All = 72f; //Adding three columns to section. section.AddColumn(100, 15); section.AddColumn(100, 15); section.AddColumn(100, 15); //Set the columns to be of equal width. section.MakeColumnsEqual(); //Adding a new paragraph to the section. paragraph = section.AddParagraph(); //Adding text. text = paragraph.AppendText("Mountain-200"); //Formatting Text text.CharacterFormat.FontName = "Bitstream Vera Sans"; text.CharacterFormat.FontSize = 12f; text.CharacterFormat.Bold = true; //Adding a new paragraph to the section. section.AddParagraph(); paragraph = section.AddParagraph(); //Inserting an Image. WPicture picture = paragraph.AppendPicture(new Bitmap(Path.Combine(dataPath, "Mountain-200.jpg"))) as WPicture; picture.Width = 120f; picture.Height = 90f; //Adding a new paragraph to the section. section.AddParagraph(); paragraph = section.AddParagraph(); paragraph.ParagraphFormat.LineSpacing = 20f; //Adding text. paragraph.AppendText(@"Product No:BK-M68B-38" + "\n" + "Size: 38" + "\n" + "Weight: 25\n" + "Price: $2,294.99"); paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Justify; // Set column break as true. It navigates the cursor position to the next Column. paragraph.ParagraphFormat.ColumnBreakAfter = true; paragraph = section.AddParagraph(); text = paragraph.AppendText("Mountain-300"); text.CharacterFormat.FontName = "Bitstream Vera Sans"; text.CharacterFormat.FontSize = 12f; text.CharacterFormat.Bold = true; section.AddParagraph(); paragraph = section.AddParagraph(); picture = paragraph.AppendPicture(new Bitmap(Path.Combine(dataPath, "Mountain-300.jpg"))) as WPicture; picture.Width = 120f; picture.Height = 90f; section.AddParagraph(); paragraph = section.AddParagraph(); paragraph.ParagraphFormat.LineSpacing = 20f; paragraph.AppendText(@"Product No:BK-M4-38" + "\n" + "Size: 35\n" + "Weight: 22" + "\n" + " Price: $1,079.99"); paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Justify; paragraph.ParagraphFormat.ColumnBreakAfter = true; paragraph = section.AddParagraph(); text = paragraph.AppendText("Road-150"); text.CharacterFormat.FontName = "Bitstream Vera Sans"; text.CharacterFormat.FontSize = 12f; text.CharacterFormat.Bold = true; section.AddParagraph(); paragraph = section.AddParagraph(); picture = paragraph.AppendPicture(new Bitmap(Path.Combine(dataPath, "Road-550-W.jpg"))) as WPicture; picture.Width = 120f; picture.Height = 90f; section.AddParagraph(); paragraph = section.AddParagraph(); paragraph.ParagraphFormat.LineSpacing = 20f; paragraph.AppendText(@"Product No: BK-R93R-44" + "\n" + "Size: 44" + "\n" + "Weight: 14" + "\n" + "Price: $3,578.27"); paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Justify; section = document.AddSection(); section.BreakCode = SectionBreakCode.NoBreak; section.PageSetup.Margins.All = 72f; text = section.AddParagraph().AppendText("First Look\n"); //Formatting Text text.CharacterFormat.FontName = "Bitstream Vera Sans"; text.CharacterFormat.FontSize = 12f; text.CharacterFormat.Bold = true; paragraph = section.AddParagraph(); paragraph.ParagraphFormat.LineSpacing = 20f; paragraph.AppendText("Adventure Works Cycles, the fictitious company, is a large, multinational manufacturing company. The company manufactures and sells metal and composite bicycles to North American, European and Asian commercial markets. While its base operation is located in Bothell, Washington with 290 employees, several regional sales teams are located throughout their market base."); paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Justify; paragraph.ParagraphFormat.PageBreakAfter = true; paragraph = section.AddParagraph(); text = paragraph.AppendText("Introduction\n"); //Formatting Text text.CharacterFormat.FontName = "Bitstream Vera Sans"; text.CharacterFormat.FontSize = 12f; text.CharacterFormat.Bold = true; paragraph = section.AddParagraph(); paragraph.ParagraphFormat.LineSpacing = 20f; paragraph.AppendText("In 2000, Adventure Works Cycles bought a small manufacturing plant, Importadores Neptuno, located in Mexico. Importadores Neptuno manufactures several critical subcomponents for the Adventure Works Cycles product line. These subcomponents are shipped to the Bothell location for final product assembly. In 2001, Importadores Neptuno, became the sole manufacturer and distributor of the touring bicycle product group."); paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Justify; //Save as doc format if (wordDocRadioBtn.Checked) { //Saving the document to disk. document.Save("Sample.doc"); //Message box confirmation to view the created document. if (MessageBoxAdv.Show("Do you want to view the generated Word document?", "Document has been created", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { //Launching the MS Word file using the default Application.[MS Word Or Free WordViewer] #if NETCORE System.Diagnostics.Process process = new System.Diagnostics.Process(); process.StartInfo = new System.Diagnostics.ProcessStartInfo("Sample.doc") { UseShellExecute = true }; process.Start(); #else System.Diagnostics.Process.Start("Sample.doc"); #endif //Exit this.Close(); } } //Save as docx format else if (wordDocxRadioBtn.Checked) { //Saving the document as .docx document.Save("Sample.docx", FormatType.Docx); //Message box confirmation to view the created document. if (MessageBoxAdv.Show("Do you want to view the generated Word document?", "Document has been created", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { try { //Launching the MS Word file using the default Application.[MS Word Or Free WordViewer] #if NETCORE System.Diagnostics.Process process = new System.Diagnostics.Process(); process.StartInfo = new System.Diagnostics.ProcessStartInfo("Sample.docx") { UseShellExecute = true }; process.Start(); #else System.Diagnostics.Process.Start("Sample.docx"); #endif //Exit this.Close(); } catch (Win32Exception ex) { MessageBoxAdv.Show("Microsoft Word Viewer or Microsoft Word is not installed in this system"); Console.WriteLine(ex.ToString()); } } } //Save as pdf format else if (pdfRadioBtn.Checked) { DocToPDFConverter converter = new DocToPDFConverter(); //Convert word document into PDF document PdfDocument pdfDoc = converter.ConvertToPDF(document); //Save the pdf file pdfDoc.Save("Sample.pdf"); //Message box confirmation to view the created document. if (MessageBoxAdv.Show("Do you want to view the generated PDF?", " Document has been created", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { try { #if NETCORE System.Diagnostics.Process process = new System.Diagnostics.Process(); process.StartInfo = new System.Diagnostics.ProcessStartInfo("Sample.pdf") { UseShellExecute = true }; process.Start(); #else System.Diagnostics.Process.Start("Sample.pdf"); #endif //Exit this.Close(); } catch (Exception ex) { MessageBoxAdv.Show("PDF Viewer is not installed in this system"); Console.WriteLine(ex.ToString()); } } } else { // Exit this.Close(); } } catch (Exception Ex) { MessageBox.Show(Ex.Message); } }
void CreateEndNote(WordDocument document) { //Add a new section to the document. IWSection section = document.AddSection(); //Adding a new paragraph to the section. IWParagraph paragraph = section.AddParagraph(); IWTextRange textRange = paragraph.AppendText("\t\t\t\t\tDemo for Endnote"); textRange.CharacterFormat.TextColor = Color.Black; textRange.CharacterFormat.Bold = true; textRange.CharacterFormat.FontSize = 20; section.AddParagraph(); section.AddParagraph(); paragraph = section.AddParagraph(); WFootnote footnote = new WFootnote(document); footnote = paragraph.AppendFootnote(FootnoteType.Endnote); footnote.MarkerCharacterFormat.SubSuperScript = SubSuperScript.SuperScript; //Insert Text into the paragraph paragraph.AppendText("Google").CharacterFormat.Bold = true; paragraph = section.AddParagraph(); paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center; #if NETCORE paragraph.AppendPicture(Image.FromFile(@"..\..\..\..\..\..\..\..\Common\images\DocIO\google.png")); #else paragraph.AppendPicture(Image.FromFile(@"..\..\..\..\..\..\..\Common\images\DocIO\google.png")); #endif paragraph = footnote.TextBody.AddParagraph(); paragraph.AppendText(" Google is the most famous search engines in the Word "); section = document.AddSection(); section.BreakCode = SectionBreakCode.NoBreak; //Adding a new paragraph to the section. paragraph = section.AddParagraph(); paragraph = section.AddParagraph(); footnote = paragraph.AppendFootnote(FootnoteType.Endnote); footnote.MarkerCharacterFormat.SubSuperScript = SubSuperScript.SuperScript; //Insert Text into the paragraph paragraph.AppendText("Yahoo").CharacterFormat.Bold = true; paragraph = section.AddParagraph(); paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center; #if NETCORE paragraph.AppendPicture(Image.FromFile(@"..\..\..\..\..\..\..\..\Common\images\DocIO\yahoo.gif")); #else paragraph.AppendPicture(Image.FromFile(@"..\..\..\..\..\..\..\Common\images\DocIO\yahoo.gif")); #endif paragraph = footnote.TextBody.AddParagraph(); paragraph.AppendText(" Yahoo experience makes it easier to discover the news and information that you care about most. "); section = document.AddSection(); section.BreakCode = SectionBreakCode.NoBreak; //Adding a new paragraph to the section. paragraph = section.AddParagraph(); paragraph = section.AddParagraph(); footnote = paragraph.AppendFootnote(FootnoteType.Endnote); footnote.MarkerCharacterFormat.SubSuperScript = SubSuperScript.SuperScript; //Insert Text into the paragraph paragraph.AppendText("Northwind Traders").CharacterFormat.Bold = true; paragraph = section.AddParagraph(); paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center; #if NETCORE paragraph.AppendPicture(Image.FromFile(@"..\..\..\..\..\..\..\..\Common\images\DocIO\Northwind_logo.png")); #else paragraph.AppendPicture(Image.FromFile(@"..\..\..\..\..\..\..\Common\images\DocIO\Northwind_logo.png")); #endif paragraph = footnote.TextBody.AddParagraph(); paragraph.AppendText(" The Northwind sample database (Northwind.mdb) is included with all versions of Access. It provides data you can experiment with and database objects that demonstrate features you might want to implement in your own databases "); //Set the number format for the Endnote. document.EndnoteNumberFormat = Syncfusion.DocIO.FootEndNoteNumberFormat.LowerCaseRoman; document.RestartIndexForEndnote = Syncfusion.DocIO.EndnoteRestartIndex.DoNotRestart; //Set the Endnote position. document.EndnotePosition = Syncfusion.DocIO.EndnotePosition.DisplayEndOfSection; }
/// <summary> /// Creates an expansion of triple scalar product /// </summary> /// <param name="paragraph">Represents a paragraph to add MathML element</param> private void CreateTripleScalarProduct(IWParagraph paragraph) { WordDocument document = paragraph.Document; //Creates a MathML element WMath math = paragraph.AppendMath(); //Adds an office math IOfficeMath officeMath = math.MathParagraph.Maths.Add(); #region Math text //Unicode value of middle dot string middleDot = "\u00B7"; string multiplicationSign = "\u00D7"; string text = "A" + middleDot + "B" + multiplicationSign + "C"; //Adds a math item IOfficeMathRunElement officeMathParaItem = AddMathText(document, officeMath, text); //Sets style for math text officeMathParaItem.MathFormat.Style = MathStyleType.Bold; //Adds math text officeMathParaItem = AddMathText(document, officeMath, "="); //Sets style for math text officeMathParaItem.MathFormat.Style = MathStyleType.Bold; //Adds math text text = "A" + multiplicationSign + "B" + middleDot + "C"; officeMathParaItem = AddMathText(document, officeMath, text); //Sets style for math text officeMathParaItem.MathFormat.Style = MathStyleType.Bold; //Adds math text officeMathParaItem = AddMathText(document, officeMath, "="); #endregion #region Delimiter //Adds a delimiter IOfficeMathDelimiter mathDelimiter = officeMath.Functions.Add(MathFunctionType.Delimiter) as IOfficeMathDelimiter; //Sets begin character for delimiter mathDelimiter.BeginCharacter = "|"; //Sets end character for delimiter mathDelimiter.EndCharacter = "|"; //Apply formats for delimiter mathDelimiter.ControlProperties = new WCharacterFormat(document); (mathDelimiter.ControlProperties as WCharacterFormat).Italic = true; //Adds arguments for delimiter officeMath = mathDelimiter.Equation.Add() as IOfficeMath; #region Matrix //Add matrix into delimiter IOfficeMathMatrix mathMatrix = officeMath.Functions.Add(MathFunctionType.Matrix) as IOfficeMathMatrix; //Add columns in matrix mathMatrix.Columns.Add(); mathMatrix.Columns.Add(); mathMatrix.Columns.Add(); #region First row //Adds a new row IOfficeMathMatrixRow mathMatrixRow = mathMatrix.Rows.Add(); ///Add values to row AddMatrixRowValues(document, mathMatrixRow, "A"); #endregion #region Second row //Adds a new row mathMatrixRow = mathMatrix.Rows.Add(); ///Add values to row AddMatrixRowValues(document, mathMatrixRow, "B"); #endregion #region Third row //Adds a new row mathMatrixRow = mathMatrix.Rows.Add(); ///Add values to row AddMatrixRowValues(document, mathMatrixRow, "C"); #endregion #endregion #endregion }
/// <summary> /// Export the UI data to Word document. /// </summary> /// <param name="invoiceItems">The InvoiceItems.</param> /// <param name="billInfo">The BillingInformation.</param> /// <param name="totalDue">The TotalDue.</param> public void CreateWord(IList <InvoiceItem> invoiceItems, BillingInformation billInfo, double totalDue) { try { //Load Template document stream Assembly assembly = typeof(MainPage).Assembly; Stream inputStream = assembly.GetManifestResourceStream("Invoice.Assets.Template.docx"); //Create instance WordDocument document = new WordDocument(); //Open Template document document.Open(inputStream, FormatType.Word2013); //Dispose input stream inputStream.Dispose(); //Set Clear Fields to false document.MailMerge.ClearFields = false; //Create Mail Merge Data Table MailMergeDataTable mailMergeDataTable = new MailMergeDataTable("Invoice", invoiceItems); //Executes mail merge using the data generated in the app. document.MailMerge.ExecuteGroup(mailMergeDataTable); //Mail Merge Billing information string[] fieldNames = { "Name", "Address", "Date", "InvoiceNumber", "DueDate", "TotalDue" }; string[] fieldValues = { billInfo.Name, billInfo.Address, billInfo.Date.ToString("d"), billInfo.InvoiceNumber, billInfo.DueDate.ToString("d"), totalDue.ToString("#,###.00", CultureInfo.InvariantCulture) }; document.MailMerge.Execute(fieldNames, fieldValues); try { //Create Output file in Document library location document.Save("Invoice.docx", FormatType.Docx); //Save as Docx format //Message box confirmation to view the created PDF document. if (MessageBox.Show("Do you want to view the Word file?", "Word Document Created", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes) { try { //Launching the PDF file using the default Application.[Acrobat Reader] System.Diagnostics.Process.Start("Invoice.docx"); //this.Close(); } catch (Win32Exception ex) { MessageBox.Show("Word 2013 is not installed in this system"); Console.WriteLine(ex.ToString()); } } //Close instance document.Close(); } catch (Exception ex) { if (ex is IOException) { MessageBox.Show("Please close the file (" + Directory.GetCurrentDirectory() + "\\Invoice.docx" + ") then try generating the document using DocIO.", "File is already open", MessageBoxButton.OK, MessageBoxImage.Error); } else { MessageBox.Show("The input document could not be processed, Could you please email the document to [email protected] for trouble shooting", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } } catch (Exception Ex) { MessageBox.Show(Ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
public ActionResult EmployeeReport(string Group1, string Button) { if (Group1 == null) { return(View()); } if (Button == "View Template") { return(new TemplateResult("EmployeesReportDemo.doc", ResolveApplicationDataPath("App_Data\\DocIO"), HttpContext.ApplicationInstance.Response)); } AppDomain.CurrentDomain.SetData("SQLServerCompactEditionUnderWebHosting", true); DataSet dataset = new DataSet(); //Access the database and get the NorthWind SqlCeConnection conn = new SqlCeConnection(); if (conn.ServerVersion.StartsWith("3.5")) { conn.ConnectionString = "Data Source = " + ResolveApplicationDataPath("NorthwindIO_3.5.sdf", "App_Data"); } else { conn.ConnectionString = "Data Source = " + ResolveApplicationDataPath("NorthwindIO.sdf", "App_Data"); } conn.Open(); SqlCeDataAdapter adapter = new SqlCeDataAdapter("Select TOP(5) * from EmployeesReport", conn); adapter.Fill(dataset); adapter.Dispose(); conn.Close(); System.Data.DataTable table = dataset.Tables[0]; string dataPath = ResolveApplicationDataPath("EmployeesReportDemo.doc", "App_Data\\DocIO"); // Creating a new document. WordDocument document = new WordDocument(); // Load template document.Open(dataPath, FormatType.Doc); // Set table name as Employess for template mergefield reference. table.TableName = "Employees"; // Execute Mail Merge with groups. document.MailMerge.ExecuteGroup(table); try { #region Document SaveOption //Save as .doc format if (Group1 == "WordDoc") { return(document.ExportAsActionResult("Sample.doc", FormatType.Doc, HttpContext.ApplicationInstance.Response, HttpContentDisposition.Attachment)); } //Save as .docx format else if (Group1 == "WordDocx") { return(document.ExportAsActionResult("Sample.docx", FormatType.Docx, HttpContext.ApplicationInstance.Response, HttpContentDisposition.Attachment)); } // Save as WordML(.xml) format else if (Group1 == "WordML") { return(document.ExportAsActionResult("Sample.xml", FormatType.WordML, HttpContext.ApplicationInstance.Response, HttpContentDisposition.Attachment)); } //Save as .pdf format else if (Group1 == "Pdf") { DocToPDFConverter converter = new DocToPDFConverter(); PdfDocument pdfDoc = converter.ConvertToPDF(document); return(pdfDoc.ExportAsActionResult("sample.pdf", HttpContext.ApplicationInstance.Response, HttpReadType.Save)); } #endregion Document SaveOption } catch (Exception) { } return(View()); }
/// <summary> /// Creates a Fourier series equation /// </summary> /// <param name="paragraph">Represents a paragraph to add MathML element</param> private void CreateFourierseries(IWParagraph paragraph) { WordDocument document = paragraph.Document; //Creates a new MathML element WMath math = paragraph.AppendMath(); //Adds a math IOfficeMath officeMath = math.MathParagraph.Maths.Add(); //Adds a math text AddMathText(document, officeMath, "f"); //Adds a math delimiter IOfficeMathDelimiter mathDelimiter = math.MathParagraph.Maths.Add().Functions.Add(MathFunctionType.Delimiter) as IOfficeMathDelimiter; //Adds a math in the delimiter officeMath = mathDelimiter.Equation.Add() as IOfficeMath; //Adds a math text AddMathText(document, officeMath, "x"); AddMathText(document, math.MathParagraph.Maths.Add(), "="); //Adds a Subscript equation IOfficeMathScript mathScript = AddMathScript(math.MathParagraph.Maths.Add(), MathScriptType.Subscript); //Adds a math text AddMathText(document, mathScript.Equation, "a"); AddMathText(document, mathScript.Script, "0"); //Adds a math text AddMathText(document, math.MathParagraph.Maths.Add(), "+"); //Adds a math n-array IOfficeMathNArray mathNAry = math.MathParagraph.Maths.Add().Functions.Add(MathFunctionType.NArray) as IOfficeMathNArray; //Unicode value of n-array summation string sigma = "\u2211"; //Sets the value as the n-array character mathNAry.NArrayCharacter = sigma; mathNAry.HasGrow = true; //Adds a math text AddMathText(document, mathNAry.Subscript, "n=1"); //Adds a math text string infinitySymbol = "\u221E"; AddMathText(document, mathNAry.Superscript, infinitySymbol); //Adds a math delimiter mathDelimiter = mathNAry.Equation.Functions.Add(MathFunctionType.Delimiter) as IOfficeMathDelimiter; //Adds an math in the delimiter equation collection officeMath = mathDelimiter.Equation.Add() as IOfficeMath; //Adds a math script mathScript = AddMathScript(officeMath, MathScriptType.Subscript); //Adds a math text AddMathText(document, mathScript.Equation, "a"); //Adds a math text AddMathText(document, mathScript.Script, "n"); //Adds a math function IOfficeMathFunction mathFunction = officeMath.Functions.Add(MathFunctionType.Function) as IOfficeMathFunction; //Adds a math text IOfficeMathRunElement mathParaItem = AddMathText(document, mathFunction.FunctionName, "cos"); mathParaItem.MathFormat.Style = MathStyleType.Regular; //Adds a math fraction IOfficeMathFraction mathFraction = mathFunction.Equation.Functions.Add(MathFunctionType.Fraction) as IOfficeMathFraction; //Adds a math text //Unicode value of PI string pi = "\uD835\uDF0B"; string text = "n" + pi + "x"; AddMathText(document, mathFraction.Numerator, text); AddMathText(document, mathFraction.Denominator, "L"); //Adds a math text AddMathText(document, officeMath, "+"); //Adds a math script mathScript = AddMathScript(officeMath, MathScriptType.Subscript); //Adds a math text AddMathText(document, mathScript.Equation, "b"); AddMathText(document, mathScript.Script, "n"); //Adds a function mathFunction = officeMath.Functions.Add(MathFunctionType.Function) as IOfficeMathFunction; //Adds a math text mathParaItem = AddMathText(document, mathFunction.FunctionName, "sin"); mathParaItem.MathFormat.Style = MathStyleType.Regular; //Adds a math fraction element mathFraction = mathFunction.Equation.Functions.Add(MathFunctionType.Fraction) as IOfficeMathFraction; //Adds a math text for numerator AddMathText(document, mathFraction.Numerator, text); //Adds a math text for denominator AddMathText(document, mathFraction.Denominator, "L"); }
private async void Save(bool isDocFormat, WordDocument document) { StorageFile stgFile; if (!(Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))) { FileSavePicker savePicker = new FileSavePicker(); savePicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary; // Dropdown of file types the user can save the file as if (isDocFormat) { savePicker.FileTypeChoices.Add("Word Document", new List <string>() { ".doc" }); } else { savePicker.FileTypeChoices.Add("Word Document", new List <string>() { ".docx" }); } // Default file name if the user does not type one in or select a file to replace savePicker.SuggestedFileName = "Sample"; stgFile = await savePicker.PickSaveFileAsync(); } else { StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder; stgFile = await local.CreateFileAsync("WordDocument.docx", CreationCollisionOption.ReplaceExisting); } if (stgFile != null) { MemoryStream stream = new MemoryStream(); if (isDocFormat) { await document.SaveAsync(stream, FormatType.Doc); } else { await document.SaveAsync(stream, FormatType.Docx); } document.Close(); stream.Position = 0; Windows.Storage.Streams.IRandomAccessStream fileStream = await stgFile.OpenAsync(FileAccessMode.ReadWrite); Stream st = fileStream.AsStreamForWrite(); st.SetLength(0); st.Write((stream as MemoryStream).ToArray(), 0, (int)stream.Length); st.Flush(); st.Dispose(); fileStream.Dispose(); MessageDialog msgDialog = new MessageDialog("Do you want to view the Document?", "File has been created successfully."); UICommand yesCmd = new UICommand("Yes"); msgDialog.Commands.Add(yesCmd); UICommand noCmd = new UICommand("No"); msgDialog.Commands.Add(noCmd); IUICommand cmd = await msgDialog.ShowAsync(); if (cmd == yesCmd) { // Launch the retrieved file bool success = await Windows.System.Launcher.LaunchFileAsync(stgFile); } } }
private void button1_Click(object sender, System.EventArgs e) { try { //Creates a new word document instance WordDocument document = new WordDocument(); //Adds new section to the document IWSection section = document.AddSection(); //Sets page margins document.LastSection.PageSetup.Margins.All = 72; //Adds new paragraph to the section IWParagraph paragraph = section.AddParagraph(); //Appends text to paragraph IWTextRange textRange = paragraph.AppendText("Mathematical equations"); textRange.CharacterFormat.FontSize = 28; paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center; paragraph.ParagraphFormat.AfterSpacing = 12; #region Sum to the power of n //Adds new paragraph to the section paragraph = AddParagraph(section, "This is an expansion of the sum (1+X) to the power of n."); //Creates an equation with sum to the power of N CreateSumToThePowerOfN(paragraph); #endregion #region Fourier series //Adds new paragraph to the section paragraph = AddParagraph(section, "This is a Fourier series for the function of period 2L"); //Creates a Fourier series equation CreateFourierseries(paragraph); #endregion #region Triple scalar product //Adds new paragraph to the section paragraph = AddParagraph(section, "This is an expansion of triple scalar product"); //Creates a triple scalar product equation CreateTripleScalarProduct(paragraph); #endregion #region Gamma function //Adds new paragraph to the section paragraph = AddParagraph(section, "This is an expansion of gamma function"); //Creates a gamma function equation CreateGammaFunction(paragraph); #endregion #region Vector relation //Adds new paragraph to the section paragraph = AddParagraph(section, "This is an expansion of vector relation "); //Creates a vector relation equation CreateVectorRelation(paragraph); #endregion //Save as docx format if (wordDocxRadioBtn.Checked) { //Saving the document as .docx document.Save("Create Equation.docx", FormatType.Docx); //Message box confirmation to view the created document. if (MessageBoxAdv.Show("Do you want to view the generated Word document?", "Document has been created", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { try { //Launching the MS Word file using the default Application.[MS Word Or Free WordViewer] #if NETCORE System.Diagnostics.Process process = new System.Diagnostics.Process(); process.StartInfo = new System.Diagnostics.ProcessStartInfo("Create Equation.docx") { UseShellExecute = true }; process.Start(); #else System.Diagnostics.Process.Start("Create Equation.docx"); #endif //Exit this.Close(); } catch (Win32Exception ex) { MessageBoxAdv.Show("Microsoft Word Viewer or Microsoft Word is not installed in this system"); Console.WriteLine(ex.ToString()); } } } //Save as pdf format else if (pdfRadioBtn.Checked) { DocToPDFConverter converter = new DocToPDFConverter(); //Convert word document into PDF document PdfDocument pdfDoc = converter.ConvertToPDF(document); //Save the pdf file pdfDoc.Save("Create Equation.pdf"); converter.Dispose(); pdfDoc.Close(); //Message box confirmation to view the created document. if (MessageBoxAdv.Show("Do you want to view the generated PDF?", " Document has been created", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { try { #if NETCORE System.Diagnostics.Process process = new System.Diagnostics.Process(); process.StartInfo = new System.Diagnostics.ProcessStartInfo("Create Equation.pdf") { UseShellExecute = true }; process.Start(); #else System.Diagnostics.Process.Start("Create Equation.pdf"); #endif //Exit this.Close(); } catch (Exception ex) { MessageBoxAdv.Show("PDF Viewer is not installed in this system"); Console.WriteLine(ex.ToString()); } } } else { // Exit this.Close(); } } catch (Exception Ex) { MessageBox.Show(Ex.Message); } }
private void Button_Click_1(object sender, RoutedEventArgs e) { // Creating a new document. WordDocument document = new WordDocument(); //Adding a new section to the document. WSection section = document.AddSection() as WSection; //Set Margin of the section section.PageSetup.Margins.All = 72; //Set page size of the section section.PageSetup.PageSize.Width = 612; section.PageSetup.PageSize.Height = 792; //Create Paragraph styles WParagraphStyle style = document.AddParagraphStyle("Normal") as WParagraphStyle; style.CharacterFormat.FontName = "Calibri"; style.CharacterFormat.FontSize = 11f; style.ParagraphFormat.BeforeSpacing = 0; style.ParagraphFormat.AfterSpacing = 8; style.ParagraphFormat.LineSpacing = 13.8f; style = document.AddParagraphStyle("Heading 1") as WParagraphStyle; style.ApplyBaseStyle("Normal"); style.CharacterFormat.FontName = "Calibri Light"; style.CharacterFormat.FontSize = 16f; style.CharacterFormat.TextColor = Color.FromArgb(46, 116, 181); style.ParagraphFormat.BeforeSpacing = 12; style.ParagraphFormat.AfterSpacing = 0; style.ParagraphFormat.Keep = true; style.ParagraphFormat.KeepFollow = true; style.ParagraphFormat.OutlineLevel = OutlineLevel.Level1; IWParagraph paragraph = section.HeadersFooters.Header.AddParagraph(); Stream imageStream = execAssm.GetManifestResourceStream("Syncfusion.SampleBrowser.UWP.DocIO.DocIO.Assets.AdventureCycle.jpg"); //Appends picture to the paragraph. WPicture picture = paragraph.AppendPicture(imageStream) as WPicture; picture.TextWrappingStyle = TextWrappingStyle.InFrontOfText; picture.VerticalOrigin = VerticalOrigin.Margin; picture.VerticalPosition = -45; picture.HorizontalOrigin = HorizontalOrigin.Column; picture.HorizontalPosition = 263.5f; picture.WidthScale = 20; picture.HeightScale = 15; paragraph.ApplyStyle("Normal"); paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Left; WTextRange textRange = paragraph.AppendText("Adventure Works Cycles") as WTextRange; textRange.CharacterFormat.FontSize = 12f; textRange.CharacterFormat.FontName = "Calibri"; //Appends paragraph. paragraph = section.AddParagraph(); paragraph.ApplyStyle("Heading 1"); paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center; textRange = paragraph.AppendText("Adventure Works Cycles") as WTextRange; textRange.CharacterFormat.FontSize = 18f; textRange.CharacterFormat.FontName = "Calibri"; //Appends paragraph. paragraph = section.AddParagraph(); paragraph.ParagraphFormat.FirstLineIndent = 36; paragraph.BreakCharacterFormat.FontSize = 12f; textRange = paragraph.AppendText("Adventure Works Cycles, the fictitious company on which the AdventureWorks sample databases are based, is a large, multinational manufacturing company. The company manufactures and sells metal and composite bicycles to North American, European and Asian commercial markets. While its base operation is located in Bothell, Washington with 290 employees, several regional sales teams are located throughout their market base.") as WTextRange; textRange.CharacterFormat.FontSize = 12f; paragraph = section.AddParagraph(); paragraph.ParagraphFormat.FirstLineIndent = 36; paragraph.BreakCharacterFormat.FontSize = 12f; textRange = paragraph.AppendText("In 2000, Adventure Works Cycles bought a small manufacturing plant, Importadores Neptuno, located in Mexico. Importadores Neptuno manufactures several critical subcomponents for the Adventure Works Cycles product line. These subcomponents are shipped to the Bothell location for final product assembly. In 2001, Importadores Neptuno, became the sole manufacturer and distributor of the touring bicycle product group.") as WTextRange; textRange.CharacterFormat.FontSize = 12f; paragraph = section.AddParagraph(); paragraph.ApplyStyle("Heading 1"); paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Left; textRange = paragraph.AppendText("Product Overview") as WTextRange; textRange.CharacterFormat.FontSize = 16f; textRange.CharacterFormat.FontName = "Calibri"; //Appends table. IWTable table = section.AddTable(); table.ResetCells(3, 2); table.TableFormat.Borders.BorderType = BorderStyle.None; table.TableFormat.IsAutoResized = true; //Appends paragraph. paragraph = table[0, 0].AddParagraph(); paragraph.ParagraphFormat.AfterSpacing = 0; paragraph.BreakCharacterFormat.FontSize = 12f; //Appends picture to the paragraph. imageStream = execAssm.GetManifestResourceStream("Syncfusion.SampleBrowser.UWP.DocIO.DocIO.Assets.Mountain-200.jpg"); //Appends picture to the paragraph. picture = paragraph.AppendPicture(imageStream) as WPicture; picture.TextWrappingStyle = TextWrappingStyle.TopAndBottom; picture.VerticalOrigin = VerticalOrigin.Paragraph; picture.VerticalPosition = 4.5f; picture.HorizontalOrigin = HorizontalOrigin.Column; picture.HorizontalPosition = -2.15f; picture.WidthScale = 79; picture.HeightScale = 79; //Appends paragraph. paragraph = table[0, 1].AddParagraph(); paragraph.ApplyStyle("Heading 1"); paragraph.ParagraphFormat.AfterSpacing = 0; paragraph.ParagraphFormat.LineSpacing = 12f; paragraph.AppendText("Mountain-200"); //Appends paragraph. paragraph = table[0, 1].AddParagraph(); paragraph.ParagraphFormat.AfterSpacing = 0; paragraph.ParagraphFormat.LineSpacing = 12f; paragraph.BreakCharacterFormat.FontSize = 12f; paragraph.BreakCharacterFormat.FontName = "Times New Roman"; textRange = paragraph.AppendText("Product No: BK-M68B-38\r") as WTextRange; textRange.CharacterFormat.FontSize = 12f; textRange.CharacterFormat.FontName = "Times New Roman"; textRange = paragraph.AppendText("Size: 38\r") as WTextRange; textRange.CharacterFormat.FontSize = 12f; textRange.CharacterFormat.FontName = "Times New Roman"; textRange = paragraph.AppendText("Weight: 25\r") as WTextRange; textRange.CharacterFormat.FontSize = 12f; textRange.CharacterFormat.FontName = "Times New Roman"; textRange = paragraph.AppendText("Price: $2,294.99\r") as WTextRange; textRange.CharacterFormat.FontSize = 12f; textRange.CharacterFormat.FontName = "Times New Roman"; //Appends paragraph. paragraph = table[0, 1].AddParagraph(); paragraph.ParagraphFormat.AfterSpacing = 0; paragraph.ParagraphFormat.LineSpacing = 12f; paragraph.BreakCharacterFormat.FontSize = 12f; //Appends paragraph. paragraph = table[1, 0].AddParagraph(); paragraph.ApplyStyle("Heading 1"); paragraph.ParagraphFormat.AfterSpacing = 0; paragraph.ParagraphFormat.LineSpacing = 12f; paragraph.AppendText("Mountain-300 "); //Appends paragraph. paragraph = table[1, 0].AddParagraph(); paragraph.ParagraphFormat.AfterSpacing = 0; paragraph.ParagraphFormat.LineSpacing = 12f; paragraph.BreakCharacterFormat.FontSize = 12f; paragraph.BreakCharacterFormat.FontName = "Times New Roman"; textRange = paragraph.AppendText("Product No: BK-M47B-38\r") as WTextRange; textRange.CharacterFormat.FontSize = 12f; textRange.CharacterFormat.FontName = "Times New Roman"; textRange = paragraph.AppendText("Size: 35\r") as WTextRange; textRange.CharacterFormat.FontSize = 12f; textRange.CharacterFormat.FontName = "Times New Roman"; textRange = paragraph.AppendText("Weight: 22\r") as WTextRange; textRange.CharacterFormat.FontSize = 12f; textRange.CharacterFormat.FontName = "Times New Roman"; textRange = paragraph.AppendText("Price: $1,079.99\r") as WTextRange; textRange.CharacterFormat.FontSize = 12f; textRange.CharacterFormat.FontName = "Times New Roman"; //Appends paragraph. paragraph = table[1, 0].AddParagraph(); paragraph.ParagraphFormat.AfterSpacing = 0; paragraph.ParagraphFormat.LineSpacing = 12f; paragraph.BreakCharacterFormat.FontSize = 12f; //Appends paragraph. paragraph = table[1, 1].AddParagraph(); paragraph.ApplyStyle("Heading 1"); paragraph.ParagraphFormat.LineSpacing = 12f; //Appends picture to the paragraph. imageStream = execAssm.GetManifestResourceStream("Syncfusion.SampleBrowser.UWP.DocIO.DocIO.Assets.Mountain-300.jpg"); //Appends picture to the paragraph. picture = paragraph.AppendPicture(imageStream) as WPicture; picture.TextWrappingStyle = TextWrappingStyle.TopAndBottom; picture.VerticalOrigin = VerticalOrigin.Paragraph; picture.VerticalPosition = 8.2f; picture.HorizontalOrigin = HorizontalOrigin.Column; picture.HorizontalPosition = -14.95f; picture.WidthScale = 75; picture.HeightScale = 75; //Appends paragraph. paragraph = table[2, 0].AddParagraph(); paragraph.ApplyStyle("Heading 1"); paragraph.ParagraphFormat.LineSpacing = 12f; //Appends picture to the paragraph. imageStream = execAssm.GetManifestResourceStream("Syncfusion.SampleBrowser.UWP.DocIO.DocIO.Assets.Road-550-W.jpg"); //Appends picture to the paragraph. picture = paragraph.AppendPicture(imageStream) as WPicture; picture.TextWrappingStyle = TextWrappingStyle.TopAndBottom; picture.VerticalOrigin = VerticalOrigin.Paragraph; picture.VerticalPosition = 3.75f; picture.HorizontalOrigin = HorizontalOrigin.Column; picture.HorizontalPosition = -5f; picture.WidthScale = 92; picture.HeightScale = 92; //Appends paragraph. paragraph = table[2, 1].AddParagraph(); paragraph.ApplyStyle("Heading 1"); paragraph.ParagraphFormat.AfterSpacing = 0; paragraph.ParagraphFormat.LineSpacing = 12f; paragraph.AppendText("Road-150 "); //Appends paragraph. paragraph = table[2, 1].AddParagraph(); paragraph.ParagraphFormat.AfterSpacing = 0; paragraph.ParagraphFormat.LineSpacing = 12f; paragraph.BreakCharacterFormat.FontSize = 12f; paragraph.BreakCharacterFormat.FontName = "Times New Roman"; textRange = paragraph.AppendText("Product No: BK-R93R-44\r") as WTextRange; textRange.CharacterFormat.FontSize = 12f; textRange.CharacterFormat.FontName = "Times New Roman"; textRange = paragraph.AppendText("Size: 44\r") as WTextRange; textRange.CharacterFormat.FontSize = 12f; textRange.CharacterFormat.FontName = "Times New Roman"; textRange = paragraph.AppendText("Weight: 14\r") as WTextRange; textRange.CharacterFormat.FontSize = 12f; textRange.CharacterFormat.FontName = "Times New Roman"; textRange = paragraph.AppendText("Price: $3,578.27\r") as WTextRange; textRange.CharacterFormat.FontSize = 12f; textRange.CharacterFormat.FontName = "Times New Roman"; //Appends paragraph. paragraph = table[2, 1].AddParagraph(); paragraph.ApplyStyle("Heading 1"); paragraph.ParagraphFormat.LineSpacing = 12f; //Appends paragraph. section.AddParagraph(); Save(rdDoc.IsChecked == true, document); }
/// <summary> /// Encrypt the selected Word document /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, EventArgs e) { if (this.txtEncryptSource.Text != null && this.txtEncryptSource.Text != "") { WordDocument document = new WordDocument(this.txtEncryptSource.Text); // Getting last section of the document. IWSection section = document.LastSection; // Adding a paragraph to the section. IWParagraph paragraph = section.AddParagraph(); // Writing text IWTextRange text = paragraph.AppendText("This document was encrypted with password"); text.CharacterFormat.FontSize = 16f; text.CharacterFormat.FontName = "Bitstream Vera Serif"; // Encrypt the document by giving password document.EncryptDocument(txtEnOpen.Text); # region Save Document //Save as doc format if (wordDocRadioBtn.Checked) { //Saving the document to disk. document.Save("Sample.doc"); //Message box confirmation to view the created document. if (MessageBoxAdv.Show("Do you want to view the generated Word document?", "Document has been created", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { //Launching the MS Word file using the default Application.[MS Word Or Free WordViewer] System.Diagnostics.Process.Start("Sample.doc"); //Exit this.Close(); } } //Save as docx format else if (wordDocxRadioBtn.Checked) { //Saving the document as .docx document.Save("Sample.docx", FormatType.Docx); //Message box confirmation to view the created document. if (MessageBoxAdv.Show("Do you want to view the generated Word document?", "Document has been created", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { try { //Launching the MS Word file using the default Application.[MS Word Or Free WordViewer] System.Diagnostics.Process.Start("Sample.docx"); //Exit this.Close(); } catch (Win32Exception ex) { MessageBoxAdv.Show("Microsoft Word Viewer or Microsoft Word is not installed in this system"); Console.WriteLine(ex.ToString()); } } } else { // Exit this.Close(); } # endregion }
private void button1_Click(object sender, EventArgs e) { try { if (this.textBox1.Text != string.Empty) { WordDocument document = new WordDocument(); IWSection section = document.AddSection(); // Set Margin of the document section.PageSetup.Margins.All = 72; IWParagraph para = section.AddParagraph(); bool valid = false; // This manual validation check is Transitional. We do this here only for instructional purpose. if (section.Body.IsValidXHTML(this.textBox1.Text, XHTMLValidationType.Transitional, out errorMessage)) { valid = true; document.XHTMLValidateOption = XHTMLValidationType.Transitional; } // This manual validation check is Strict. We do this here only for instructional purpose else if (section.Body.IsValidXHTML(this.textBox1.Text, XHTMLValidationType.Strict, out errorMessage)) { valid = true; document.XHTMLValidateOption = XHTMLValidationType.Strict; } // This manual validation check is None. We do this here only for instructional purpose else if (section.Body.IsValidXHTML(this.textBox1.Text, XHTMLValidationType.None, out errorMessage)) { valid = true; document.XHTMLValidateOption = XHTMLValidationType.None; } if (!valid) { outpuTextBox.Text = "Content is not a welformatted XHTML content.\t\t\tError message:\t\t\t\t\t\t" + errorMessage; this.panel4.Visible = true; this.label4.Visible = false; this.button3.Text = "-"; this.Size = new Size(384, 650); } else { // By default, the input html will be validated for XHTML format. This will provide you understandable error messages, if the format is invalid. // However, if you are sure that the input html is valid, then you can skip the validation step to improve performance. However, any error messages //you might get here will not be very useful as to where exactly in your html, the issue is. section.Body.InsertXHTML(this.textBox1.Text); outpuTextBox.Text = "Conversion Successful"; this.panel4.Visible = true; this.label4.Visible = false; this.button3.Text = "-"; this.Size = new Size(384, 650); #region Save and open Document //Save as doc format if (wordDocRadioBtn.Checked) { //Saving the document to disk. document.Save("Sample.doc"); //Message box confirmation to view the created document. if (MessageBoxAdv.Show("Do you want to view the generated Word document?", "Document has been created", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { //Launching the MS Word file using the default Application.[MS Word Or Free WordViewer] #if NETCORE System.Diagnostics.Process process = new System.Diagnostics.Process(); process.StartInfo = new System.Diagnostics.ProcessStartInfo("Sample.doc") { UseShellExecute = true }; process.Start(); #else System.Diagnostics.Process.Start("Sample.doc"); #endif //Exit this.Close(); } } //Save as docx format else if (wordDocxRadioBtn.Checked) { //Saving the document as .docx document.Save("Sample.docx", FormatType.Docx); //Message box confirmation to view the created document. if (MessageBoxAdv.Show("Do you want to view the generated Word document?", "Document has been created", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { try { //Launching the MS Word file using the default Application.[MS Word Or Free WordViewer] #if NETCORE System.Diagnostics.Process process = new System.Diagnostics.Process(); process.StartInfo = new System.Diagnostics.ProcessStartInfo("Sample.docx") { UseShellExecute = true }; process.Start(); #else System.Diagnostics.Process.Start("Sample.docx"); #endif //Exit this.Close(); } catch (Win32Exception ex) { MessageBoxAdv.Show("Microsoft Word Viewer or Microsoft Word is not installed in this system"); Console.WriteLine(ex.ToString()); } } } else { // Exit this.Close(); } #endregion } } else { MessageBoxAdv.Show("Browse or type the HTML content to be converted to word document"); } } catch (Exception Ex) { MessageBox.Show(Ex.Message); } }
private void button1_Click(object sender, System.EventArgs e) { // Get Template document and database path. string dataPath = Application.StartupPath + @"\..\..\..\..\..\..\..\Common\Data\DocIO\"; try { //SDF and get the NorthWind AppDomain.CurrentDomain.SetData("SQLServerCompactEditionUnderWebHosting", true); DataTable table = new DataTable(); SqlCeConnection conn = new SqlCeConnection(); if (conn.ServerVersion.StartsWith("3.5")) { conn.ConnectionString = "Data Source = " + dataPath + "..\\NorthwindIO_3.5.sdf"; } else { conn.ConnectionString = "Data Source = " + dataPath + "..\\NorthwindIO.sdf"; } conn.Open(); SqlCeDataAdapter adapter = new SqlCeDataAdapter("Select TOP(5) * from EmployeesReport", conn); adapter.Fill(table); adapter.Dispose(); conn.Close(); // Creating a new document. WordDocument document = new WordDocument(); // Load template document.Open(Path.Combine(dataPath, "EmployeesReportDemo.doc"), FormatType.Doc); // Set table name as Employess for template mergefield reference. table.TableName = "Employees"; // Execute Mail Merge with groups. document.MailMerge.ExecuteGroup(table); //Save as doc format if (wordDocRadioBtn.Checked) { //Saving the document to disk. document.Save("Sample.doc"); //Message box confirmation to view the created document. if (MessageBoxAdv.Show("Do you want to view the generated Word document?", "Document has been created", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { //Launching the MS Word file using the default Application.[MS Word Or Free WordViewer] System.Diagnostics.Process.Start("Sample.doc"); //Exit this.Close(); } } //Save as docx format else if (wordDocxRadioBtn.Checked) { //Saving the document as .docx document.Save("Sample.docx", FormatType.Docx); //Message box confirmation to view the created document. if (MessageBoxAdv.Show("Do you want to view the generated Word document?", "Document has been created", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { try { //Launching the MS Word file using the default Application.[MS Word Or Free WordViewer] System.Diagnostics.Process.Start("Sample.docx"); //Exit this.Close(); } catch (Win32Exception ex) { MessageBoxAdv.Show("Microsoft Word Viewer or Microsoft Word is not installed in this system"); Console.WriteLine(ex.ToString()); } } } //Save as pdf format else if (pdfRadioBtn.Checked) { DocToPDFConverter converter = new DocToPDFConverter(); //Convert word document into PDF document PdfDocument pdfDoc = converter.ConvertToPDF(document); //Save the pdf file pdfDoc.Save("Sample.pdf"); //Message box confirmation to view the created document. if (MessageBoxAdv.Show("Do you want to view the generated PDF?", " Document has been created", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { try { System.Diagnostics.Process.Start("Sample.pdf"); //Exit this.Close(); } catch (Exception ex) { MessageBoxAdv.Show("PDF Viewer is not installed in this system"); Console.WriteLine(ex.ToString()); } } } else { // Exit this.Close(); } } catch (Exception Ex) { // Shows the Message box with Exception message, if an exception throws. MessageBoxAdv.Show(Ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { } }
void OnButtonClicked(object sender, EventArgs e) { WordDocument doc = new WordDocument(); doc.EnsureMinimal(); WParagraph para = doc.LastParagraph; para.AppendText("Essential DocIO - Table of Contents"); para.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center; para.ApplyStyle(BuiltinStyle.Heading4); para = doc.LastSection.AddParagraph() as WParagraph; para.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center; para.ApplyStyle(BuiltinStyle.Heading4); para = doc.LastSection.AddParagraph() as WParagraph; //Insert TOC TableOfContent toc = para.AppendTOC(1, 3); para.ApplyStyle(BuiltinStyle.Heading4); //Apply built-in paragraph formatting WSection section = doc.LastSection; #region Default Styles WParagraph newPara = section.AddParagraph() as WParagraph; newPara = section.AddParagraph() as WParagraph; newPara.AppendBreak(BreakType.PageBreak); WTextRange text = newPara.AppendText("Document with Default styles") as WTextRange; newPara.ApplyStyle(BuiltinStyle.Heading1); newPara = section.AddParagraph() as WParagraph; newPara.AppendText("This is the heading1 of built in style. This sample demonstrates the TOC insertion in a word document. Note that DocIO can only insert TOC field in a word document. It can not refresh or create TOC field. MS Word refreshes the TOC field after insertion. Please update the field or press F9 key to refresh the TOC."); section.AddParagraph(); newPara = section.AddParagraph() as WParagraph; text = newPara.AppendText("Section1") as WTextRange; newPara.ApplyStyle(BuiltinStyle.Heading2); newPara = section.AddParagraph() as WParagraph; newPara.AppendText("This is the heading2 of built in style. A document can contain any number of sections. Sections are used to apply same formatting for a group of paragraphs. You can insert sections by inserting section breaks."); section.AddParagraph(); newPara = section.AddParagraph() as WParagraph; text = newPara.AppendText("Paragraph1") as WTextRange; newPara.ApplyStyle(BuiltinStyle.Heading3); newPara = section.AddParagraph() as WParagraph; newPara.AppendText("This is the heading3 of built in style. Each section contains any number of paragraphs. A paragraph is a set of statements that gives a meaning for the text."); section.AddParagraph(); newPara = section.AddParagraph() as WParagraph; text = newPara.AppendText("Paragraph2") as WTextRange; newPara.ApplyStyle(BuiltinStyle.Heading3); newPara = section.AddParagraph() as WParagraph; newPara.AppendText("This is the heading3 of built in style. This demonstrates the paragraphs at the same level and style as that of the previous one. A paragraph can have any number formatting. This can be attained by formatting each text range in the paragraph."); section.AddParagraph(); section = doc.AddSection() as WSection; section.BreakCode = SectionBreakCode.NewPage; newPara = section.AddParagraph() as WParagraph; text = newPara.AppendText("Section2") as WTextRange; newPara.ApplyStyle(BuiltinStyle.Heading2); newPara = section.AddParagraph() as WParagraph; newPara.AppendText("This is the heading2 of built in style. A document can contain any number of sections. Sections are used to apply same formatting for a group of paragraphs. You can insert sections by inserting section breaks."); section.AddParagraph(); newPara = section.AddParagraph() as WParagraph; text = newPara.AppendText("Paragraph1") as WTextRange; newPara.ApplyStyle(BuiltinStyle.Heading3); newPara = section.AddParagraph() as WParagraph; newPara.AppendText("This is the heading3 of built in style. Each section contains any number of paragraphs. A paragraph is a set of statements that gives a meaning for the text."); section.AddParagraph(); newPara = section.AddParagraph() as WParagraph; text = newPara.AppendText("Paragraph2") as WTextRange; newPara.ApplyStyle(BuiltinStyle.Heading3); newPara = section.AddParagraph() as WParagraph; newPara.AppendText("This is the heading3 of built in style. This demonstrates the paragraphs at the same level and style as that of the previous one. A paragraph can have any number formatting. This can be attained by formatting each text range in the paragraph."); #endregion toc.IncludePageNumbers = true; toc.RightAlignPageNumbers = true; toc.UseHyperlinks = true; toc.LowerHeadingLevel = 1; toc.UpperHeadingLevel = 3; toc.UseOutlineLevels = true; //Updates the table of contents. doc.UpdateTableOfContents(); MemoryStream ms = new MemoryStream(); //Set file content type string contentType = null; string fileName = null; if (docxButton.Checked) { fileName = "Table of Contents.docx"; contentType = "application/msword"; doc.Save(ms, FormatType.Docx); } else { fileName = "Table of Contents.pdf"; contentType = "application/pdf"; DocIORenderer renderer = new DocIORenderer(); PdfDocument pdfDoc = renderer.ConvertToPDF(doc); pdfDoc.Save(ms); pdfDoc.Close(); } doc.Dispose(); if (ms != null) { SaveAndroid androidSave = new SaveAndroid(); androidSave.Save(fileName, contentType, ms, m_context); } }
private void button1_Click_1(object sender, System.EventArgs e) { // Get Template document and database path. string dataPath = Application.StartupPath + @"..\..\..\..\..\..\..\..\Common\Data\"; try { //SDF the database and get the NorthWind AppDomain.CurrentDomain.SetData("SQLServerCompactEditionUnderWebHosting", true); DataTable table = new DataTable(); SqlCeConnection conn = new SqlCeConnection(); if (conn.ServerVersion.StartsWith("3.5")) { conn.ConnectionString = "Data Source = " + dataPath + "NorthwindIO_3.5.sdf"; } else { conn.ConnectionString = "Data Source = " + dataPath + "NorthwindIO.sdf"; } conn.Open(); SqlCeDataAdapter adapter = new SqlCeDataAdapter("Select CustomerID,CompanyName,ContactName,Address,Country,Phone from Customers", conn); adapter.Fill(table); adapter.Dispose(); conn.Close(); // Creating a new document. WordDocument document = new WordDocument(); // Adding a new section to the document. IWSection section = document.AddSection(); IWParagraph paragraph = section.AddParagraph(); paragraph.ParagraphFormat.BeforeSpacing = 20f; //Format the heading. IWTextRange text = paragraph.AppendText("Northwind Report"); text.CharacterFormat.Bold = true; text.CharacterFormat.FontName = "Cambria"; text.CharacterFormat.FontSize = 14.0f; text.CharacterFormat.TextColor = Color.DarkBlue; paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center; paragraph = section.AddParagraph(); paragraph.ParagraphFormat.BeforeSpacing = 18f; //Create a new table WTextBody textBody = section.Body; IWTable docTable = textBody.AddTable(); //Set the format for rows RowFormat format = new RowFormat(); format.Borders.BorderType = Syncfusion.DocIO.DLS.BorderStyle.Single; format.Borders.LineWidth = 1.0F; format.Borders.Color = Color.Black; //Initialize number of rows and cloumns. docTable.ResetCells(table.Rows.Count + 1, table.Columns.Count, format, 84); //Repeat the header. docTable.Rows[0].IsHeader = true; string colName; //Format the header rows for (int c = 0; c <= table.Columns.Count - 1; c++) { string[] Cols = table.Columns[c].ColumnName.Split('|'); colName = Cols[Cols.Length - 1]; IWTextRange theadertext = docTable.Rows[0].Cells[c].AddParagraph().AppendText(colName); theadertext.CharacterFormat.FontSize = 12f; theadertext.CharacterFormat.Bold = true; theadertext.CharacterFormat.TextColor = Color.White; docTable.Rows[0].Cells[c].CellFormat.BackColor = Color.FromArgb(33, 67, 126); docTable.Rows[0].Cells[c].CellFormat.Borders.Color = Color.Black; docTable.Rows[0].Cells[c].CellFormat.Borders.BorderType = Syncfusion.DocIO.DLS.BorderStyle.Single; docTable.Rows[0].Cells[c].CellFormat.Borders.LineWidth = 1.0f; docTable.Rows[0].Cells[c].CellFormat.VerticalAlignment = Syncfusion.DocIO.DLS.VerticalAlignment.Middle; } //Format the table body rows for (int r = 0; r <= table.Rows.Count - 1; r++) { for (int c = 0; c <= table.Columns.Count - 1; c++) { string Value = table.Rows[r][c].ToString(); IWTextRange theadertext = docTable.Rows[r + 1].Cells[c].AddParagraph().AppendText(Value); theadertext.CharacterFormat.FontSize = 10; docTable.Rows[r + 1].Cells[c].CellFormat.BackColor = ((r & 1) == 0) ? Color.FromArgb(237, 240, 246) : Color.FromArgb(192, 201, 219); docTable.Rows[r + 1].Cells[c].CellFormat.Borders.Color = Color.Black; docTable.Rows[r + 1].Cells[c].CellFormat.Borders.BorderType = Syncfusion.DocIO.DLS.BorderStyle.Single; docTable.Rows[r + 1].Cells[c].CellFormat.Borders.LineWidth = 0.5f; docTable.Rows[r + 1].Cells[c].CellFormat.VerticalAlignment = Syncfusion.DocIO.DLS.VerticalAlignment.Middle; } } // Add a footer paragraph text to the document. WParagraph footerPar = new WParagraph(document); // Add text. footerPar.AppendText("Copyright Syncfusion Inc. 2001 - 2017"); // Add page and Number of pages field to the document. footerPar.AppendText(" Page "); footerPar.AppendField("Page", Syncfusion.DocIO.FieldType.FieldPage); section.HeadersFooters.Footer.Paragraphs.Add(footerPar); //Save as doc format if (wordDocRadioBtn.Checked) { //Saving the document to disk. document.Save("Sample.doc"); //Message box confirmation to view the created document. if (MessageBoxAdv.Show("Do you want to view the generated Word document?", "Document has been created", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { //Launching the MS Word file using the default Application.[MS Word Or Free WordViewer] System.Diagnostics.Process.Start("Sample.doc"); //Exit this.Close(); } } //Save as docx format else if (wordDocxRadioBtn.Checked) { //Saving the document as .docx document.Save("Sample.docx", FormatType.Docx); //Message box confirmation to view the created document. if (MessageBoxAdv.Show("Do you want to view the generated Word document?", "Document has been created", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { try { //Launching the MS Word file using the default Application.[MS Word Or Free WordViewer] System.Diagnostics.Process.Start("Sample.docx"); //Exit this.Close(); } catch (Win32Exception ex) { MessageBoxAdv.Show("Microsoft Word Viewer or Microsoft Word is not installed in this system"); Console.WriteLine(ex.ToString()); } } } //Save as pdf format else if (pdfRadioBtn.Checked) { DocToPDFConverter converter = new DocToPDFConverter(); //Convert word document into PDF document PdfDocument pdfDoc = converter.ConvertToPDF(document); //Save the pdf file pdfDoc.Save("Sample.pdf"); //Message box confirmation to view the created document. if (MessageBoxAdv.Show("Do you want to view the generated PDF?", " Document has been created", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { try { System.Diagnostics.Process.Start("Sample.pdf"); //Exit this.Close(); } catch (Exception ex) { MessageBoxAdv.Show("PDF Viewer is not installed in this system"); Console.WriteLine(ex.ToString()); } } } else { // Exit this.Close(); } } catch (Exception Ex) { // Shows the Message box with Exception message, if an exception throws. MessageBoxAdv.Show(Ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { } }
public ConversionContext(WordDocument doc) { this.Doc = doc; this.AllRsids = new List <string>(); }
private void button1_Click(object sender, System.EventArgs e) { try { // Creating a new document. WordDocument document = new WordDocument(); document.EnsureMinimal(); //Set Margin of the document document.LastSection.PageSetup.Margins.All = 72; // Reading Arabic text from text file. #if NETCORE StreamReader s = new StreamReader(@"..\..\..\..\..\..\..\..\Common\Data\DocIO\Arabic.txt", System.Text.Encoding.ASCII); #else StreamReader s = new StreamReader(@"..\..\..\..\..\..\..\Common\Data\DocIO\Arabic.txt", System.Text.Encoding.ASCII); #endif string text = s.ReadToEnd(); // Appending Arabic text to the document. document.LastParagraph.ParagraphFormat.Bidi = true; IWTextRange txtRange = document.LastParagraph.AppendText(text); txtRange.CharacterFormat.Bidi = true; // Set the RTL text font size. txtRange.CharacterFormat.FontSizeBidi = 16; //Save as doc format if (wordDocRadioBtn.Checked) { //Saving the document to disk. document.Save("Sample.doc"); //Message box confirmation to view the created document. if (MessageBoxAdv.Show("Do you want to view the generated Word document?", "Document has been created", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { //Launching the MS Word file using the default Application.[MS Word Or Free WordViewer] #if NETCORE System.Diagnostics.Process process = new System.Diagnostics.Process(); process.StartInfo = new System.Diagnostics.ProcessStartInfo("Sample.doc") { UseShellExecute = true }; process.Start(); #else System.Diagnostics.Process.Start("Sample.doc"); #endif //Exit this.Close(); } } //Save as docx format else if (wordDocxRadioBtn.Checked) { //Saving the document as .docx document.Save("Sample.docx", FormatType.Docx); //Message box confirmation to view the created document. if (MessageBoxAdv.Show("Do you want to view the generated Word document?", "Document has been created", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { try { //Launching the MS Word file using the default Application.[MS Word Or Free WordViewer] #if NETCORE System.Diagnostics.Process process = new System.Diagnostics.Process(); process.StartInfo = new System.Diagnostics.ProcessStartInfo("Sample.docx") { UseShellExecute = true }; process.Start(); #else System.Diagnostics.Process.Start("Sample.docx"); #endif //Exit this.Close(); } catch (Win32Exception ex) { MessageBoxAdv.Show("Microsoft Word Viewer or Microsoft Word is not installed in this system"); Console.WriteLine(ex.ToString()); } } } //Save as pdf format else if (pdfRadioBtn.Checked) { DocToPDFConverter converter = new DocToPDFConverter(); //Convert word document into PDF document PdfDocument pdfDoc = converter.ConvertToPDF(document); document.Close(); converter.Dispose(); //Save the pdf file pdfDoc.Save("Sample.pdf"); pdfDoc.Close(true); //Message box confirmation to view the created document. if (MessageBoxAdv.Show("Do you want to view the generated PDF?", " Document has been created", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { try { #if NETCORE System.Diagnostics.Process process = new System.Diagnostics.Process(); process.StartInfo = new System.Diagnostics.ProcessStartInfo("Sample.pdf") { UseShellExecute = true }; process.Start(); #else System.Diagnostics.Process.Start("Sample.pdf"); #endif //Exit this.Close(); } catch (Exception ex) { MessageBoxAdv.Show("PDF Viewer is not installed in this system"); Console.WriteLine(ex.ToString()); } } } else { // Exit this.Close(); } } catch (Exception Ex) { MessageBox.Show(Ex.Message); } }
private void btnToEPub_Click(object sender, RoutedEventArgs e) { if (this.textBox1.Text != String.Empty && fullPath != string.Empty) { if (!this.textBox1.Text.EndsWith(".doc") && !this.textBox1.Text.EndsWith(".docx") && !this.textBox1.Text.EndsWith(".rtf") && !this.textBox1.Text.EndsWith(".docm") && !this.textBox1.Text.EndsWith(".dotx") && !this.textBox1.Text.EndsWith(".dotm") && !this.textBox1.Text.EndsWith(".dot") && !this.textBox1.Text.EndsWith(".txt")) { MessageBox.Show("Browse a Word document to convert to EPUB", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (fullPath.EndsWith("\\")) { fullPath += this.textBox1.Text; } if (File.Exists(fullPath)) { try { WordDocument document = new WordDocument(fullPath); document.SaveOptions.EPubExportFont = this.chkBox1.IsChecked.Value; document.Save("Word to EPUB.epub", FormatType.EPub); document.Close(); //Message box confirmation to view the created document. if (MessageBox.Show("Conversion Successful. Do you want to view the EPUB File?", "Status", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes) { try { System.Diagnostics.Process process = new System.Diagnostics.Process(); process.StartInfo = new System.Diagnostics.ProcessStartInfo("Word to EPUB.epub") { UseShellExecute = true }; process.Start(); } catch (System.ComponentModel.Win32Exception) { MessageBox.Show("EPUB viewer is not installed in this system!", "Status"); } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Stop); } } } catch (Exception ex) { if (ex is IOException) { MessageBox.Show("Please close the file (" + Directory.GetCurrentDirectory() + "\\Word to EPUB.epub" + ") then try generating the document.", "File is already open", MessageBoxButton.OK, MessageBoxImage.Error); } else { MessageBox.Show("Document could not be generated, Could you please email the error details with along input document to [email protected] for trouble shooting" + "\r\n" + ex.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } } else { MessageBox.Show("File doesn’t exist"); } } else { MessageBox.Show("Browse a Word document to convert to EPUB", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
/// <summary> /// Creates an expansion of Gamma function /// </summary> /// <param name="paragraph">Represents a paragraph to add MathML element</param> private void CreateGammaFunction(IWParagraph paragraph) { WordDocument document = paragraph.Document; //Creates a new MathML element WMath math = paragraph.AppendMath(); //Adds a math text IOfficeMath officeMath = math.MathParagraph.Maths.Add(); //Unicode value of capital gamma string capitalGamma = "\u0393"; IOfficeMathRunElement officeMathParaItem = AddMathText(document, officeMath, capitalGamma); //Sets MathML style format for the text officeMathParaItem.MathFormat.Style = MathStyleType.Regular; //Adds a delimiter equation IOfficeMathDelimiter mathDelimiter = math.MathParagraph.Maths.Add().Functions.Add(MathFunctionType.Delimiter) as IOfficeMathDelimiter; //Adds a equation to the delimiter officeMath = mathDelimiter.Equation.Add(); //Adds a math text officeMathParaItem = AddMathText(document, officeMath, "z"); //Adds a math text officeMath = math.MathParagraph.Maths.Add(); officeMathParaItem = AddMathText(document, officeMath, "="); //Adds an n array element IOfficeMathNArray mathNAry = math.MathParagraph.Maths.Add().Functions.Add(MathFunctionType.NArray) as IOfficeMathNArray; //Adds a math text AddMathText(document, mathNAry.Subscript, "0"); //Adds a math text string infinitySymbol = "\u221E"; AddMathText(document, mathNAry.Superscript, infinitySymbol); //Adds a math superscript IOfficeMathScript mathScript = AddMathScript(mathNAry.Equation, MathScriptType.Superscript); //Adds a math text for Superscript AddMathText(document, mathScript.Equation, "t"); AddMathText(document, mathScript.Script, "z-1"); //Adds a Superscript mathScript = AddMathScript(mathNAry.Equation, MathScriptType.Superscript); AddMathText(document, mathScript.Equation, "e"); AddMathText(document, mathScript.Script, "-t"); //Adds a math text in n Array equation AddMathText(document, mathNAry.Equation, "dt"); //Adds a math text AddMathText(document, math.MathParagraph.Maths.Add(), "="); //Adds a fraction equation IOfficeMathFraction mathFraction = math.MathParagraph.Maths.Add().Functions.Add(MathFunctionType.Fraction) as IOfficeMathFraction; //Adds a math script mathScript = AddMathScript(mathFraction.Numerator, MathScriptType.Superscript); //Adds a math text for Superscript AddMathText(document, mathScript.Equation, "e"); AddMathText(document, mathScript.Script, "-"); //Unicode of small gamma string smallGamma = "\u03B3"; AddMathText(document, mathScript.Script, smallGamma); AddMathText(document, mathScript.Script, "z"); //Adds a math text for denominator AddMathText(document, mathFraction.Denominator, "z"); //Adds an n-array element mathNAry = math.MathParagraph.Maths.Add().Functions.Add(MathFunctionType.NArray) as IOfficeMathNArray; //Unicode value of n-array product string symbol = "\u220F"; //Adds a n-array character mathNAry.NArrayCharacter = symbol; //Adds a math text AddMathText(document, mathNAry.Subscript, "k=1"); //Adds a math text AddMathText(document, mathNAry.Superscript, infinitySymbol); //Adds a math script mathScript = AddMathScript(mathNAry.Equation, MathScriptType.Superscript); //Adds a math delimiter element mathDelimiter = mathScript.Equation.Functions.Add(MathFunctionType.Delimiter) as IOfficeMathDelimiter; //Adds a equation to the delimiter equation collection officeMath = mathDelimiter.Equation.Add(); //Adds a math text AddMathText(document, officeMath, "1+"); //Adds a fraction element mathFraction = officeMath.Functions.Add(MathFunctionType.Fraction) as IOfficeMathFraction; //Adds a math text for numerator AddMathText(document, mathFraction.Numerator, "z"); //Adds a math text for denominator AddMathText(document, mathFraction.Denominator, "k"); //Adds a math text AddMathText(document, mathScript.Script, "-1"); //Adds a Superscript equation mathScript = AddMathScript(mathNAry.Equation, MathScriptType.Superscript); //Adds a math text for Superscript AddMathText(document, mathScript.Equation, "e"); AddMathText(document, mathScript.Script, "z"); officeMathParaItem = AddMathText(document, mathScript.Script, "/"); officeMathParaItem.MathFormat.HasLiteral = true; AddMathText(document, mathScript.Script, "k"); //Adds a math text AddMathText(document, math.MathParagraph.Maths.Add(), ","); //Adds a math text officeMathParaItem = AddMathText(document, math.MathParagraph.Maths.Add(), " "); //Sets style for math text officeMathParaItem.MathFormat.Style = MathStyleType.Regular; //Adds a math text AddMathText(document, math.MathParagraph.Maths.Add(), smallGamma); string text = "\u2248" + "0.577216"; AddMathText(document, math.MathParagraph.Maths.Add(), text); }
public ActionResult SalesInvoice(int id, string SaveOption, string Button) { ArrayList orderID = GetTestOrderID(); ViewData.Add("id", new SelectList(orderID)); if (SaveOption == null) { return(View()); } string basePath = _hostingEnvironment.WebRootPath; string dataPath = basePath + @"/DocIO/SalesInvoiceDemo.doc"; string contenttype1 = "application/msword"; FileStream fileStreamPath = new FileStream(dataPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); if (Button == "View Template") { return(File(fileStreamPath, contenttype1, "SalesInvoiceDemo.doc")); } // Create a new document WordDocument doc = new WordDocument(); // Load the template. string dataPathSales = basePath + @"/DocIO/SalesInvoiceDemo.doc"; FileStream fileStream = new FileStream(dataPathSales, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); doc.Open(fileStream, FormatType.Automatic); //Create MailMergeDataTable MailMergeDataTable mailMergeDataTableOrder = GetTestOrder(id); MailMergeDataTable mailMergeDataTableOrderTotals = GetTestOrderTotals(id); MailMergeDataTable mailMergeDataTableOrderDetails = GetTestOrderDetails(id); // Execute Mail Merge with groups. doc.MailMerge.ExecuteGroup(mailMergeDataTableOrder); doc.MailMerge.ExecuteGroup(mailMergeDataTableOrderTotals); // Using Merge events to do conditional formatting during runtime. doc.MailMerge.MergeField += new MergeFieldEventHandler(MailMerge_MergeField); doc.MailMerge.ExecuteGroup(mailMergeDataTableOrderDetails); FormatType type = FormatType.Docx; string filename = "Sample.docx"; string contenttype = "application/vnd.ms-word.document.12"; #region Document SaveOption //Save as .doc format if (SaveOption == "WordDoc") { type = FormatType.Doc; filename = "Sample.doc"; contenttype = "application/msword"; } //Save as .xml format else if (SaveOption == "WordML") { type = FormatType.WordML; filename = "Sample.xml"; contenttype = "application/msword"; } #endregion Document SaveOption MemoryStream ms = new MemoryStream(); doc.Save(ms, type); doc.Close(); ms.Position = 0; return(File(ms, contenttype, filename)); }
/// <summary> /// Creates an equation with sum to the power of N /// </summary> /// <param name="paragraph">Represents a paragraph to add MathML element</param> private void CreateSumToThePowerOfN(IWParagraph paragraph) { WordDocument document = paragraph.Document; //Creates a new MathML element WMath math = paragraph.AppendMath(); IOfficeMath officeMath = math.MathParagraph.Maths.Add(); //Adds a math script element IOfficeMathScript mathScript = AddMathScript(officeMath, MathScriptType.Superscript); #region Delimiter equation //Adds a delimiter IOfficeMathDelimiter mathDelimiter = mathScript.Equation.Functions.Add(MathFunctionType.Delimiter) as IOfficeMathDelimiter; //Adds an office math in the delimiter officeMath = mathDelimiter.Equation.Add() as IOfficeMath; //Adds a math text IOfficeMathRunElement mathParaItem = AddMathText(document, officeMath, "1+x"); //Adds a math text mathParaItem = AddMathText(document, mathScript.Script, "n"); #endregion //Adds a math text officeMath = math.MathParagraph.Maths.Add(1); mathParaItem = AddMathText(document, officeMath, "=1+"); #region Fraction equation //Adds a math fraction IOfficeMathFraction mathFraction = math.MathParagraph.Maths.Add().Functions.Add(MathFunctionType.Fraction) as IOfficeMathFraction; //Adds a numerator text AddMathText(document, mathFraction.Numerator, "nx"); //Adds a denominator text AddMathText(document, mathFraction.Denominator, "1!"); #endregion //Adds a math text officeMath = math.MathParagraph.Maths.Add(); mathParaItem = AddMathText(document, officeMath, "+"); #region Fraction equation //Adds a math fraction mathFraction = math.MathParagraph.Maths.Add().Functions.Add(MathFunctionType.Fraction) as IOfficeMathFraction; #region Numerator //Adds a numerator text AddMathText(document, mathFraction.Numerator, "n"); //Adds a delimiter mathDelimiter = mathFraction.Numerator.Functions.Add(MathFunctionType.Delimiter) as IOfficeMathDelimiter; //Adds a math text for delimiter officeMath = mathDelimiter.Equation.Add() as IOfficeMath; AddMathText(document, officeMath, "n-1"); //Adds a math script mathScript = mathFraction.Numerator.Functions.Add(MathFunctionType.SubSuperscript) as IOfficeMathScript; //Adds a math text for Superscript AddMathText(document, mathScript.Equation, "x"); AddMathText(document, mathScript.Script, "2"); #endregion #region Denominator //Adds a math text for denominator AddMathText(document, mathFraction.Denominator, "2!"); #endregion #endregion //Adds a math text officeMath = math.MathParagraph.Maths.Add(); AddMathText(document, officeMath, "+..."); }
private void button1_Click(object sender, System.EventArgs e) { try { // Get XML file path. string dataPath = Application.StartupPath + @"..\..\..\..\..\..\..\..\Common\Data\DocIO\"; //Opens an existing Word document WordDocument document = new WordDocument(dataPath + "Mathematical Equation.docx"); //Gets the last section in the document WSection section = document.LastSection; //Gets paragraph from Word document WParagraph paragraph = document.LastSection.Body.ChildEntities[3] as WParagraph; //Gets MathML from the paragraph WMath math = paragraph.ChildEntities[0] as WMath; //Gets the radical equation IOfficeMathRadical mathRadical = math.MathParagraph.Maths[0].Functions[1] as IOfficeMathRadical; //Gets the fraction equation in radical IOfficeMathFraction mathFraction = mathRadical.Equation.Functions[0] as IOfficeMathFraction; //Gets the n-array in fraction IOfficeMathNArray mathNAry = mathFraction.Numerator.Functions[0] as IOfficeMathNArray; //Gets the math script in n-array IOfficeMathScript mathScript = mathNAry.Equation.Functions[0] as IOfficeMathScript; //Gets the delimiter in math script IOfficeMathDelimiter mathDelimiter = mathScript.Equation.Functions[0] as IOfficeMathDelimiter; //Gets the math script in delimiter mathScript = mathDelimiter.Equation[0].Functions[0] as IOfficeMathScript; //Gets the math run element in math script IOfficeMathRunElement mathParaItem = mathScript.Equation.Functions[0] as IOfficeMathRunElement; //Modifies the math text value (mathParaItem.Item as WTextRange).Text = "x"; //Gets the math bar in delimiter IOfficeMathBar mathBar = mathDelimiter.Equation[0].Functions[2] as IOfficeMathBar; //Gets the math run element in bar mathParaItem = mathBar.Equation.Functions[0] as IOfficeMathRunElement; //Modifies the math text value (mathParaItem.Item as WTextRange).Text = "x"; //Gets the paragraph from Word document paragraph = document.LastSection.Body.ChildEntities[6] as WParagraph; //Gets MathML from the paragraph math = paragraph.ChildEntities[0] as WMath; //Gets the math script equation mathScript = math.MathParagraph.Maths[0].Functions[0] as IOfficeMathScript; //Gets the math run element in math script mathParaItem = mathScript.Equation.Functions[0] as IOfficeMathRunElement; //Modifies the math text value (mathParaItem.Item as WTextRange).Text = "x"; //Gets the paragraph from Word document paragraph = document.LastSection.Body.ChildEntities[7] as WParagraph; //Gets MathML from the paragraph WMath math2 = paragraph.ChildEntities[0] as WMath; //Gets bar equation mathBar = math2.MathParagraph.Maths[0].Functions[0] as IOfficeMathBar; //Gets the math run element in bar mathParaItem = mathBar.Equation.Functions[0] as IOfficeMathRunElement; //Gets the math text (mathParaItem.Item as WTextRange).Text = "x"; //Save as docx format if (wordDocxRadioBtn.Checked) { //Saving the document as .docx document.Save("Edit Equation.docx", FormatType.Docx); //Message box confirmation to view the created document. if (MessageBoxAdv.Show("Do you want to view the generated Word document?", "Document has been created", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { try { //Launching the MS Word file using the default Application.[MS Word Or Free WordViewer] #if NETCORE System.Diagnostics.Process process = new System.Diagnostics.Process(); process.StartInfo = new System.Diagnostics.ProcessStartInfo("Edit Equation.docx") { UseShellExecute = true }; process.Start(); #else System.Diagnostics.Process.Start("Edit Equation.docx"); #endif //Exit this.Close(); } catch (Win32Exception ex) { MessageBoxAdv.Show("Microsoft Word Viewer or Microsoft Word is not installed in this system"); Console.WriteLine(ex.ToString()); } } } //Save as pdf format else if (pdfRadioBtn.Checked) { DocToPDFConverter converter = new DocToPDFConverter(); //Convert word document into PDF document PdfDocument pdfDoc = converter.ConvertToPDF(document); //Save the pdf file pdfDoc.Save("Edit Equation.pdf"); converter.Dispose(); pdfDoc.Close(); //Message box confirmation to view the created document. if (MessageBoxAdv.Show("Do you want to view the generated PDF?", " Document has been created", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { try { #if NETCORE System.Diagnostics.Process process = new System.Diagnostics.Process(); process.StartInfo = new System.Diagnostics.ProcessStartInfo("Edit Equation.pdf") { UseShellExecute = true }; process.Start(); #else System.Diagnostics.Process.Start("Edit Equation.pdf"); #endif //Exit this.Close(); } catch (Exception ex) { MessageBoxAdv.Show("PDF Viewer is not installed in this system"); Console.WriteLine(ex.ToString()); } } } else { // Exit this.Close(); } } catch (Exception Ex) { MessageBox.Show(Ex.Message); } }
public MemoryStream CreateEquation(string documentType) { string basePath = @"wwwroot/"; string dataPath = basePath + @"data/docio/create-equation.docx"; FileStream fileStream = new FileStream(dataPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); // Creates an empty Word document instance WordDocument document = new WordDocument(); // Opens template document document.Open(fileStream, FormatType.Docx); fileStream.Dispose(); fileStream = null; //Gets the last section in the document WSection section = document.LastSection; //Sets page margins document.LastSection.PageSetup.Margins.All = 72; //Adds new paragraph to the section IWParagraph paragraph = section.AddParagraph(); //Appends text to paragraph IWTextRange textRange = paragraph.AppendText("Mathematical equations"); textRange.CharacterFormat.FontSize = 28; paragraph.ParagraphFormat.HorizontalAlignment = HorizontalAlignment.Center; paragraph.ParagraphFormat.AfterSpacing = 12; #region Sum to the power of n //Adds new paragraph to the section paragraph = AddParagraph(section, "This is an expansion of the sum (1+X) to the power of n."); //Creates an equation with sum to the power of N CreateSumToThePowerOfN(paragraph); #endregion #region Fourier series //Adds new paragraph to the section paragraph = AddParagraph(section, "This is a Fourier series for the function of period 2L"); //Creates a Fourier series equation CreateFourierseries(paragraph); #endregion #region Triple scalar product //Adds new paragraph to the section paragraph = AddParagraph(section, "This is an expansion of triple scalar product"); //Creates a triple scalar product equation CreateTripleScalarProduct(paragraph); #endregion #region Gamma function //Adds new paragraph to the section paragraph = AddParagraph(section, "This is an expansion of gamma function"); //Creates a gamma function equation CreateGammaFunction(paragraph); #endregion #region Vector relation //Adds new paragraph to the section paragraph = AddParagraph(section, "This is an expansion of vector relation "); //Creates a vector relation equation CreateVectorRelation(paragraph); #endregion FormatType type = FormatType.Docx; #region Document SaveOption //Save as .pdf format if (documentType == "PDF") { DocIORenderer render = new DocIORenderer(); // Converts Word document into PDF document. PdfDocument pdf = render.ConvertToPDF(document); //Save the document as a stream and retrun the stream using (MemoryStream stream = new MemoryStream()) { //Save the created PDF document to MemoryStream pdf.Save(stream); render.Dispose(); pdf.Close(); document.Close(); stream.Position = 0; return(stream); } } else { using (MemoryStream stream = new MemoryStream()) { //Save the created Word document to MemoryStream document.Save(stream, type); document.Close(); stream.Position = 0; return(stream); } } #endregion Document SaveOption }
public ActionResult TableStyles(string Group1, string Group2) { if (Group1 == null) { return(View()); } string dataPath = ResolveApplicationDataPath("TemplateTableStyle.doc", "App_Data\\DocIO"); WordDocument document = new WordDocument(dataPath); string dataBase = ResolveApplicationDataPath("Northwind.mdb", "App_Data"); // Get Data from the Database. OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + dataBase); conn.Open(); DataSet ds = new DataSet(); OleDbDataAdapter adapter = new OleDbDataAdapter("Select * from Suppliers", conn); adapter.Fill(ds); ds.Tables[0].TableName = "Suppliers"; adapter.Dispose(); conn.Close(); // Execute Mail Merge with groups. document.MailMerge.ExecuteGroup(ds.Tables[0]); #region Built-in table styles if (Group1 == "Built-in") { //Get table to apply style. WTable table = (WTable)document.LastSection.Tables[0]; //Apply built-in table style to the table. table.ApplyStyle(BuiltinTableStyle.MediumShading1Accent5); } #endregion Built-in table styles #region Custom Style else { #region Custom table styles //Get table to apply style WTable table = (WTable)document.LastSection.Tables[0]; //Apply custom table style to the table #region Apply Table style WTableStyle tableStyle = document.AddTableStyle("Tablestyle") as WTableStyle; System.Drawing.Color borderColor = System.Drawing.Color.WhiteSmoke; System.Drawing.Color firstRowBackColor = System.Drawing.Color.Blue; System.Drawing.Color backColor = System.Drawing.Color.WhiteSmoke; ConditionalFormattingStyle firstRowStyle, lastRowStyle, firstColumnStyle, lastColumnStyle, oddColumnBandingStyle, oddRowBandingStyle, evenRowBandingStyle; #region Table Properties tableStyle.TableProperties.RowStripe = 1; tableStyle.TableProperties.ColumnStripe = 1; tableStyle.TableProperties.LeftIndent = 0; tableStyle.TableProperties.Paddings.Top = 0; tableStyle.TableProperties.Paddings.Bottom = 0; tableStyle.TableProperties.Paddings.Left = 5.4f; tableStyle.TableProperties.Paddings.Right = 5.4f; tableStyle.TableProperties.Borders.Top.BorderType = BorderStyle.Single; tableStyle.TableProperties.Borders.Top.LineWidth = 1f; tableStyle.TableProperties.Borders.Top.Color = System.Drawing.Color.AliceBlue; tableStyle.TableProperties.Borders.Top.Space = 0; tableStyle.TableProperties.Borders.Bottom.BorderType = BorderStyle.Single; tableStyle.TableProperties.Borders.Bottom.LineWidth = 1f; tableStyle.TableProperties.Borders.Bottom.Color = borderColor; tableStyle.TableProperties.Borders.Bottom.Space = 0; tableStyle.TableProperties.Borders.Left.BorderType = BorderStyle.Single; tableStyle.TableProperties.Borders.Left.LineWidth = 1f; tableStyle.TableProperties.Borders.Left.Color = borderColor; tableStyle.TableProperties.Borders.Left.Space = 0; tableStyle.TableProperties.Borders.Right.BorderType = BorderStyle.Single; tableStyle.TableProperties.Borders.Right.LineWidth = 1f; tableStyle.TableProperties.Borders.Right.Color = borderColor; tableStyle.TableProperties.Borders.Right.Space = 0; tableStyle.TableProperties.Borders.Horizontal.BorderType = BorderStyle.Single; tableStyle.TableProperties.Borders.Horizontal.LineWidth = 1f; tableStyle.TableProperties.Borders.Horizontal.Color = borderColor; tableStyle.TableProperties.Borders.Horizontal.Space = 0; #endregion #region Conditional Formatting Properties #region First Row Conditional Formatting Style firstRowStyle = tableStyle.ConditionalFormattingStyles.Add(ConditionalFormattingType.FirstRow); #region Character format firstRowStyle.CharacterFormat.Bold = true; firstRowStyle.CharacterFormat.BoldBidi = true; firstRowStyle.CharacterFormat.TextColor = System.Drawing.Color.FromArgb(255, 255, 255, 255); #endregion #region Table Cell Properties firstRowStyle.CellProperties.Borders.Top.BorderType = BorderStyle.Single; firstRowStyle.CellProperties.Borders.Top.LineWidth = 1f; firstRowStyle.CellProperties.Borders.Top.Color = borderColor; firstRowStyle.CellProperties.Borders.Top.Space = 0; firstRowStyle.CellProperties.Borders.Bottom.BorderType = BorderStyle.Single; firstRowStyle.CellProperties.Borders.Bottom.LineWidth = 1f; firstRowStyle.CellProperties.Borders.Bottom.Color = borderColor; firstRowStyle.CellProperties.Borders.Bottom.Space = 0; firstRowStyle.CellProperties.Borders.Left.BorderType = BorderStyle.Single; firstRowStyle.CellProperties.Borders.Left.LineWidth = 1f; firstRowStyle.CellProperties.Borders.Left.Color = borderColor; firstRowStyle.CellProperties.Borders.Left.Space = 0; firstRowStyle.CellProperties.Borders.Right.BorderType = BorderStyle.Single; firstRowStyle.CellProperties.Borders.Right.LineWidth = 1f; firstRowStyle.CellProperties.Borders.Right.Color = borderColor; firstRowStyle.CellProperties.Borders.Right.Space = 0; firstRowStyle.CellProperties.Borders.Horizontal.BorderType = BorderStyle.Cleared; firstRowStyle.CellProperties.Borders.Vertical.BorderType = BorderStyle.Cleared; firstRowStyle.CellProperties.BackColor = firstRowBackColor; firstRowStyle.CellProperties.ForeColor = System.Drawing.Color.FromArgb(0, 255, 255, 255); firstRowStyle.CellProperties.TextureStyle = TextureStyle.TextureNone; #endregion #endregion #region Last Row Conditional Formatting Style lastRowStyle = tableStyle.ConditionalFormattingStyles.Add(ConditionalFormattingType.LastRow); #region Character format lastRowStyle.CharacterFormat.Bold = true; lastRowStyle.CharacterFormat.BoldBidi = true; #endregion #region Table Cell Properties lastRowStyle.CellProperties.Borders.Top.BorderType = BorderStyle.Double; lastRowStyle.CellProperties.Borders.Top.LineWidth = .75f; lastRowStyle.CellProperties.Borders.Top.Color = borderColor; lastRowStyle.CellProperties.Borders.Top.Space = 0; lastRowStyle.CellProperties.Borders.Bottom.BorderType = BorderStyle.Single; lastRowStyle.CellProperties.Borders.Bottom.LineWidth = 1f; lastRowStyle.CellProperties.Borders.Bottom.Color = borderColor; lastRowStyle.CellProperties.Borders.Bottom.Space = 0; lastRowStyle.CellProperties.Borders.Left.BorderType = BorderStyle.Single; lastRowStyle.CellProperties.Borders.Left.LineWidth = 1f; lastRowStyle.CellProperties.Borders.Left.Color = borderColor; lastRowStyle.CellProperties.Borders.Left.Space = 0; lastRowStyle.CellProperties.Borders.Right.BorderType = BorderStyle.Single; lastRowStyle.CellProperties.Borders.Right.LineWidth = 1f; lastRowStyle.CellProperties.Borders.Right.Color = borderColor; lastRowStyle.CellProperties.Borders.Right.Space = 0; lastRowStyle.CellProperties.Borders.Horizontal.BorderType = BorderStyle.Cleared; lastRowStyle.CellProperties.Borders.Vertical.BorderType = BorderStyle.Cleared; #endregion #endregion #region First Column Conditional Formatting Style firstColumnStyle = tableStyle.ConditionalFormattingStyles.Add(ConditionalFormattingType.FirstColumn); #region Character format firstColumnStyle.CharacterFormat.Bold = true; firstColumnStyle.CharacterFormat.BoldBidi = true; #endregion #endregion #region Last Column Conditional Formatting Style lastColumnStyle = tableStyle.ConditionalFormattingStyles.Add(ConditionalFormattingType.LastColumn); #region Character format lastColumnStyle.CharacterFormat.Bold = true; lastColumnStyle.CharacterFormat.BoldBidi = true; #endregion #endregion #region Odd Column Banding Conditional Formatting Style oddColumnBandingStyle = tableStyle.ConditionalFormattingStyles.Add(ConditionalFormattingType.OddColumnBanding); #region Table Cell Properties oddColumnBandingStyle.CellProperties.BackColor = backColor; oddColumnBandingStyle.CellProperties.ForeColor = System.Drawing.Color.FromArgb(0, 255, 255, 255); oddColumnBandingStyle.CellProperties.TextureStyle = TextureStyle.TextureNone; #endregion #endregion #region Odd Row Banding Conditional Formatting Style oddRowBandingStyle = tableStyle.ConditionalFormattingStyles.Add(ConditionalFormattingType.OddRowBanding); #region Table Cell Properties oddRowBandingStyle.CellProperties.Borders.Horizontal.BorderType = BorderStyle.Cleared; oddRowBandingStyle.CellProperties.Borders.Vertical.BorderType = BorderStyle.Cleared; oddRowBandingStyle.CellProperties.BackColor = backColor; oddRowBandingStyle.CellProperties.ForeColor = System.Drawing.Color.FromArgb(0, 255, 255, 255); oddRowBandingStyle.CellProperties.TextureStyle = TextureStyle.TextureNone; #endregion #endregion #region Even Row Banding Conditional Formatting Style evenRowBandingStyle = tableStyle.ConditionalFormattingStyles.Add(ConditionalFormattingType.EvenRowBanding); #region Table Cell Properties evenRowBandingStyle.CellProperties.Borders.Horizontal.BorderType = BorderStyle.Cleared; evenRowBandingStyle.CellProperties.Borders.Vertical.BorderType = BorderStyle.Cleared; #endregion #endregion #endregion #endregion table.ApplyStyle("Tablestyle"); #endregion } #endregion Custom Style #region Document save option //Save as .docx format if (Group2 == "WordDocx") { return(document.ExportAsActionResult("Sample.docx", FormatType.Docx, HttpContext.ApplicationInstance.Response, HttpContentDisposition.Attachment)); } // Save as WordML(.xml) format else if (Group2 == "WordML") { return(document.ExportAsActionResult("Sample.xml", FormatType.WordML, HttpContext.ApplicationInstance.Response, HttpContentDisposition.Attachment)); } //Save as .pdf format else if (Group2 == "Pdf") { DocToPDFConverter converter = new DocToPDFConverter(); PdfDocument pdfDoc = converter.ConvertToPDF(document); return(pdfDoc.ExportAsActionResult("sample.pdf", HttpContext.ApplicationInstance.Response, HttpReadType.Save)); } #endregion Document save option return(View()); }
public ActionResult InsertBreak(string Group1) { if (Group1 == null) { return(View()); } //Creating a new document WordDocument document = new WordDocument(); //Adding a new section. IWSection section = document.AddSection(); IWParagraph paragraph = section.AddParagraph(); paragraph = section.AddParagraph(); section.PageSetup.Margins.All = 20f; IWTextRange text = paragraph.AppendText("Adventure products"); //Formatting Text text.CharacterFormat.FontName = "Bitstream Vera Sans"; text.CharacterFormat.FontSize = 12f; text.CharacterFormat.Bold = true; section.AddParagraph(); paragraph = section.AddParagraph(); paragraph.ParagraphFormat.LineSpacing = 20f; paragraph.AppendText("In 2000, Adventure Works Cycles bought a small manufacturing plant, Importadores Neptuno, located in Mexico. Importadores Neptuno manufactures several critical subcomponents for the Adventure Works Cycles product line. These subcomponents are shipped to the Bothell location for final product assembly. In 2001, Importadores Neptuno, became the sole manufacturer and distributor of the touring bicycle product group "); paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Justify; #region Line break paragraph.AppendBreak(BreakType.LineBreak); paragraph.AppendBreak(BreakType.LineBreak); #endregion Line break section = document.AddSection(); section.BreakCode = SectionBreakCode.NoBreak; section.PageSetup.Margins.All = 20f; //Adding three columns to section. section.AddColumn(100, 15); section.AddColumn(100, 15); section.AddColumn(100, 15); //Set the columns to be of equal width. section.MakeColumnsEqual(); //Adding a new paragraph to the section. paragraph = section.AddParagraph(); //Adding text. text = paragraph.AppendText("Mountain-200"); //Formatting Text text.CharacterFormat.FontName = "Bitstream Vera Sans"; text.CharacterFormat.FontSize = 12f; text.CharacterFormat.Bold = true; //Adding a new paragraph to the section. section.AddParagraph(); paragraph = section.AddParagraph(); string basePath = _hostingEnvironment.WebRootPath; FileStream imageStream = new FileStream(basePath + @"/images/DocIO/Mountain-200.jpg", FileMode.Open, FileAccess.Read); //Inserting an Image. WPicture picture = paragraph.AppendPicture(imageStream) as WPicture; picture.Width = 120f; picture.Height = 90f; //Adding a new paragraph to the section. section.AddParagraph(); paragraph = section.AddParagraph(); paragraph.ParagraphFormat.LineSpacing = 20f; //Adding text. paragraph.AppendText(@"Product No:BK-M68B-38" + "\n" + "Size: 38" + "\n" + "Weight: 25\n" + "Price: $2,294.99"); paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Justify; // Set column break as true. It navigates the cursor position to the next Column. paragraph.ParagraphFormat.ColumnBreakAfter = true; paragraph = section.AddParagraph(); text = paragraph.AppendText("Mountain-300"); text.CharacterFormat.FontName = "Bitstream Vera Sans"; text.CharacterFormat.FontSize = 12f; text.CharacterFormat.Bold = true; section.AddParagraph(); paragraph = section.AddParagraph(); imageStream = new FileStream(basePath + @"/images/DocIO/Mountain-300.jpg", FileMode.Open, FileAccess.Read); picture = paragraph.AppendPicture(imageStream) as WPicture; picture.Width = 120f; picture.Height = 90f; section.AddParagraph(); paragraph = section.AddParagraph(); paragraph.ParagraphFormat.LineSpacing = 20f; paragraph.AppendText(@"Product No:BK-M4-38" + "\n" + "Size: 35\n" + "Weight: 22" + "\n" + "Price: $1,079.99"); paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Justify; paragraph.ParagraphFormat.ColumnBreakAfter = true; paragraph = section.AddParagraph(); text = paragraph.AppendText("Road-150"); text.CharacterFormat.FontName = "Bitstream Vera Sans"; text.CharacterFormat.FontSize = 12f; text.CharacterFormat.Bold = true; section.AddParagraph(); paragraph = section.AddParagraph(); imageStream = new FileStream(basePath + @"/images/DocIO/Road-550-W.jpg", FileMode.Open, FileAccess.Read); picture = paragraph.AppendPicture(imageStream) as WPicture; picture.Width = 120f; picture.Height = 90f; section.AddParagraph(); paragraph = section.AddParagraph(); paragraph.ParagraphFormat.LineSpacing = 20f; paragraph.AppendText(@"Product No: BK-R93R-44" + "\n" + "Size: 44" + "\n" + "Weight: 14" + "\n" + "Price: $3,578.27"); paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Justify; section = document.AddSection(); section.BreakCode = SectionBreakCode.NoBreak; section.PageSetup.Margins.All = 20f; text = section.AddParagraph().AppendText("First Look\n"); //Formatting Text text.CharacterFormat.FontName = "Bitstream Vera Sans"; text.CharacterFormat.FontSize = 12f; text.CharacterFormat.Bold = true; paragraph = section.AddParagraph(); paragraph.ParagraphFormat.LineSpacing = 20f; paragraph.AppendText(@"Adventure Works Cycles, the fictitious company, is a large, multinational manufacturing company. The company manufactures and sells metal and composite bicycles to North American, European and Asian commercial markets. While its base operation is located in Bothell, Washington with 290 employees, several regional sales teams are located throughout their market base."); paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Justify; paragraph.ParagraphFormat.PageBreakAfter = true; paragraph = section.AddParagraph(); text = paragraph.AppendText("Introduction\n"); //Formatting Text text.CharacterFormat.FontName = "Bitstream Vera Sans"; text.CharacterFormat.FontSize = 12f; text.CharacterFormat.Bold = true; paragraph = section.AddParagraph(); paragraph.ParagraphFormat.LineSpacing = 20f; paragraph.AppendText(@"In 2000, Adventure Works Cycles bought a small manufacturing plant, Importadores Neptuno, located in Mexico. Importadores Neptuno manufactures several critical subcomponents for the Adventure Works Cycles product line. These subcomponents are shipped to the Bothell location for final product assembly. In 2001, Importadores Neptuno, became the sole manufacturer and distributor of the touring bicycle product group."); paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Justify; FormatType type = FormatType.Docx; string filename = "Sample.docx"; string contenttype = "application/vnd.ms-word.document.12"; #region Document SaveOption //Save as .doc format if (Group1 == "WordDoc") { type = FormatType.Doc; filename = "Sample.doc"; contenttype = "application/msword"; } //Save as .xml format else if (Group1 == "WordML") { type = FormatType.WordML; filename = "Sample.xml"; contenttype = "application/msword"; } #endregion Document SaveOption MemoryStream ms = new MemoryStream(); document.Save(ms, type); document.Close(); ms.Position = 0; return(File(ms, contenttype, filename)); }
private void button1_Click(object sender, System.EventArgs e) { try { //A new document is created. WordDocument document = new WordDocument(); //Create footnotes at the bottom of the page CreateFootNote(document); //Create endnotes at the end of the section CreateEndNote(document); //Save as doc format if (wordDocRadioBtn.Checked) { //Saving the document to disk. document.Save("Sample.doc"); //Message box confirmation to view the created document. if (MessageBoxAdv.Show("Do you want to view the generated Word document?", "Document has been created", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { //Launching the MS Word file using the default Application.[MS Word Or Free WordViewer] #if NETCORE System.Diagnostics.Process process = new System.Diagnostics.Process(); process.StartInfo = new System.Diagnostics.ProcessStartInfo("Sample.doc") { UseShellExecute = true }; process.Start(); #else System.Diagnostics.Process.Start("Sample.doc"); #endif //Exit this.Close(); } } //Save as docx format else if (wordDocxRadioBtn.Checked) { //Saving the document as .docx document.Save("Sample.docx", FormatType.Docx); //Message box confirmation to view the created document. if (MessageBoxAdv.Show("Do you want to view the generated Word document?", "Document has been created", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { try { //Launching the MS Word file using the default Application.[MS Word Or Free WordViewer] #if NETCORE System.Diagnostics.Process process = new System.Diagnostics.Process(); process.StartInfo = new System.Diagnostics.ProcessStartInfo("Sample.docx") { UseShellExecute = true }; process.Start(); #else System.Diagnostics.Process.Start("Sample.docx"); #endif //Exit this.Close(); } catch (Win32Exception ex) { MessageBoxAdv.Show("Microsoft Word Viewer or Microsoft Word is not installed in this system"); Console.WriteLine(ex.ToString()); } } } else { // Exit this.Close(); } } catch (Exception Ex) { MessageBox.Show(Ex.Message); } }
public bool MauSo4a( string KinhGui, string So, string QuyenSo, string HoTen_NV, string hovaten, string DiaChi, string ThuaDatSo, string ToBanDoSo, string DiaChiThuaDat, string DienTich_TD, string SDChung, string SDRieng, string SDMD, string TuThoiDiem, string THDNSD, string LoaiNhaO, string DTNhaO, string DTSan, string NOSDChung, string NOSDRieng, string NOKetCau, string NOSoTang, string NOThoiHanSH, string RXSLoaiCay, string RXSDienTich, string CLNLoaiCay, string RXSSHChung, string RXSSHRieng, string RXSThoiGianSH, string CLNDienTich, string CLNSHChung, string CLNSHRieng, string CLNThoiGianSH, string cua, string ndsd, string nguongoc, string GiayToKemTheo, string NhuCauGhiNo, string DeNghiKhac, string ThangV, string NgayV, string NamV ) { #region ===== Core====== MemoryStream mStream = null; WordDocument document = null; string fileBoNhiem = string.Empty; // Create currency format CultureInfo vietnam = new CultureInfo(1066); NumberFormatInfo vnfi = vietnam.NumberFormat; vnfi.CurrencySymbol = Constants.VN_UNIT; vnfi.CurrencyDecimalSeparator = Constants.CHAR_COMMA; vnfi.CurrencyDecimalDigits = 0; //Create Temp Folder if it does not exist if (!Directory.Exists(Global.AppPath + Constants.FOLDER_TEMP)) { Directory.CreateDirectory(Global.AppPath + Constants.FOLDER_TEMP); } //Gets DocFile is Existed string[] DocFile = Directory.GetFiles(Global.AppPath + Constants.FOLDER_TEMP + Constants.CHAR_FLASH, Constants.CHAR_STAR + Constants.FILE_EXT_DOC); //Delete *.doc file if existed foreach (string file in DocFile) { File.Delete(file); } //string path = Global.AppPath + Constants.FOLDER_TEMPLATES + Constants.CHAR_FLASH + FILE_QUYETDINHKHENTHUONG; try { // Read template mStream = new MemoryStream(File.ReadAllBytes("MauSo4a.docx").ToArray());// I document = new WordDocument(mStream); mStream.Close(); } catch { return(false); } fileBoNhiem = Global.AppPath + Constants.FOLDER_TEMP + Constants.CHAR_FLASH + "MauSo4a" + Constants.FILE_EXT_DOC; // II xuat //Prepare to mailMerg DateTime SysDate = DateTime.Now; #endregion ===== End Core===== #region === Set value =====//III // text fields string[] fields = new string[] { "KinhGui", "So", "QuyenSo", "HoVaTen_NVD", "HoVaTen", "DiaChi", "ThuaDatSo", "ToBanDoSo", "DiaChiThuaDat", "DienTich_TD", "SDChung", "SDRieng", "SDMD", "TuThoiDiem", "LoaiNhaO", "DTNhaO", "DTSan", "NOSDChung", "NOSDRieng", "NOKetCau", "NOSoTang", "NOThoiHanSH", "RXSLoaiCay", "RXSDienTich", "CLNLoaiCay", "RXSSHChung", "RXSSHRieng", "RXSThoiGianSH", "CLNDienTich", "CLNSHChung", "CLNSHRieng", "CLNThoiGianSH", "GiayToKemTheo", "NhuCauGhiNo", "DeNghiKhac", "NgayV", "ThangV", "NamV", "cua", "NguonGoc", "THDNSD", "Noidungsd" }; string[] values = new string[] { KinhGui, So, QuyenSo, HoTen_NV, hovaten, DiaChi, ThuaDatSo, ToBanDoSo, DiaChiThuaDat, DienTich_TD, SDChung, SDRieng, SDMD, TuThoiDiem, LoaiNhaO, DTNhaO, DTSan, NOSDChung, NOSDRieng, NOKetCau, NOSoTang, NOThoiHanSH, RXSLoaiCay, RXSDienTich, CLNLoaiCay, RXSSHChung, RXSSHRieng, RXSThoiGianSH, CLNDienTich, CLNSHChung, CLNSHRieng, CLNThoiGianSH, GiayToKemTheo, NhuCauGhiNo, DeNghiKhac, NgayV, ThangV, NamV, cua, nguongoc, THDNSD, ndsd }; #endregion End Set Value===== #region =====Core===== // Begin mailMerg document document.MailMerge.Execute(fields, values); // Save document to file document.Save(fileBoNhiem, FormatType.Doc); // Close the document after save document.Close(); this.PrinPriview(fileBoNhiem); #endregion ===== End Core===== return(true); }
private void btnCreate_Click(object sender, EventArgs e) { // Creating a new document. WordDocument document = new WordDocument(); //Adding a new section to the document. WSection section = document.AddSection() as WSection; //Set Margin of the section section.PageSetup.Margins.All = 72; //Set page size of the section section.PageSetup.PageSize = new Syncfusion.Drawing.SizeF(612, 792); //Create Paragraph styles WParagraphStyle style = document.AddParagraphStyle("Normal") as WParagraphStyle; style.CharacterFormat.FontName = "Calibri"; style.CharacterFormat.FontSize = 11f; style.ParagraphFormat.BeforeSpacing = 0; style.ParagraphFormat.AfterSpacing = 8; style.ParagraphFormat.LineSpacing = 13.8f; style = document.AddParagraphStyle("Heading 1") as WParagraphStyle; style.ApplyBaseStyle("Normal"); style.CharacterFormat.FontName = "Calibri Light"; style.CharacterFormat.FontSize = 16f; // style.CharacterFormat.TextColor = Color.FromArgb(46, 116, 181); style.CharacterFormat.TextColor = Syncfusion.Drawing.Color.FromArgb(46, 116, 181); style.ParagraphFormat.BeforeSpacing = 12; style.ParagraphFormat.AfterSpacing = 0; style.ParagraphFormat.Keep = true; style.ParagraphFormat.KeepFollow = true; style.ParagraphFormat.OutlineLevel = OutlineLevel.Level1; IWParagraph paragraph = section.HeadersFooters.Header.AddParagraph(); // Gets the image stream. /* * IWPicture picture = paragraph.AppendPicture(new Bitmap("AdventureCycle.jpg")) as WPicture; * * picture.TextWrappingStyle = TextWrappingStyle.InFrontOfText; * picture.VerticalOrigin = VerticalOrigin.Margin; * picture.VerticalPosition = -45; * picture.HorizontalOrigin = HorizontalOrigin.Column; * picture.HorizontalPosition = 263.5f; * picture.WidthScale = 20; * picture.HeightScale = 15; */ paragraph.ApplyStyle("Normal"); paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Left; WTextRange textRange = paragraph.AppendText("Adventure Works Cycles") as WTextRange; textRange.CharacterFormat.FontSize = 12f; textRange.CharacterFormat.FontName = "Calibri"; textRange.CharacterFormat.TextColor = Syncfusion.Drawing.Color.Red; //Appends paragraph. paragraph = section.AddParagraph(); paragraph.ApplyStyle("Heading 1"); paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center; textRange = paragraph.AppendText("Adventure Works Cycles") as WTextRange; textRange.CharacterFormat.FontSize = 18f; textRange.CharacterFormat.FontName = "Calibri"; //Appends paragraph. paragraph = section.AddParagraph(); paragraph.ParagraphFormat.FirstLineIndent = 36; paragraph.BreakCharacterFormat.FontSize = 12f; textRange = paragraph.AppendText("Adventure Works Cycles, the fictitious company on which the AdventureWorks sample databases are based, is a large, multinational manufacturing company. The company manufactures and sells metal and composite bicycles to North American, European and Asian commercial markets. While its base operation is in Bothell, Washington with 290 employees, several regional sales teams are located throughout their market base.") as WTextRange; textRange.CharacterFormat.FontSize = 12f; //Appends paragraph. paragraph = section.AddParagraph(); paragraph.ParagraphFormat.FirstLineIndent = 36; paragraph.BreakCharacterFormat.FontSize = 12f; textRange = paragraph.AppendText("In 2000, AdventureWorks Cycles bought a small manufacturing plant, Importadores Neptuno, located in Mexico. Importadores Neptuno manufactures several critical subcomponents for the AdventureWorks Cycles product line. These subcomponents are shipped to the Bothell location for final product assembly. In 2001, Importadores Neptuno, became the sole manufacturer and distributor of the touring bicycle product group.") as WTextRange; textRange.CharacterFormat.FontSize = 12f; paragraph = section.AddParagraph(); paragraph.ApplyStyle("Heading 1"); paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Left; textRange = paragraph.AppendText("Product Overview") as WTextRange; textRange.CharacterFormat.FontSize = 16f; textRange.CharacterFormat.FontName = "Calibri"; //Appends table. IWTable table = section.AddTable(); table.ResetCells(3, 2); table.TableFormat.Borders.BorderType = Syncfusion.DocIO.DLS.BorderStyle.None; table.TableFormat.IsAutoResized = true; //Appends paragraph. paragraph = table[0, 0].AddParagraph(); paragraph.ParagraphFormat.AfterSpacing = 0; paragraph.BreakCharacterFormat.FontSize = 12f; //Appends picture to the paragraph. /* * picture = paragraph.AppendPicture(new Bitmap("Mountain-200.jpg")) as WPicture; * picture.TextWrappingStyle = TextWrappingStyle.TopAndBottom; * picture.VerticalOrigin = VerticalOrigin.Paragraph; * picture.VerticalPosition = 4.5f; * picture.HorizontalOrigin = HorizontalOrigin.Column; * picture.HorizontalPosition = -2.15f; * picture.WidthScale = 79; * picture.HeightScale = 79; */ //Appends paragraph. paragraph = table[0, 1].AddParagraph(); paragraph.ApplyStyle("Heading 1"); paragraph.ParagraphFormat.AfterSpacing = 0; paragraph.ParagraphFormat.LineSpacing = 12f; paragraph.AppendText("Mountain-200"); //Appends paragraph. paragraph = table[0, 1].AddParagraph(); paragraph.ParagraphFormat.AfterSpacing = 0; paragraph.ParagraphFormat.LineSpacing = 12f; paragraph.BreakCharacterFormat.FontSize = 12f; paragraph.BreakCharacterFormat.FontName = "Times New Roman"; textRange = paragraph.AppendText("Product No: BK-M68B-38\r") as WTextRange; textRange.CharacterFormat.FontSize = 12f; textRange.CharacterFormat.FontName = "Times New Roman"; textRange = paragraph.AppendText("Size: 38\r") as WTextRange; textRange.CharacterFormat.FontSize = 12f; textRange.CharacterFormat.FontName = "Times New Roman"; textRange = paragraph.AppendText("Weight: 25\r") as WTextRange; textRange.CharacterFormat.FontSize = 12f; textRange.CharacterFormat.FontName = "Times New Roman"; textRange = paragraph.AppendText("Price: $2,294.99\r") as WTextRange; textRange.CharacterFormat.FontSize = 12f; textRange.CharacterFormat.FontName = "Times New Roman"; //Appends paragraph. paragraph = table[0, 1].AddParagraph(); paragraph.ParagraphFormat.AfterSpacing = 0; paragraph.ParagraphFormat.LineSpacing = 12f; paragraph.BreakCharacterFormat.FontSize = 12f; //Appends paragraph. paragraph = table[1, 0].AddParagraph(); paragraph.ApplyStyle("Heading 1"); paragraph.ParagraphFormat.AfterSpacing = 0; paragraph.ParagraphFormat.LineSpacing = 12f; paragraph.AppendText("Mountain-300 "); //Appends paragraph. paragraph = table[1, 0].AddParagraph(); paragraph.ParagraphFormat.AfterSpacing = 0; paragraph.ParagraphFormat.LineSpacing = 12f; paragraph.BreakCharacterFormat.FontSize = 12f; paragraph.BreakCharacterFormat.FontName = "Times New Roman"; textRange = paragraph.AppendText("Product No: BK-M47B-38\r") as WTextRange; textRange.CharacterFormat.FontSize = 12f; textRange.CharacterFormat.FontName = "Times New Roman"; textRange = paragraph.AppendText("Size: 35\r") as WTextRange; textRange.CharacterFormat.FontSize = 12f; textRange.CharacterFormat.FontName = "Times New Roman"; textRange = paragraph.AppendText("Weight: 22\r") as WTextRange; textRange.CharacterFormat.FontSize = 12f; textRange.CharacterFormat.FontName = "Times New Roman"; textRange = paragraph.AppendText("Price: $1,079.99\r") as WTextRange; textRange.CharacterFormat.FontSize = 12f; textRange.CharacterFormat.FontName = "Times New Roman"; //Appends paragraph. paragraph = table[1, 0].AddParagraph(); paragraph.ParagraphFormat.AfterSpacing = 0; paragraph.ParagraphFormat.LineSpacing = 12f; paragraph.BreakCharacterFormat.FontSize = 12f; //Appends paragraph. paragraph = table[1, 1].AddParagraph(); paragraph.ApplyStyle("Heading 1"); paragraph.ParagraphFormat.LineSpacing = 12f; //Appends picture to the paragraph. /* * picture = paragraph.AppendPicture(new Bitmap("Mountain-300.jpg")) as WPicture; * picture.TextWrappingStyle = TextWrappingStyle.TopAndBottom; * picture.VerticalOrigin = VerticalOrigin.Paragraph; * picture.VerticalPosition = 8.2f; * picture.HorizontalOrigin = HorizontalOrigin.Column; * picture.HorizontalPosition = -14.95f; * picture.WidthScale = 75; * picture.HeightScale = 75; */ //Appends paragraph. paragraph = table[2, 0].AddParagraph(); paragraph.ApplyStyle("Heading 1"); paragraph.ParagraphFormat.LineSpacing = 12f; //Appends picture to the paragraph. /* * picture = paragraph.AppendPicture(new Bitmap("Road-550-W.jpg")) as WPicture; * picture.TextWrappingStyle = TextWrappingStyle.TopAndBottom; * picture.VerticalOrigin = VerticalOrigin.Paragraph; * picture.VerticalPosition = 3.75f; * picture.HorizontalOrigin = HorizontalOrigin.Column; * picture.HorizontalPosition = -5f; * picture.WidthScale = 92; * picture.HeightScale = 92; */ //Appends paragraph. paragraph = table[2, 1].AddParagraph(); paragraph.ApplyStyle("Heading 1"); paragraph.ParagraphFormat.AfterSpacing = 0; paragraph.ParagraphFormat.LineSpacing = 12f; paragraph.AppendText("Road-150 "); //Appends paragraph. paragraph = table[2, 1].AddParagraph(); paragraph.ParagraphFormat.AfterSpacing = 0; paragraph.ParagraphFormat.LineSpacing = 12f; paragraph.BreakCharacterFormat.FontSize = 12f; paragraph.BreakCharacterFormat.FontName = "Times New Roman"; textRange = paragraph.AppendText("Product No: BK-R93R-44\r") as WTextRange; textRange.CharacterFormat.FontSize = 12f; textRange.CharacterFormat.FontName = "Times New Roman"; textRange = paragraph.AppendText("Size: 44\r") as WTextRange; textRange.CharacterFormat.FontSize = 12f; textRange.CharacterFormat.FontName = "Times New Roman"; textRange = paragraph.AppendText("Weight: 14\r") as WTextRange; textRange.CharacterFormat.FontSize = 12f; textRange.CharacterFormat.FontName = "Times New Roman"; textRange = paragraph.AppendText("Price: $3,578.27\r") as WTextRange; textRange.CharacterFormat.FontSize = 12f; textRange.CharacterFormat.FontName = "Times New Roman"; //Appends paragraph. section.AddParagraph(); //Saves the Word document //document.Save("Sample.docx"); // создаем каталог для файла string path = @"C:\SomeDir2"; DirectoryInfo dirInfo = new DirectoryInfo(path); if (!dirInfo.Exists) { dirInfo.Create(); } // запись в файл using (FileStream fstream = new FileStream($"{path}\\Sample.docx", FileMode.OpenOrCreate)) { document.Save(fstream, 0); } }
void OnButtonClicked(object sender, EventArgs e) { Assembly assembly = Assembly.GetExecutingAssembly(); //Creates an empty Word document instance. WordDocument document = new WordDocument(); Stream inputStream = assembly.GetManifestResourceStream("SampleBrowser.Samples.DocIO.Templates.ContentControlTemplate.docx"); //Opens template document. document.Open(inputStream, FormatType.Word2013); IWTextRange textRange; //Gets table from the template document. IWTable table = document.LastSection.Tables[0]; WTableRow row = table.Rows[1]; #region Inserting content controls #region Calendar content control IWParagraph cellPara = row.Cells[0].Paragraphs[0]; //Accesses the date picker content control. IInlineContentControl inlineControl = (cellPara.ChildEntities[2] as IInlineContentControl); textRange = inlineControl.ParagraphItems[0] as WTextRange; //Sets today's date to display. textRange.Text = DateTime.Now.ToShortDateString(); textRange.CharacterFormat.FontSize = 14; //Protects the content control. inlineControl.ContentControlProperties.LockContents = true; #endregion #region Plain text content controls table = document.LastSection.Tables[1]; row = table.Rows[0]; cellPara = row.Cells[0].LastParagraph; //Accesses the plain text content control. inlineControl = (cellPara.ChildEntities[1] as IInlineContentControl); //Protects the content control. inlineControl.ContentControlProperties.LockContents = true; textRange = inlineControl.ParagraphItems[0] as WTextRange; //Sets text in plain text content control. textRange.Text = "Northwind Analytics"; textRange.CharacterFormat.FontSize = 14; cellPara = row.Cells[1].LastParagraph; //Accesses the plain text content control. inlineControl = (cellPara.ChildEntities[1] as IInlineContentControl); //Protects the content control. inlineControl.ContentControlProperties.LockContents = true; textRange = inlineControl.ParagraphItems[0] as WTextRange; //Sets text in plain text content control. textRange.Text = "Northwind"; textRange.CharacterFormat.FontSize = 14; row = table.Rows[1]; cellPara = row.Cells[0].LastParagraph; //Accesses the plain text content control. inlineControl = (cellPara.ChildEntities[1] as IInlineContentControl); //Protects the content control. inlineControl.ContentControlProperties.LockContents = true; //Sets text in plain text content control. textRange = inlineControl.ParagraphItems[0] as WTextRange; textRange.Text = "10"; textRange.CharacterFormat.FontSize = 14; cellPara = row.Cells[1].LastParagraph; //Accesses the plain text content control. inlineControl = (cellPara.ChildEntities[1] as IInlineContentControl); //Protects the content control. inlineControl.ContentControlProperties.LockContents = true; //Sets text in plain text content control. textRange = inlineControl.ParagraphItems[0] as WTextRange; textRange.Text = "Nancy Davolio"; textRange.CharacterFormat.FontSize = 14; #endregion #region CheckBox Content control row = table.Rows[2]; cellPara = row.Cells[0].LastParagraph; //Inserts checkbox content control. inlineControl = cellPara.AppendInlineContentControl(ContentControlType.CheckBox); inlineControl.ContentControlProperties.LockContents = true; //Sets checkbox as checked state. inlineControl.ContentControlProperties.IsChecked = true; textRange = cellPara.AppendText("C#, "); textRange.CharacterFormat.FontSize = 14; //Inserts checkbox content control. inlineControl = cellPara.AppendInlineContentControl(ContentControlType.CheckBox); inlineControl.ContentControlProperties.LockContents = true; //Sets checkbox as checked state. inlineControl.ContentControlProperties.IsChecked = true; textRange = cellPara.AppendText("VB"); textRange.CharacterFormat.FontSize = 14; #endregion #region Drop down list content control cellPara = row.Cells[1].LastParagraph; //Accesses the dropdown list content control. inlineControl = (cellPara.ChildEntities[1] as IInlineContentControl); inlineControl.ContentControlProperties.LockContents = true; //Sets default option to display. textRange = inlineControl.ParagraphItems[0] as WTextRange; textRange.Text = "ASP.NET"; textRange.CharacterFormat.FontSize = 14; inlineControl.ParagraphItems.Add(textRange); //Adds items to the dropdown list. ContentControlListItem item; item = new ContentControlListItem(); item.DisplayText = "ASP.NET MVC"; item.Value = "2"; inlineControl.ContentControlProperties.ContentControlListItems.Add(item); item = new ContentControlListItem(); item.DisplayText = "Windows Forms"; item.Value = "3"; inlineControl.ContentControlProperties.ContentControlListItems.Add(item); item = new ContentControlListItem(); item.DisplayText = "WPF"; item.Value = "4"; inlineControl.ContentControlProperties.ContentControlListItems.Add(item); item = new ContentControlListItem(); item.DisplayText = "Xamarin"; item.Value = "5"; inlineControl.ContentControlProperties.ContentControlListItems.Add(item); #endregion #region Calendar content control row = table.Rows[3]; cellPara = row.Cells[0].LastParagraph; //Accesses the date picker content control. inlineControl = (cellPara.ChildEntities[1] as IInlineContentControl); inlineControl.ContentControlProperties.LockContents = true; //Sets default date to display. textRange = inlineControl.ParagraphItems[0] as WTextRange; textRange.Text = DateTime.Now.AddDays(-5).ToShortDateString(); textRange.CharacterFormat.FontSize = 14; cellPara = row.Cells[1].LastParagraph; //Inserts date picker content control. inlineControl = (cellPara.ChildEntities[1] as IInlineContentControl); inlineControl.ContentControlProperties.LockContents = true; //Sets default date to display. textRange = inlineControl.ParagraphItems[0] as WTextRange; textRange.Text = DateTime.Now.AddDays(10).ToShortDateString(); textRange.CharacterFormat.FontSize = 14; #endregion #endregion #region Block content control //Accesses the block content control. BlockContentControl blockContentControl = ((document.ChildEntities[0] as WSection).Body.ChildEntities[2] as BlockContentControl); //Protects the block content control blockContentControl.ContentControlProperties.LockContents = true; #endregion MemoryStream stream = new MemoryStream(); document.Save(stream, FormatType.Word2013); document.Close(); if (stream != null) { SaveAndroid androidSave = new SaveAndroid(); androidSave.Save("FormFillingAndProtection.docx", "application/msword", stream, m_context); } }
private void button1_Click(object sender, System.EventArgs e) { try { //Getting Image files path. string dataPath = Application.StartupPath + @"..\..\..\..\..\..\..\..\Common\images\DocIO\"; //A new document is created. WordDocument document = new WordDocument(); //Adding a new section to the document. WSection section = document.AddSection() as WSection; //Set Margin of the section section.PageSetup.Margins.All = 72; //Set page size of the section section.PageSetup.PageSize = new SizeF(612, 792); //Create Paragraph styles WParagraphStyle style = document.AddParagraphStyle("Normal") as WParagraphStyle; style.CharacterFormat.FontName = "Calibri"; style.CharacterFormat.FontSize = 11f; style.ParagraphFormat.BeforeSpacing = 0; style.ParagraphFormat.AfterSpacing = 8; style.ParagraphFormat.LineSpacing = 13.8f; style = document.AddParagraphStyle("Heading 1") as WParagraphStyle; style.ApplyBaseStyle("Normal"); style.CharacterFormat.FontName = "Calibri Light"; style.CharacterFormat.FontSize = 16f; style.CharacterFormat.TextColor = Color.FromArgb(46, 116, 181); style.ParagraphFormat.BeforeSpacing = 12; style.ParagraphFormat.AfterSpacing = 0; style.ParagraphFormat.Keep = true; style.ParagraphFormat.KeepFollow = true; style.ParagraphFormat.OutlineLevel = OutlineLevel.Level1; IWParagraph paragraph = section.HeadersFooters.Header.AddParagraph(); WPicture picture = paragraph.AppendPicture(Image.FromFile(dataPath + "AdventureCycle.jpg")) as WPicture; picture.TextWrappingStyle = TextWrappingStyle.InFrontOfText; picture.VerticalOrigin = VerticalOrigin.Margin; picture.VerticalPosition = -45; picture.HorizontalOrigin = HorizontalOrigin.Column; picture.HorizontalPosition = 263.5f; picture.WidthScale = 20; picture.HeightScale = 15; paragraph.ApplyStyle("Normal"); paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Left; WTextRange textRange = paragraph.AppendText("Adventure Works Cycles") as WTextRange; textRange.CharacterFormat.FontSize = 12f; textRange.CharacterFormat.FontName = "Calibri"; textRange.CharacterFormat.TextColor = Color.Red; //Appends paragraph. paragraph = section.AddParagraph(); paragraph.ApplyStyle("Heading 1"); paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Center; textRange = paragraph.AppendText("Adventure Works Cycles") as WTextRange; textRange.CharacterFormat.FontSize = 18f; textRange.CharacterFormat.FontName = "Calibri"; //Appends paragraph. paragraph = section.AddParagraph(); paragraph.ParagraphFormat.FirstLineIndent = 36; paragraph.BreakCharacterFormat.FontSize = 12f; textRange = paragraph.AppendText("Adventure Works Cycles, the fictitious company on which the AdventureWorks sample databases are based, is a large, multinational manufacturing company. The company manufactures and sells metal and composite bicycles to North American, European and Asian commercial markets. While its base operation is located in Bothell, Washington with 290 employees, several regional sales teams are located throughout their market base.") as WTextRange; textRange.CharacterFormat.FontSize = 12f; paragraph = section.AddParagraph(); paragraph.ParagraphFormat.FirstLineIndent = 36; paragraph.BreakCharacterFormat.FontSize = 12f; textRange = paragraph.AppendText("In 2000, Adventure Works Cycles bought a small manufacturing plant, Importadores Neptuno, located in Mexico. Importadores Neptuno manufactures several critical subcomponents for the Adventure Works Cycles product line. These subcomponents are shipped to the Bothell location for final product assembly. In 2001, Importadores Neptuno, became the sole manufacturer and distributor of the touring bicycle product group.") as WTextRange; textRange.CharacterFormat.FontSize = 12f; paragraph = section.AddParagraph(); paragraph.ApplyStyle("Heading 1"); paragraph.ParagraphFormat.HorizontalAlignment = Syncfusion.DocIO.DLS.HorizontalAlignment.Left; textRange = paragraph.AppendText("Product Overview") as WTextRange; textRange.CharacterFormat.FontSize = 16f; textRange.CharacterFormat.FontName = "Calibri"; //Appends table. IWTable table = section.AddTable(); table.ResetCells(3, 2); table.TableFormat.Borders.BorderType = Syncfusion.DocIO.DLS.BorderStyle.None; table.TableFormat.IsAutoResized = true; //Appends paragraph. paragraph = table[0, 0].AddParagraph(); paragraph.ParagraphFormat.AfterSpacing = 0; paragraph.BreakCharacterFormat.FontSize = 12f; //Appends picture to the paragraph. picture = paragraph.AppendPicture(Image.FromFile(dataPath + "Mountain-200.jpg")) as WPicture; picture.TextWrappingStyle = TextWrappingStyle.TopAndBottom; picture.VerticalOrigin = VerticalOrigin.Paragraph; picture.VerticalPosition = 4.5f; picture.HorizontalOrigin = HorizontalOrigin.Column; picture.HorizontalPosition = -2.15f; picture.WidthScale = 79; picture.HeightScale = 79; //Appends paragraph. paragraph = table[0, 1].AddParagraph(); paragraph.ApplyStyle("Heading 1"); paragraph.ParagraphFormat.AfterSpacing = 0; paragraph.ParagraphFormat.LineSpacing = 12f; paragraph.AppendText("Mountain-200"); //Appends paragraph. paragraph = table[0, 1].AddParagraph(); paragraph.ParagraphFormat.AfterSpacing = 0; paragraph.ParagraphFormat.LineSpacing = 12f; paragraph.BreakCharacterFormat.FontSize = 12f; paragraph.BreakCharacterFormat.FontName = "Times New Roman"; textRange = paragraph.AppendText("Product No: BK-M68B-38\r") as WTextRange; textRange.CharacterFormat.FontSize = 12f; textRange.CharacterFormat.FontName = "Times New Roman"; textRange = paragraph.AppendText("Size: 38\r") as WTextRange; textRange.CharacterFormat.FontSize = 12f; textRange.CharacterFormat.FontName = "Times New Roman"; textRange = paragraph.AppendText("Weight: 25\r") as WTextRange; textRange.CharacterFormat.FontSize = 12f; textRange.CharacterFormat.FontName = "Times New Roman"; textRange = paragraph.AppendText("Price: $2,294.99\r") as WTextRange; textRange.CharacterFormat.FontSize = 12f; textRange.CharacterFormat.FontName = "Times New Roman"; //Appends paragraph. paragraph = table[0, 1].AddParagraph(); paragraph.ParagraphFormat.AfterSpacing = 0; paragraph.ParagraphFormat.LineSpacing = 12f; paragraph.BreakCharacterFormat.FontSize = 12f; //Appends paragraph. paragraph = table[1, 0].AddParagraph(); paragraph.ApplyStyle("Heading 1"); paragraph.ParagraphFormat.AfterSpacing = 0; paragraph.ParagraphFormat.LineSpacing = 12f; paragraph.AppendText("Mountain-300 "); //Appends paragraph. paragraph = table[1, 0].AddParagraph(); paragraph.ParagraphFormat.AfterSpacing = 0; paragraph.ParagraphFormat.LineSpacing = 12f; paragraph.BreakCharacterFormat.FontSize = 12f; paragraph.BreakCharacterFormat.FontName = "Times New Roman"; textRange = paragraph.AppendText("Product No: BK-M47B-38\r") as WTextRange; textRange.CharacterFormat.FontSize = 12f; textRange.CharacterFormat.FontName = "Times New Roman"; textRange = paragraph.AppendText("Size: 35\r") as WTextRange; textRange.CharacterFormat.FontSize = 12f; textRange.CharacterFormat.FontName = "Times New Roman"; textRange = paragraph.AppendText("Weight: 22\r") as WTextRange; textRange.CharacterFormat.FontSize = 12f; textRange.CharacterFormat.FontName = "Times New Roman"; textRange = paragraph.AppendText("Price: $1,079.99\r") as WTextRange; textRange.CharacterFormat.FontSize = 12f; textRange.CharacterFormat.FontName = "Times New Roman"; //Appends paragraph. paragraph = table[1, 0].AddParagraph(); paragraph.ParagraphFormat.AfterSpacing = 0; paragraph.ParagraphFormat.LineSpacing = 12f; paragraph.BreakCharacterFormat.FontSize = 12f; //Appends paragraph. paragraph = table[1, 1].AddParagraph(); paragraph.ApplyStyle("Heading 1"); paragraph.ParagraphFormat.LineSpacing = 12f; //Appends picture to the paragraph. picture = paragraph.AppendPicture(Image.FromFile(dataPath + "Mountain-300.jpg")) as WPicture; picture.TextWrappingStyle = TextWrappingStyle.TopAndBottom; picture.VerticalOrigin = VerticalOrigin.Paragraph; picture.VerticalPosition = 8.2f; picture.HorizontalOrigin = HorizontalOrigin.Column; picture.HorizontalPosition = -14.95f; picture.WidthScale = 75; picture.HeightScale = 75; //Appends paragraph. paragraph = table[2, 0].AddParagraph(); paragraph.ApplyStyle("Heading 1"); paragraph.ParagraphFormat.LineSpacing = 12f; //Appends picture to the paragraph. picture = paragraph.AppendPicture(Image.FromFile(dataPath + "Road-550-W.jpg")) as WPicture; picture.TextWrappingStyle = TextWrappingStyle.TopAndBottom; picture.VerticalOrigin = VerticalOrigin.Paragraph; picture.VerticalPosition = 3.75f; picture.HorizontalOrigin = HorizontalOrigin.Column; picture.HorizontalPosition = -5f; picture.WidthScale = 92; picture.HeightScale = 92; //Appends paragraph. paragraph = table[2, 1].AddParagraph(); paragraph.ApplyStyle("Heading 1"); paragraph.ParagraphFormat.AfterSpacing = 0; paragraph.ParagraphFormat.LineSpacing = 12f; paragraph.AppendText("Road-150 "); //Appends paragraph. paragraph = table[2, 1].AddParagraph(); paragraph.ParagraphFormat.AfterSpacing = 0; paragraph.ParagraphFormat.LineSpacing = 12f; paragraph.BreakCharacterFormat.FontSize = 12f; paragraph.BreakCharacterFormat.FontName = "Times New Roman"; textRange = paragraph.AppendText("Product No: BK-R93R-44\r") as WTextRange; textRange.CharacterFormat.FontSize = 12f; textRange.CharacterFormat.FontName = "Times New Roman"; textRange = paragraph.AppendText("Size: 44\r") as WTextRange; textRange.CharacterFormat.FontSize = 12f; textRange.CharacterFormat.FontName = "Times New Roman"; textRange = paragraph.AppendText("Weight: 14\r") as WTextRange; textRange.CharacterFormat.FontSize = 12f; textRange.CharacterFormat.FontName = "Times New Roman"; textRange = paragraph.AppendText("Price: $3,578.27\r") as WTextRange; textRange.CharacterFormat.FontSize = 12f; textRange.CharacterFormat.FontName = "Times New Roman"; //Appends paragraph. section.AddParagraph(); //Save as doc format if (wordDocRadioBtn.Checked) { //Saving the document to disk. document.Save("Sample.doc"); //Message box confirmation to view the created document. if (MessageBoxAdv.Show("Do you want to view the generated Word document?", "Document has been created", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { //Launching the MS Word file using the default Application.[MS Word Or Free WordViewer] #if NETCORE System.Diagnostics.Process process = new System.Diagnostics.Process(); process.StartInfo = new System.Diagnostics.ProcessStartInfo("Sample.doc") { UseShellExecute = true }; process.Start(); #else System.Diagnostics.Process.Start("Sample.doc"); #endif //Exit this.Close(); } } //Save as docx format else if (wordDocxRadioBtn.Checked) { //Saving the document as .docx document.Save("Sample.docx", FormatType.Docx); //Message box confirmation to view the created document. if (MessageBoxAdv.Show("Do you want to view the generated Word document?", "Document has been created", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { try { //Launching the MS Word file using the default Application.[MS Word Or Free WordViewer] #if NETCORE System.Diagnostics.Process process = new System.Diagnostics.Process(); process.StartInfo = new System.Diagnostics.ProcessStartInfo("Sample.docx") { UseShellExecute = true }; process.Start(); #else System.Diagnostics.Process.Start("Sample.docx"); #endif //Exit this.Close(); } catch (Win32Exception ex) { MessageBoxAdv.Show("Microsoft Word Viewer or Microsoft Word is not installed in this system"); Console.WriteLine(ex.ToString()); } } } //Save as pdf format else if (pdfRadioBtn.Checked) { DocToPDFConverter converter = new DocToPDFConverter(); //Convert word document into PDF document PdfDocument pdfDoc = converter.ConvertToPDF(document); //Save the pdf file pdfDoc.Save("Sample.pdf"); //Message box confirmation to view the created document. if (MessageBoxAdv.Show("Do you want to view the generated PDF?", " Document has been created", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { try { #if NETCORE System.Diagnostics.Process process = new System.Diagnostics.Process(); process.StartInfo = new System.Diagnostics.ProcessStartInfo("Sample.pdf") { UseShellExecute = true }; process.Start(); #else System.Diagnostics.Process.Start("Sample.pdf"); #endif //Exit this.Close(); } catch (Exception ex) { MessageBoxAdv.Show("PDF Viewer is not installed in this system"); Console.WriteLine(ex.ToString()); } } } else { // Exit this.Close(); } } catch (Exception Ex) { MessageBox.Show(Ex.Message); } }