-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathForm1.vb
More file actions
55 lines (51 loc) · 2.59 KB
/
Form1.vb
File metadata and controls
55 lines (51 loc) · 2.59 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
Imports System
Imports System.ComponentModel
Imports System.Drawing
Imports System.Windows.Forms
#Region "#usings"
Imports DevExpress.XtraRichEdit
Imports DevExpress.XtraRichEdit.API.Native
Imports DevExpress.XtraPrinting
#End Region ' #usings
Namespace RichEditDocumentServer_Printing
Public Partial Class Form1
Inherits Form
Public Sub New()
InitializeComponent()
End Sub
Private Sub btn_Print_Click(ByVal sender As Object, ByVal e As EventArgs)
#Region "#serverprint"
Dim richServer As RichEditDocumentServer = 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" & Microsoft.VisualBasic.Constants.vbLf)
richServer.Document.Paragraphs.Append()
'Create a table
richServer.BeginUpdate()
Dim _table As 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(Sub(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 As PrintingSystem = New PrintingSystem()
Using link As PrintableComponentLink = New PrintableComponentLink(printingSystem)
link.Component = richServer
link.CreateDocument()
link.ShowPreviewDialog()
End Using
End Using
#End Region ' #serverprint
End Sub
End Class
End Namespace