-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathForm1.cs
More file actions
73 lines (63 loc) · 2.69 KB
/
Form1.cs
File metadata and controls
73 lines (63 loc) · 2.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
#region #usings
using DevExpress.XtraRichEdit;
using DevExpress.XtraRichEdit.API.Native;
using DevExpress.XtraPrinting;
#endregion #usings
namespace RichEditDocumentServer_Printing
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btn_Print_Click(object sender, EventArgs e)
{
#region #serverprint
RichEditDocumentServer richServer = new RichEditDocumentServer();
// Specify default formatting
richServer.Document.DefaultParagraphProperties.Alignment = ParagraphAlignment.Center;
// Specify page settings
richServer.Document.Sections[0].Page.Landscape = true;
richServer.Document.Sections[0].Page.Height = DevExpress.Office.Utils.Units.InchesToDocumentsF(10.0f);
richServer.Document.Sections[0].Page.Width = DevExpress.Office.Utils.Units.InchesToDocumentsF(4.5f);
// Add document content
richServer.Document.AppendText("This content is created programmatically\n");
richServer.Document.Paragraphs.Append();
//Create a table
richServer.BeginUpdate();
Table _table = richServer.Document.Tables.Create(richServer.Document.Selection.Start, 8, 8, AutoFitBehaviorType.FixedColumnWidth);
_table.BeginUpdate();
_table.Borders.InsideHorizontalBorder.LineThickness = 1;
_table.Borders.InsideHorizontalBorder.LineStyle = BorderLineStyle.Double;
_table.Borders.InsideVerticalBorder.LineThickness = 1;
_table.Borders.InsideVerticalBorder.LineStyle = BorderLineStyle.Double;
_table.TableAlignment = TableRowAlignment.Center;
_table.ForEachCell((cell, rowIndex, columnIndex) =>
{
richServer.Document.InsertText(cell.Range.Start, String.Format("{0}*{1} is {2}",
rowIndex + 2, columnIndex + 2, (rowIndex + 2) * (columnIndex + 2)));
});
_table.EndUpdate();
richServer.EndUpdate();
// Invoke the Print Preview dialog
using (PrintingSystem printingSystem = new PrintingSystem())
{
using (PrintableComponentLink link = new PrintableComponentLink(printingSystem))
{
link.Component = richServer;
link.CreateDocument();
link.ShowPreviewDialog();
}
}
#endregion #serverprint
}
}
}