static void Main(string[] args) { using (RichEditDocumentServer wordProcessor = new RichEditDocumentServer()) { //Register the created service implementation wordProcessor.LoadDocument("Multimodal.docx"); //Load embedded dictionaries var openOfficePatternStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("word_processing_hyphenation.hyphen.dic"); var customDictionaryStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("word_processing_hyphenation.hyphen_exc.dic"); //Create dictionary objects OpenOfficeHyphenationDictionary hyphenationDictionary = new OpenOfficeHyphenationDictionary(openOfficePatternStream, new System.Globalization.CultureInfo("EN-US")); CustomHyphenationDictionary exceptionsDictionary = new CustomHyphenationDictionary(customDictionaryStream, new System.Globalization.CultureInfo("EN-US")); //Add them to the word processor's collection wordProcessor.HyphenationDictionaries.Add(hyphenationDictionary); wordProcessor.HyphenationDictionaries.Add(exceptionsDictionary); //Specify hyphenation settings wordProcessor.Document.Hyphenation = true; wordProcessor.Document.HyphenateCaps = true; //Export the result to the PDF format wordProcessor.ExportToPdf("Result.pdf"); } //Open the result Process.Start("Result.pdf"); }
private void button1_Click(object sender, EventArgs e) { RichEditDocumentServer server = new RichEditDocumentServer(); server.LoadDocument("fish.rtf"); DocumentRange[] ranges = server.Document.FindAll(DevExpress.Office.Characters.PageBreak.ToString(), DevExpress.XtraRichEdit.API.Native.SearchOptions.None); DocumentPosition dp = server.Document.Paragraphs[0].Range.Start; List <MyRtfObject> collection = new List <MyRtfObject>(); foreach (DocumentRange dr in ranges) { DocumentRange tmpRange = server.Document.CreateRange(dp, dr.Start.ToInt() - dp.ToInt()); collection.Add(new MyRtfObject() { RtfSplitContent = server.Document.GetRtfText(tmpRange) }); dp = dr.End; } DocumentRange tmpRange2 = server.Document.CreateRange(dp, server.Document.Paragraphs[server.Document.Paragraphs.Count - 1].Range.End.ToInt() - dp.ToInt()); collection.Add(new MyRtfObject() { RtfSplitContent = server.Document.GetRtfText(tmpRange2) }); XtraReport1 report = new XtraReport1(); report.DataSource = collection; report.ShowPreviewDialog(); }
public ActionResult RichEditCustomPartial(int?position) { ViewData["RTF"] = rtf; if (position != null) { MemoryStream memoryStream = new MemoryStream(); RichEditExtension.SaveCopy("RichEdit", memoryStream, DocumentFormat.Rtf); memoryStream.Position = 0; var server = new RichEditDocumentServer(); server.LoadDocument(memoryStream, DocumentFormat.Rtf); var pos = server.Document.CreatePosition(position.Value); server.Document.InsertRtfText(pos, rtf); memoryStream = new MemoryStream(); server.SaveDocument(memoryStream, DocumentFormat.Rtf); var model = new RichEditData { DocumentId = Guid.NewGuid().ToString(), Document = memoryStream.ToArray(), DocumentFormat = DocumentFormat.Rtf }; return(PartialView("_RichEditPartial", model)); } return(PartialView("_RichEditPartial")); }
static void BeforeImport(RichEditDocumentServer server) { #region #HandleBeforeImportEvent server.LoadDocument("Documents\\TerribleRevengeKOI8R.txt"); server.BeforeImport += BeforeImportHelper.BeforeImport; #endregion #HandleBeforeImportEvent }
private void button1_Click(object sender, RoutedEventArgs e) { OpenFileDialog ofdlg = new OpenFileDialog(); ofdlg.Multiselect = false; ofdlg.Filter = "Word 97-2003 Files (*.doc)|*.doc"; if (ofdlg.ShowDialog() == true) { image1.Source = null; textBlock1.Text = string.Empty; #region #richserverload richServer = new RichEditDocumentServer(); richServer.CreateNewDocument(); try { richServer.LoadDocument(ofdlg.File.OpenRead(), DocumentFormat.Doc); imgs = richServer.Document.GetImages(richServer.Document.Range); if (imgs.Count > 0) { ShowCurrentImage(); } textBlock1.Text = richServer.Document.Text; } catch (Exception ex) { textBlock1.Text = "Exception occurs:\n" + ex.Message; } #endregion #richserverload button2.IsEnabled = true; this.SimpleAnimation.Completed += new EventHandler(SimpleAnimaton_Completed); this.SimpleAnimation.Begin(); } }
static void EditEndnote(RichEditDocumentServer wordProcessor) { #region #EditEndnote wordProcessor.LoadDocument("Documents//Grimm.docx"); Document document = wordProcessor.Document; //Access the first endnote's content: SubDocument endnote = document.Endnotes[0].BeginUpdate(); //Exclude the reference mark and the space after it from the range to be edited: DocumentRange noteTextRange = endnote.CreateRange(endnote.Range.Start.ToInt() + 2, endnote.Range.Length - 2); //Access the range's character properties: CharacterProperties characterProperties = endnote.BeginUpdateCharacters(noteTextRange); characterProperties.ForeColor = System.Drawing.Color.Red; characterProperties.Italic = true; //Finalize the character options update: endnote.EndUpdateCharacters(characterProperties); //Finalize the endnote update: document.Endnotes[0].EndUpdate(endnote); #endregion #EditEndnote }
void OpenDocumentAndShowReport() { OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"; openFileDialog1.FilterIndex = 2; openFileDialog1.RestoreDirectory = true; if (openFileDialog1.ShowDialog() == DialogResult.OK) { try { if (openFileDialog1.OpenFile() != null) { using (RichEditDocumentServer reds = new RichEditDocumentServer()) { reds.LoadDocument(openFileDialog1.FileName); using (XtraReport1 report = new XtraReport1()) { report.RichText.Rtf = reds.RtfText; report.ShowPreviewDialog(); } } } } catch (Exception ex) { MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message); } } }
public static Document MergeDouments(List <string> filenames) { RichEditDocumentServer targetServer = new RichEditDocumentServer(); RichEditDocumentServer sourceServer = new RichEditDocumentServer(); Document targetDoc = targetServer.Document; Document sourceDoc = sourceServer.Document; for (int i = 0; i < filenames.Count; i++) { sourceServer.LoadDocument(filenames[i]); targetDoc.Sections[targetDoc.Sections.Count - 1].UnlinkHeaderFromPrevious(); targetDoc.Sections[targetDoc.Sections.Count - 1].UnlinkFooterFromPrevious(); SectionsMerger.Append(sourceDoc, targetDoc); if (i == filenames.Count - 1) { return(targetDoc); } targetDoc.AppendSection(); } return(targetDoc); }
private void button1_Click(object sender, RoutedEventArgs e) { #region #xpfprinter RichEditDocumentServer srv = new RichEditDocumentServer(); srv.LoadDocument("test.docx"); FixedDocument document = RichEditDocumentXpfPrinter.CreateFixedDocument(srv); PrintDialog pDialog = new PrintDialog(); PrintQueueCollection queues = new PrintServer().GetPrintQueues(new[] { EnumeratedPrintQueueTypes.Local, EnumeratedPrintQueueTypes.Connections }); System.Collections.IEnumerator localPrinterEnumerator = queues.GetEnumerator(); PrintQueue printQueue = null; do { if (!localPrinterEnumerator.MoveNext()) { break; } printQueue = (PrintQueue)localPrinterEnumerator.Current; }while (!printQueue.FullName.Contains("Canon")); if (printQueue != null) { pDialog.PrintQueue = printQueue; pDialog.PrintDocument(document.DocumentPaginator, string.Empty); } #endregion #xpfprinter }
static void MergeDocuments(RichEditDocumentServer wordProcessor) { #region #MergeDocuments wordProcessor.LoadDocument("Documents//Grimm.docx", DocumentFormat.OpenXml); wordProcessor.Document.AppendDocumentContent("Documents//MovieRentals.docx", DocumentFormat.OpenXml); #endregion #MergeDocuments }
protected void Page_Load(object sender, EventArgs e) { if (!IsCallback && Request["Template"] != null && Request["ID"] != null) { var TemplateDoc = Request["Template"].ToString(); var ID = Request["ID"].ToString(); RichEditDocumentServer documentServer = new RichEditDocumentServer(); documentServer.LoadDocument(Path.Combine(DirectoryManagmentUtils.CurrentDataDirectory, TemplateDoc)); IEnumerable <CompanyVM> items = GetData(ID); string FileName = "RegisterForm_"; FileName += items.FirstOrDefault()?.Id; FileName += @".docx"; documentServer.Options.MailMerge.DataSource = items; using (MemoryStream stream = new MemoryStream()) { documentServer.MailMerge(stream, DocumentFormat.OpenXml); stream.Position = 0; DocumentManager.CloseDocument(documentId); SaveStreamToFile(stream, Path.Combine(DirectoryManagmentUtils.CurrentDataDirectory, FileName)); stream.Position = 0; SendFiletoClientBrowser(Path.Combine(DirectoryManagmentUtils.CurrentDataDirectory, FileName)); DemoRichEdit.Open(documentId, DocumentFormat.OpenXml, () => { return(stream); }); } } }
// Saving Invoice at DataBase public void InvoiceSave() { MemoryStream rtfStream = new MemoryStream(); MemoryStream pdfStream = new MemoryStream(); ASPxRichEdit1.SaveCopy(rtfStream, DocumentFormat.Rtf); ASPxRichEdit1.ExportToPdf(pdfStream); RichEditDocumentServer docServer = new RichEditDocumentServer(); docServer.LoadDocument(rtfStream, DocumentFormat.Rtf); using (SqlConnection con = new SqlConnection(conStr)) { using (SqlCommand cmd = new SqlCommand()) { cmd.CommandType = CommandType.Text; cmd.Connection = con; cmd.CommandText = @"update Invoices set InvoiceRtf = @InvoiceRtf, InvoicePdf = @InvoicePdf where OrderID = @OrderID"; cmd.Parameters.AddWithValue("@OrderID", HiddenInvoiceId.Value); cmd.Parameters.AddWithValue("@InvoiceRtf", SqlDbType.VarBinary).Value = rtfStream.ToArray(); cmd.Parameters.AddWithValue("@InvoicePdf", SqlDbType.VarBinary).Value = pdfStream.ToArray(); con.Open(); cmd.ExecuteNonQuery(); con.Close(); } } }
private static void ConvertFilesODTtoDOCX(DirectoryInfo directory) { RichEditDocumentServer server = new RichEditDocumentServer(); String newName = string.Empty; server.Options.Export.Html.EmbedImages = true; foreach (FileInfo file in directory.GetFiles()) { if (file.Extension.Equals(".odt") || file.Extension.Equals("odt")) { server.LoadDocument(@file.FullName, DocumentFormat.OpenDocument); //Console.WriteLine(file.FullName); newName = file.Name.Replace(file.Extension, ""); //Console.WriteLine(newName); server.SaveDocument(directory.FullName + Path.DirectorySeparatorChar + newName, DocumentFormat.OpenXml); try { file.Delete(); } catch (Exception) { //Do nothing } } } foreach (DirectoryInfo dir in directory.GetDirectories()) { if (!dir.Name.Equals("TEMPORALES") && !dir.Name.Equals("ERROR_LOGS")) { ConvertFilesODTtoDOCX(dir); } } }
static void Main(string[] args) { RichEditDocumentServer server = new RichEditDocumentServer(); server.EncryptedFilePasswordRequested += Server_EncryptedFilePasswordRequested; server.EncryptedFilePasswordCheckFailed += Server_EncryptedFilePasswordCheckFailed; server.DecryptionFailed += Server_DecryptionFailed; server.Options.Import.EncryptionPassword = "******"; server.LoadDocument("Documents//testEncrypted.docx"); EncryptionSettings encryptionOptions = new EncryptionSettings(); encryptionOptions.Type = EncryptionType.Strong; encryptionOptions.Password = "******"; Console.WriteLine("Select the file format: DOCX/DOC"); string answerFormat = Console.ReadLine()?.ToLower(); DocumentFormat documentFormat; if (answerFormat == "docx") { documentFormat = DocumentFormat.OpenXml; } else { documentFormat = DocumentFormat.Doc; } string fileName = String.Format("EncryptedwithNewPassword.{0}", answerFormat); server.SaveDocument(fileName, documentFormat, encryptionOptions); Console.WriteLine("The document is saved with new password. Continue? (y/n)"); string answer = Console.ReadLine()?.ToLower(); if (answer == "y") { Console.WriteLine("Re-opening the file..."); server.LoadDocument(fileName); } if (IsValid == true) { server.SaveDocument(fileName, documentFormat); Process.Start(fileName); } }
/// <summary> /// Von dem Doc-Dokument wird die erste Seite in tiff konvertiert und gespeichert. /// die funktion liefert den Path zu der neue Datei zurück. /// </summary> public string GetFirstPageAsImageFromDocument(DocumentParam param) { try { string fileName = string.Empty; FileInfo fileInfo = new FileInfo(param.FilePath); if (fileInfo.Exists == false) { return(fileName); } string pathFolder = Path.GetTempPath(); FilesFunctions.DeleteFilesInFolder(pathFolder, Tiff); string tempName = FilesFunctions.GetRandomName(pathFolder, fileInfo, true, Pdf); using (RichEditDocumentServer richServer = new RichEditDocumentServer()) { richServer.LoadDocument(param.FilePath); //Specify export options: PdfExportOptions options = new PdfExportOptions { Compressed = false, ImageQuality = PdfJpegImageQuality.Highest }; //Export the document to the stream: using (FileStream pdfFileStream = new FileStream(tempName, FileMode.Create)) { richServer.ExportToPdf(pdfFileStream, options); } } var pdf = new PdfTiffConverter(); var parammeter = new DocumentParam { Resolution = param.Resolution, Colour = param.Colour, Compression = param.Compression, Quality = param.Quality, KeepOriginal = param.KeepOriginal, ConTyp = param.ConTyp, Doctyp = param.Doctyp, FilePath = tempName }; fileName = pdf.GetFirstPageAsImageFromDocument(parammeter); return(fileName); } catch (Exception ex) { FileLogger.FileLogger.Instance.WriteExeption(ex); return(string.Empty); } }
private void GUI_Print_PrintAll_Load(object sender, EventArgs e) { RichEditDocumentServer f = new RichEditDocumentServer(); f.LoadDocument("C:\\Users\\Mint\\Desktop\\ChuongTrinhDaoTao_T.doc"); //printableComponentLink1.Component = f; //documentViewer1.DocumentSource = printingSystem1; }
private Stream ExecuteMerge(string templateName, DocumentFormat documentFormat) { Stream result = new MemoryStream(); MailMergeOptions mailMergeOptions = documentServer.CreateMailMergeOptions(); if (templateName == "preview1") { documentServer.LoadDocument(Page.MapPath("~/App_Data/InvoicesDetail.rtf")); List <Invoice> invoices = new List <Invoice>(10); invoices.Add(new Invoice(0, "Invoice1", 10.0m)); invoices.Add(new Invoice(1, "Invoice2", 15.0m)); invoices.Add(new Invoice(2, "Invoice3", 20.0m)); mailMergeOptions.DataSource = invoices; } else if (templateName == "preview2") { documentServer.LoadDocument(Page.MapPath("~/App_Data/SamplesDetail.rtf")); mailMergeOptions.DataSource = ManualDataSet.CreateData().Tables[0]; } else if (templateName == "all") { Stream part1 = ExecuteMerge("preview1", documentFormat); Stream part2 = ExecuteMerge("preview2", documentFormat); part1.Seek(0, SeekOrigin.Begin); part2.Seek(0, SeekOrigin.Begin); documentServer.LoadDocument(part1, documentFormat); documentServer.Document.AppendDocumentContent(part2, documentFormat); documentServer.SaveDocument(result, documentFormat); return(result); } documentServer.Options.MailMerge.ViewMergedData = true; documentServer.Options.Export.Html.EmbedImages = true; mailMergeOptions.MergeMode = MergeMode.JoinTables; documentServer.MailMerge(mailMergeOptions, result, documentFormat); return(result); }
static void ConvertHTMLtoDOCX(RichEditDocumentServer server) { #region #ConvertHTMLtoDOCX server.LoadDocument("Documents\\TextWithImages.htm"); server.SaveDocument("Document_DOCX.docx", DocumentFormat.OpenXml); System.Diagnostics.Process.Start("Document_DOCX.docx"); #endregion #ConvertHTMLtoDOCX }
static void ConvertHTMLtoPDF(RichEditDocumentServer wordProcessor) { #region #ConvertHTMLtoPDF wordProcessor.LoadDocument("Documents\\TextWithImages.htm"); wordProcessor.ExportToPdf("Document_PDF.pdf"); System.Diagnostics.Process.Start("Document_PDF.pdf"); #endregion #ConvertHTMLtoPDF }
public static Bitmap GenerateImageFromWord(string fileName) { using (RichEditDocumentServer wordDocumentAPI = new RichEditDocumentServer()) { wordDocumentAPI.LoadDocument(fileName); return(ExportToImage(wordDocumentAPI)); } }
public override DevExpress.XtraPrinting.IPrintable CreatePrintableComponent(Item fileItem) { RichEditDocumentServer docServer = new RichEditDocumentServer(); Stream contentStream = DocumentsApp.Data.ReadFileContent(fileItem); docServer.LoadDocument(contentStream, GetFormat(fileItem)); return(docServer); }
public string Parse() { using (var documentProcessor = new RichEditDocumentServer()) { documentProcessor.LoadDocument(file.FullName); return(documentProcessor.Text); } }
static void BeforeExport(RichEditDocumentServer server) { #region #HandleBeforeExportEvent server.LoadDocument("Documents\\Grimm.docx"); server.BeforeExport += BeforeExportHelper.BeforeExport; server.SaveDocument("Document_HTML.html", DocumentFormat.Html); System.Diagnostics.Process.Start("Document_HTML.html"); #endregion #HandleBeforeExportEvent }
void CreateComment(RichEditDocumentServer server) { #region #CreateComment Document document = server.Document; server.LoadDocument("Documents\\Grimm.docx", DocumentFormat.OpenXml); DocumentRange docRange = document.Paragraphs[2].Range; string commentAuthor = "Johnson Alphonso D"; document.Comments.Create(docRange, commentAuthor, DateTime.Now); #endregion #CreateComment }
private Stream ConvertToPdf(Stream stream, string fileName) { RichEditDocumentServer server = new RichEditDocumentServer(); server.LoadDocument(stream, FileExtensionHelper.GetDocumentFormat(fileName)); MemoryStream memoryStream = new MemoryStream(); server.ExportToPdf(memoryStream); return(memoryStream); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { RichEditDocumentServer server = new RichEditDocumentServer(); server.LoadDocument(Server.MapPath("~/SpellChecking.docx")); DocumentManager.CloseDocument(documentId); RichEdit.Open(documentId, DocumentFormat.OpenXml, () => server.OpenXmlBytes); } }
IBasePrintable CreatePrintableComponent(string extention, Stream contentStream) { IBasePrintable component; if (RICH_EDIT_TYPES.Contains(extention)) { RichEditDocumentServer docServer = new RichEditDocumentServer(); switch (extention) { case ".docx": docServer.LoadDocument(contentStream, DevExpress.XtraRichEdit.DocumentFormat.Doc); break; case ".doc": docServer.LoadDocument(contentStream, DevExpress.XtraRichEdit.DocumentFormat.Doc); break; case ".rtf": docServer.LoadDocument(contentStream, DevExpress.XtraRichEdit.DocumentFormat.Rtf); break; case ".html": docServer.LoadDocument(contentStream, DevExpress.XtraRichEdit.DocumentFormat.Html); break; } component = docServer; } else if (SPREAD_SHEET_TYPES.Contains(extention)) { IWorkbook workbook = new Workbook(); workbook.AddService(typeof(IChartControllerFactoryService), new ChartControllerFactoryService()); workbook.AddService(typeof(IChartImageService), new ChartImageService()); switch (extention) { case ".xls": workbook.LoadDocument(contentStream, DevExpress.Spreadsheet.DocumentFormat.Xls); break; case ".xlsx": workbook.LoadDocument(contentStream, DevExpress.Spreadsheet.DocumentFormat.Xlsx); break; case ".txt": workbook.LoadDocument(contentStream, DevExpress.Spreadsheet.DocumentFormat.Text); break; case ".csv": workbook.LoadDocument(contentStream, DevExpress.Spreadsheet.DocumentFormat.Csv); break; } component = workbook; } else { return(null); } return(component); }
static void PrintLayout(RichEditDocumentServer wordProcessor) { #region #PrintLayout wordProcessor.LoadDocument("Documents\\Grimm.docx", DocumentFormat.OpenXml); Document document = wordProcessor.Document; document.Unit = DevExpress.Office.DocumentUnit.Inch; document.Sections[0].Page.PaperKind = System.Drawing.Printing.PaperKind.A6; document.Sections[0].Page.Landscape = true; document.Sections[0].Margins.Left = 2.0f; #endregion #PrintLayout }
static void ConvertHTMLtoPDF(RichEditDocumentServer server) { #region #ConvertHTMLtoPDF server.LoadDocument("Documents\\TextWithImages.htm"); using (FileStream pdfFileStream = new FileStream("Document_PDF.pdf", FileMode.Create)) { server.ExportToPdf(pdfFileStream); } System.Diagnostics.Process.Start("Document_PDF.pdf"); #endregion #ConvertHTMLtoPDF }
Stream ConvertWordDocument(Stream inputStream) { using (RichEditDocumentServer server = new RichEditDocumentServer()) { server.LoadDocument(inputStream); MemoryStream resultStream = new MemoryStream(); server.Options.Export.Html.EmbedImages = true; server.SaveDocument(resultStream, DevExpress.XtraRichEdit.DocumentFormat.Html); resultStream.Seek(0, SeekOrigin.Begin); return(resultStream); } }