forked from pvginkel/PdfiumViewer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPrintMultiplePagesForm.cs
65 lines (57 loc) · 1.91 KB
/
PrintMultiplePagesForm.cs
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace PdfiumViewer.Demo
{
public partial class PrintMultiplePagesForm : Form
{
private readonly PdfViewer _viewer;
public PrintMultiplePagesForm(PdfViewer viewer)
{
if (viewer == null)
throw new ArgumentNullException(nameof(viewer));
_viewer = viewer;
InitializeComponent();
}
private void _acceptButton_Click(object sender, EventArgs e)
{
int horizontal;
int vertical;
float margin;
if (!int.TryParse(_horizontal.Text, out horizontal))
{
MessageBox.Show(this, "Invalid horizontal");
}
else if (!int.TryParse(_vertical.Text, out vertical))
{
MessageBox.Show(this, "Invalid vertical");
}
else if (!float.TryParse(_margin.Text, out margin))
{
MessageBox.Show(this, "Invalid margin");
}
else
{
var settings = new PdfPrintSettings(
_viewer.DefaultPrintMode,
new PdfPrintMultiplePages(
horizontal,
vertical,
_horizontalOrientation.Checked ? Orientation.Horizontal : Orientation.Vertical,
margin
)
);
using (var form = new PrintPreviewDialog())
{
form.Document = _viewer.Document.CreatePrintDocument(settings);
form.ShowDialog(this);
}
DialogResult = DialogResult.OK;
}
}
}
}