Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.
Tue Jun 03, 2014 11:04 am
How to print selected pages using spire.doc? I need to print all pages except the last two.
The following code shows the dialog that will be sent to print selected pages, but prints all ((
- Code: Select all
Document doc = new Document();
doc.LoadFromFile(fileName);
PrintDialog dialog = new PrintDialog();
dialog.AllowPrintToFile = true;
dialog.AllowCurrentPage = true;
dialog.AllowSomePages = true;
dialog.AllowSelection = true;
dialog.UseEXDialog = true;
doc.PrintDialog = dialog;
PrintDocument printDoc = doc.PrintDocument;
printDoc.PrinterSettings.Duplex = Duplex.Simplex;
printDoc.PrinterSettings.FromPage = 1;
printDoc.PrinterSettings.ToPage = doc.PageCount - 2;
printDoc.PrinterSettings.PrintRange = PrintRange.SomePages;
if (dialog.ShowDialog() == DialogResult.OK)
{
printDoc.Print();
}
-
nickzao
-
- Posts: 2
- Joined: Wed May 14, 2014 11:01 am
Wed Jun 04, 2014 3:23 am
Hello,
Thanks for your feedback. Please try the following codes.
- Code: Select all
Document doc = new Document();
doc.LoadFromFile(@"..\..\test.docx");
PrintDialog dialog = new PrintDialog();
dialog.AllowPrintToFile = true;
dialog.AllowCurrentPage = true;
dialog.AllowSomePages = true;
dialog.AllowSelection = true;
dialog.UseEXDialog = true;
doc.PrintDialog = dialog;
doc.PrintDocument.PrinterSettings.Duplex = Duplex.Simplex;
doc.PrintDocument.PrinterSettings.FromPage = 1;
doc.PrintDocument.PrinterSettings.ToPage = doc.PageCount - 2;
doc.PrintDocument.PrinterSettings.PrintRange = PrintRange.SomePages;
if (dialog.ShowDialog() == DialogResult.OK)
{
doc.PrintDocument.Print();
}
If there are any questions, welcome to get it back to us.
Thanks,
Gary
E-iceblue support team
-
Gary.zhang
-
- Posts: 1380
- Joined: Thu Apr 04, 2013 1:30 am
Wed Jun 04, 2014 8:06 am
It works, thanks!
-
nickzao
-
- Posts: 2
- Joined: Wed May 14, 2014 11:01 am
Wed Jun 04, 2014 8:31 am
Thanks for your quick reply. If you have any problems, please feel free to contact us.
Sincerely,
Gary
E-iceblue support team
-
Gary.zhang
-
- Posts: 1380
- Joined: Thu Apr 04, 2013 1:30 am