|
@@ -16,6 +16,7 @@ using System.Collections.Generic;
|
|
|
using System.Drawing;
|
|
|
using System.Drawing.Imaging;
|
|
|
using System.Drawing.Printing;
|
|
|
+using System.IO;
|
|
|
using System.Linq;
|
|
|
using System.Printing;
|
|
|
using System.Reflection;
|
|
@@ -91,7 +92,9 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
|
|
|
/// </summary>
|
|
|
int PreviousPrintedPageCount = 0;
|
|
|
|
|
|
+
|
|
|
public int PrintIndex;
|
|
|
+
|
|
|
///<summary>
|
|
|
///打印纸dpi100, PDF dpi 72,需要缩放
|
|
|
/// </summary>
|
|
@@ -181,7 +184,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
|
|
|
{
|
|
|
this.printDocumentEvent = eventAggregator;
|
|
|
printDocumentEvent.GetEvent<SendPrintSettingsInfoEvent>().Subscribe(RecvPrintSettingsInfo, e => e.Unicode == Unicode);
|
|
|
- printDocumentEvent.GetEvent<SendPrintQueueEvent>().Subscribe(RecvPrintQueue, e => e.Unicode == Unicode);
|
|
|
+ printDocumentEvent.GetEvent<SendPrintQueueEvent>().Subscribe(RecvPrintQueue , e => e.Unicode == Unicode);
|
|
|
printDocumentEvent.GetEvent<SendLabelEvent>().Subscribe(RecvLabel, e => e.Unicode == Unicode);
|
|
|
TurnPageCommand = new DelegateCommand<object>(TurnPage);
|
|
|
JumpPageCommand = new DelegateCommand<object>(JumpPage);
|
|
@@ -220,7 +223,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
|
|
|
printDocument.PrinterSettings.PrinterName = printQueueWithUnicode.printQueue.Name;
|
|
|
|
|
|
//TODO 这里要改,暂时禁用了海报模式的横向打印
|
|
|
- if (PrintSettingsInfo.EnumPrintOrientation == EnumPrintOrientation.StatusPortrait || PrintSettingsInfo.PrintModInfo.EnumPrintMod == EnumPrintMod.StatusPoster)
|
|
|
+ if (PrintSettingsInfo.EnumPrintOrientation == EnumPrintOrientation.StatusPortrait)
|
|
|
{
|
|
|
printDocument.DefaultPageSettings.Landscape = false;
|
|
|
}
|
|
@@ -237,21 +240,20 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
|
|
|
{
|
|
|
printDocument.DefaultPageSettings.Color = false;
|
|
|
}
|
|
|
- IsManualDuplex = true;
|
|
|
if (PrintSettingsInfo.PrintModInfo.EnumDuplexPrintMod == EnumDuplexPrintMod.StatusFlipLongEdge || PrintSettingsInfo.PrintModInfo.EnumDuplexPrintMod == EnumDuplexPrintMod.StatusFlipShortEdge || PrintSettingsInfo.PrintModInfo.EnumPrintMod == EnumPrintMod.StatusBooklet)
|
|
|
{
|
|
|
- //无阶段,自动双面打印
|
|
|
+ ///无阶段,自动双面打印
|
|
|
+ ///已在起始时验证
|
|
|
if (printQueueWithUnicode.EnumBothSidesStage == EnumBothSidesStage.StatusNone)
|
|
|
{
|
|
|
-
|
|
|
- }
|
|
|
- if (printQueueWithUnicode.printQueue.GetPrintCapabilities().DuplexingCapability.Contains(Duplexing.TwoSidedLongEdge))
|
|
|
- {
|
|
|
- printDocument.PrinterSettings.Duplex = Duplex.Horizontal;
|
|
|
- }
|
|
|
- else if (printQueueWithUnicode.printQueue.GetPrintCapabilities().DuplexingCapability.Contains(Duplexing.TwoSidedShortEdge))
|
|
|
- {
|
|
|
- printDocument.PrinterSettings.Duplex = Duplex.Vertical;
|
|
|
+ if (PrintSettingsInfo.PrintModInfo.EnumDuplexPrintMod == EnumDuplexPrintMod.StatusFlipLongEdge)
|
|
|
+ {
|
|
|
+ printDocument.PrinterSettings.Duplex = Duplex.Horizontal;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ printDocument.PrinterSettings.Duplex = Duplex.Vertical;
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -309,10 +311,10 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
|
|
|
{
|
|
|
SizeInfo sizeInfo = (SizeInfo)PrintSettingsInfo.PrintModInfo;
|
|
|
CPDFPage cPDFPage = PDFViewer.Document.PageAtIndex(PrintSettingsInfo.PageRangeList[PrintIndex]);
|
|
|
- Rectangle realBound = new Rectangle(PrintSettingsInfo.PrintDocument.DefaultPageSettings.Margins.Left,
|
|
|
- PrintSettingsInfo.PrintDocument.DefaultPageSettings.Margins.Top,
|
|
|
- e.PageBounds.Width - PrintSettingsInfo.PrintDocument.DefaultPageSettings.Margins.Left - PrintSettingsInfo.PrintDocument.DefaultPageSettings.Margins.Right,
|
|
|
- e.PageBounds.Height - PrintSettingsInfo.PrintDocument.DefaultPageSettings.Margins.Top - PrintSettingsInfo.PrintDocument.DefaultPageSettings.Margins.Bottom);
|
|
|
+ Rectangle realBound = new Rectangle(documentSettingsInfo.margins.Left,
|
|
|
+ documentSettingsInfo.margins.Top,
|
|
|
+ e.PageBounds.Width - documentSettingsInfo.margins.Left - documentSettingsInfo.margins.Right,
|
|
|
+ e.PageBounds.Height - documentSettingsInfo.margins.Top - documentSettingsInfo.margins.Bottom);
|
|
|
System.Drawing.Point startPoint = new System.Drawing.Point(0, 0);
|
|
|
if (cPDFPage != null)
|
|
|
{
|
|
@@ -345,6 +347,10 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
|
|
|
startPoint.X = (blankPageBitmap.Width - resizedWidth) / 2;
|
|
|
startPoint.Y = (blankPageBitmap.Height - resizedHeight) / 2;
|
|
|
printBitmap = CombineBitmap(blankPageBitmap, bitmap, startPoint);
|
|
|
+ if (IsManualDuplex && PrintIndex % 2 == 1&&sizeInfo.EnumDuplexPrintMod == EnumDuplexPrintMod.StatusFlipShortEdge)
|
|
|
+ {
|
|
|
+ printBitmap.RotateFlip(RotateFlipType.Rotate180FlipNone);
|
|
|
+ }
|
|
|
e.Graphics.DrawImage(printBitmap, realBound);
|
|
|
}
|
|
|
else if (sizeInfo.EnumSizeType == EnumSizeType.StatusActural)
|
|
@@ -352,6 +358,10 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
|
|
|
startPoint.X = (blankPageBitmap.Width - bitmap.Width) / 2;
|
|
|
startPoint.Y = (blankPageBitmap.Height - bitmap.Height) / 2;
|
|
|
printBitmap = CombineBitmap(blankPageBitmap, bitmap, startPoint);
|
|
|
+ if (IsManualDuplex && PrintIndex % 2 == 1 && sizeInfo.EnumDuplexPrintMod == EnumDuplexPrintMod.StatusFlipShortEdge)
|
|
|
+ {
|
|
|
+ printBitmap.RotateFlip(RotateFlipType.Rotate180FlipNone);
|
|
|
+ }
|
|
|
e.Graphics.DrawImage(printBitmap, e.MarginBounds);
|
|
|
}
|
|
|
else if (sizeInfo.EnumSizeType == EnumSizeType.StatusCustomized)
|
|
@@ -360,14 +370,18 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
|
|
|
startPoint.X = (blankPageBitmap.Width - bitmap.Width) / 2;
|
|
|
startPoint.Y = (blankPageBitmap.Height - bitmap.Height) / 2;
|
|
|
printBitmap = CombineBitmap(blankPageBitmap, bitmap, startPoint);
|
|
|
+ if (IsManualDuplex && PrintIndex % 2 == 1 && sizeInfo.EnumDuplexPrintMod == EnumDuplexPrintMod.StatusFlipShortEdge)
|
|
|
+ {
|
|
|
+ printBitmap.RotateFlip(RotateFlipType.Rotate180FlipNone);
|
|
|
+ }
|
|
|
e.Graphics.DrawImage(printBitmap, realBound);
|
|
|
}
|
|
|
bitmap.Dispose();
|
|
|
printBitmap.Dispose();
|
|
|
}
|
|
|
|
|
|
- //手动双面打印
|
|
|
- if (IsManualDuplex)
|
|
|
+ //手动双面打印,且页码不为1
|
|
|
+ if (IsManualDuplex && PrintSettingsInfo.PageRangeList.Count != 1)
|
|
|
{
|
|
|
if (PrintIndex < PrintedPageCount - 2)
|
|
|
{
|
|
@@ -398,11 +412,21 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
|
|
|
{
|
|
|
PosterInfo posterInfo = (PosterInfo)PrintSettingsInfo.PrintModInfo;
|
|
|
|
|
|
- var pageBound = printDocument.DefaultPageSettings.Bounds;
|
|
|
+ var pageBound = documentSettingsInfo.DocumentBounds;
|
|
|
System.Drawing.Point startPoint = new System.Drawing.Point(0, 0);
|
|
|
-
|
|
|
- double effectiveHeight = (double)documentSettingsInfo.DocumentHeight;
|
|
|
- double effectiveWidth = (double)documentSettingsInfo.DocumentWidth;
|
|
|
+ double effectiveHeight = 0;
|
|
|
+ double effectiveWidth = 0;
|
|
|
+ //计算有效打印区域
|
|
|
+ if (PrintSettingsInfo.EnumPrintOrientation == EnumPrintOrientation.StatusPortrait)
|
|
|
+ {
|
|
|
+ effectiveHeight = documentSettingsInfo.DocumentHeight;
|
|
|
+ effectiveWidth = documentSettingsInfo.DocumentWidth;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ effectiveHeight = documentSettingsInfo.DocumentWidth;
|
|
|
+ effectiveWidth = documentSettingsInfo.DocumentHeight;
|
|
|
+ }
|
|
|
double PreviewHeight = 0;
|
|
|
double PreviewWidth = 0;
|
|
|
Bitmap bitmap = null;
|
|
@@ -510,30 +534,61 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
|
|
|
e.Graphics.DrawString(sign, new Font("Helvetica", 10.0f), System.Drawing.Brushes.Black, margin + 5, 0);
|
|
|
}
|
|
|
|
|
|
- if (posterInfo.HasCutMarks)
|
|
|
- {
|
|
|
- System.Drawing.Pen pen = new System.Drawing.Pen(System.Drawing.Color.Black, 2);
|
|
|
- //除了四角之外都要添加裁切标记
|
|
|
|
|
|
- if (!(HorizonPaperIndex == 0 && VerticalPaperIndex == 0))
|
|
|
- {
|
|
|
- e.Graphics.DrawRectangle(pen, new Rectangle(-margin, -margin, 2 * margin, 2 * margin));
|
|
|
- }
|
|
|
- if (!(HorizonPaperIndex == HorizonPaperCount - 1 && VerticalPaperIndex == 0))
|
|
|
- {
|
|
|
- e.Graphics.DrawRectangle(pen, new Rectangle(pageBound.Height - margin, -margin, margin * 2, margin * 2));
|
|
|
- }
|
|
|
- if (!(HorizonPaperIndex == 0 && VerticalPaperIndex == VerticalPaperCount - 1))
|
|
|
+ if (PrintSettingsInfo.EnumPrintOrientation == EnumPrintOrientation.StatusPortrait)
|
|
|
+ {
|
|
|
+ if (posterInfo.HasCutMarks)
|
|
|
{
|
|
|
- e.Graphics.DrawRectangle(pen, new Rectangle(-margin, (int)pageBound.Width - margin, margin * 2, margin * 2));
|
|
|
+ System.Drawing.Pen pen = new System.Drawing.Pen(System.Drawing.Color.Black, 2);
|
|
|
+ //除了四角之外都要添加裁切标记
|
|
|
+
|
|
|
+ if (!(HorizonPaperIndex == 0 && VerticalPaperIndex == 0))
|
|
|
+ {
|
|
|
+ e.Graphics.DrawRectangle(pen, new Rectangle(-margin, -margin, 2 * margin, 2 * margin));
|
|
|
+ }
|
|
|
+ if (!(HorizonPaperIndex == HorizonPaperCount - 1 && VerticalPaperIndex == 0))
|
|
|
+ {
|
|
|
+ e.Graphics.DrawRectangle(pen, new Rectangle(pageBound.Height - margin, -margin, margin * 2, margin * 2));
|
|
|
+ }
|
|
|
+ if (!(HorizonPaperIndex == 0 && VerticalPaperIndex == VerticalPaperCount - 1))
|
|
|
+ {
|
|
|
+ e.Graphics.DrawRectangle(pen, new Rectangle(-margin, (int)pageBound.Width - margin, margin * 2, margin * 2));
|
|
|
+ }
|
|
|
+ if (!(HorizonPaperIndex == HorizonPaperCount - 1 && VerticalPaperIndex == VerticalPaperCount - 1))
|
|
|
+ {
|
|
|
+ e.Graphics.DrawRectangle(pen, new Rectangle(pageBound.Height - margin, (int)pageBound.Width - margin, margin * 2, margin * 2));
|
|
|
+ }
|
|
|
}
|
|
|
- if (!(HorizonPaperIndex == HorizonPaperCount - 1 && VerticalPaperIndex == VerticalPaperCount - 1))
|
|
|
+ e.Graphics.DrawImage(currentPrintbitmap, new Rectangle(margin, margin, (int)pageBound.Height - margin * 2, (int)pageBound.Width - margin * 2));
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (posterInfo.HasCutMarks)
|
|
|
{
|
|
|
- e.Graphics.DrawRectangle(pen, new Rectangle(pageBound.Height - margin, (int)pageBound.Width - margin, margin * 2, margin * 2));
|
|
|
+ System.Drawing.Pen pen = new System.Drawing.Pen(System.Drawing.Color.Black, 2);
|
|
|
+ //除了四角之外都要添加裁切标记
|
|
|
+
|
|
|
+ if (!(HorizonPaperIndex == 0 && VerticalPaperIndex == 0))
|
|
|
+ {
|
|
|
+ e.Graphics.DrawRectangle(pen, new Rectangle(-margin, -margin, 2 * margin, 2 * margin));
|
|
|
+ }
|
|
|
+ if (!(HorizonPaperIndex == HorizonPaperCount - 1 && VerticalPaperIndex == 0))
|
|
|
+ {
|
|
|
+ e.Graphics.DrawRectangle(pen, new Rectangle(pageBound.Width - margin, -margin, margin * 2, margin * 2));
|
|
|
+ }
|
|
|
+ if (!(HorizonPaperIndex == 0 && VerticalPaperIndex == VerticalPaperCount - 1))
|
|
|
+ {
|
|
|
+ e.Graphics.DrawRectangle(pen, new Rectangle(-margin, (int)pageBound.Height - margin, margin * 2, margin * 2));
|
|
|
+ }
|
|
|
+ if (!(HorizonPaperIndex == HorizonPaperCount - 1 && VerticalPaperIndex == VerticalPaperCount - 1))
|
|
|
+ {
|
|
|
+ e.Graphics.DrawRectangle(pen, new Rectangle(pageBound.Width - margin, (int)pageBound.Height - margin, margin * 2, margin * 2));
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
+ e.Graphics.DrawImage(currentPrintbitmap, new Rectangle(margin, margin, (int)pageBound.Width - margin * 2, (int)pageBound.Height - margin * 2));
|
|
|
|
|
|
- e.Graphics.DrawImage(currentPrintbitmap, new Rectangle(margin, margin, (int)pageBound.Height - margin * 2, (int)pageBound.Width - margin * 2));
|
|
|
+ }
|
|
|
|
|
|
if (HorizonPaperIndex < HorizonPaperCount - 1)
|
|
|
{
|
|
@@ -733,10 +788,10 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
|
|
|
int singlePageWidth;
|
|
|
Bitmap printBitmap;
|
|
|
int currentPage = 0;
|
|
|
- Rectangle realBound = new Rectangle(PrintSettingsInfo.PrintDocument.DefaultPageSettings.Margins.Left,
|
|
|
- PrintSettingsInfo.PrintDocument.DefaultPageSettings.Margins.Top,
|
|
|
- e.PageBounds.Width - PrintSettingsInfo.PrintDocument.DefaultPageSettings.Margins.Left - PrintSettingsInfo.PrintDocument.DefaultPageSettings.Margins.Right,
|
|
|
- e.PageBounds.Height - PrintSettingsInfo.PrintDocument.DefaultPageSettings.Margins.Top - PrintSettingsInfo.PrintDocument.DefaultPageSettings.Margins.Bottom);
|
|
|
+ Rectangle realBound = new Rectangle(documentSettingsInfo.margins.Left,
|
|
|
+ documentSettingsInfo.margins.Top,
|
|
|
+ e.PageBounds.Width - documentSettingsInfo.margins.Left - documentSettingsInfo.margins.Right,
|
|
|
+ e.PageBounds.Height - documentSettingsInfo.margins.Top - documentSettingsInfo.margins.Bottom);
|
|
|
|
|
|
if (PrintSettingsInfo.EnumPrintOrientation == EnumPrintOrientation.StatusPortrait)
|
|
|
{
|
|
@@ -935,6 +990,10 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ if (IsManualDuplex && PrintIndex % 2 == 1 && multipleInfo.EnumDuplexPrintMod == EnumDuplexPrintMod.StatusFlipShortEdge)
|
|
|
+ {
|
|
|
+ printBitmap.RotateFlip(RotateFlipType.Rotate180FlipNone);
|
|
|
+ }
|
|
|
e.Graphics.DrawImage(printBitmap, realBound);
|
|
|
if (IsManualDuplex)
|
|
|
{
|
|
@@ -970,10 +1029,10 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
|
|
|
Bitmap printBitmap;
|
|
|
double singlePageHeight = 0;
|
|
|
double singlePageWidth = 0;
|
|
|
- Rectangle realBound = new Rectangle(PrintSettingsInfo.PrintDocument.DefaultPageSettings.Margins.Left,
|
|
|
- PrintSettingsInfo.PrintDocument.DefaultPageSettings.Margins.Top,
|
|
|
- e.PageBounds.Width - PrintSettingsInfo.PrintDocument.DefaultPageSettings.Margins.Left - PrintSettingsInfo.PrintDocument.DefaultPageSettings.Margins.Right,
|
|
|
- e.PageBounds.Height - PrintSettingsInfo.PrintDocument.DefaultPageSettings.Margins.Top - PrintSettingsInfo.PrintDocument.DefaultPageSettings.Margins.Bottom);
|
|
|
+ Rectangle realBound = new Rectangle(documentSettingsInfo.margins.Left,
|
|
|
+ documentSettingsInfo.margins.Top,
|
|
|
+ e.PageBounds.Width - documentSettingsInfo.margins.Left - documentSettingsInfo.margins.Right,
|
|
|
+ e.PageBounds.Height - documentSettingsInfo.margins.Top - documentSettingsInfo.margins.Bottom);
|
|
|
|
|
|
if (PrintSettingsInfo.EnumPrintOrientation == EnumPrintOrientation.StatusPortrait)
|
|
|
{
|
|
@@ -1002,24 +1061,23 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
|
|
|
///左装订与右装订顺序相反
|
|
|
///左装订:
|
|
|
/// </summary>
|
|
|
-
|
|
|
if (bookletInfo.EnumBookletBinding == EnumBookletBinding.StatusLeft)
|
|
|
{
|
|
|
///奇数页:
|
|
|
///右面为页面序号
|
|
|
///左面为[(总打印纸数*4)+1-打印页右侧页序号]
|
|
|
- if ((PrintIndex + 1) % 2 == 1)
|
|
|
+ if ((TargetPaperList[PrintIndex + 1] + 1) % 2 == 1)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- leftPageIndex = PrintSettingsInfo.PageRangeList[maxPaperNumber * 4 - PrintIndex - 1];
|
|
|
+ leftPageIndex = PrintSettingsInfo.PageRangeList[maxPaperNumber * 4 - TargetPaperList[PrintIndex + 1 ] - 1];
|
|
|
leftPage = PDFViewer.Document.PageAtIndex(leftPageIndex);
|
|
|
}
|
|
|
catch
|
|
|
{
|
|
|
leftPage = null;
|
|
|
}
|
|
|
- rightPageIndex = PrintSettingsInfo.PageRangeList[PrintIndex];
|
|
|
+ rightPageIndex = PrintSettingsInfo.PageRangeList[TargetPaperList[PrintIndex + 1]];
|
|
|
//左面
|
|
|
if (leftPage != null)
|
|
|
{
|
|
@@ -1110,7 +1168,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
|
|
|
/// 右面为[(总打印纸数*4)+1-打印页右侧页序号]
|
|
|
else
|
|
|
{
|
|
|
- leftPageIndex = PrintSettingsInfo.PageRangeList[PrintIndex];
|
|
|
+ leftPageIndex = PrintSettingsInfo.PageRangeList[TargetPaperList[PrintIndex + 1]];
|
|
|
//左面
|
|
|
leftPage = PDFViewer.Document.PageAtIndex(leftPageIndex);
|
|
|
if (leftPage != null)
|
|
@@ -1156,7 +1214,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
|
|
|
//右面
|
|
|
try
|
|
|
{
|
|
|
- rightPageIndex = PrintSettingsInfo.PageRangeList[maxPaperNumber * 4 - 1 - PrintIndex];
|
|
|
+ rightPageIndex = PrintSettingsInfo.PageRangeList[maxPaperNumber * 4 - 1 - TargetPaperList[PrintIndex + 1]];
|
|
|
rightPage = PDFViewer.Document.PageAtIndex(rightPageIndex);
|
|
|
}
|
|
|
catch
|
|
@@ -1214,18 +1272,18 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
|
|
|
///奇数页:
|
|
|
///右面为页面序号
|
|
|
///左面为[(总打印纸数*4)+1-打印页右侧页序号]
|
|
|
- if ((PrintIndex + 1) % 2 == 0)
|
|
|
+ if ((TargetPaperList[PrintIndex+1] + 1) % 2 == 0)
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- leftPageIndex = PrintSettingsInfo.PageRangeList[maxPaperNumber * 4 - PrintIndex - 1];
|
|
|
+ leftPageIndex = PrintSettingsInfo.PageRangeList[maxPaperNumber * 4 - TargetPaperList[PrintIndex+1] - 1];
|
|
|
leftPage = PDFViewer.Document.PageAtIndex(leftPageIndex);
|
|
|
}
|
|
|
catch
|
|
|
{
|
|
|
leftPage = null;
|
|
|
}
|
|
|
- rightPageIndex = PrintSettingsInfo.PageRangeList[PrintIndex];
|
|
|
+ rightPageIndex = PrintSettingsInfo.PageRangeList[TargetPaperList[PrintIndex + 1]];
|
|
|
//左面
|
|
|
if (leftPage != null)
|
|
|
{
|
|
@@ -1318,7 +1376,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
|
|
|
/// 右面为[(总打印纸数*4)+1-打印页右侧页序号]
|
|
|
else
|
|
|
{
|
|
|
- leftPageIndex = PrintSettingsInfo.PageRangeList[PrintIndex];
|
|
|
+ leftPageIndex = PrintSettingsInfo.PageRangeList[TargetPaperList[PrintIndex + 1]];
|
|
|
//左面
|
|
|
leftPage = PDFViewer.Document.PageAtIndex(leftPageIndex);
|
|
|
if (leftPage != null)
|
|
@@ -1372,7 +1430,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
|
|
|
//右面
|
|
|
try
|
|
|
{
|
|
|
- rightPageIndex = PrintSettingsInfo.PageRangeList[maxPaperNumber * 4 - 1 - PrintIndex];
|
|
|
+ rightPageIndex = PrintSettingsInfo.PageRangeList[maxPaperNumber * 4 - 1 - TargetPaperList[PrintIndex + 1]];
|
|
|
rightPage = PDFViewer.Document.PageAtIndex(rightPageIndex);
|
|
|
}
|
|
|
catch
|
|
@@ -1422,6 +1480,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ e.Graphics.DrawImage(printBitmap, realBound);
|
|
|
if (IsManualDuplex)
|
|
|
{
|
|
|
if (PrintIndex < PrintedPageCount - 2)
|
|
@@ -1509,8 +1568,10 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
|
|
|
{
|
|
|
if (PDFViewer != null && printSettingsInfoWIthUnicode.printSettingsInfo != null)
|
|
|
{
|
|
|
- documentSettingsInfo.DocumentWidth = printSettingsInfoWIthUnicode.printSettingsInfo.PrintDocument.DefaultPageSettings.PaperSize.Width;
|
|
|
- documentSettingsInfo.DocumentHeight = printSettingsInfoWIthUnicode.printSettingsInfo.PrintDocument.DefaultPageSettings.PaperSize.Height;
|
|
|
+ documentSettingsInfo.DocumentWidth = PrintSettingsInfo.PrintDocument.DefaultPageSettings.PaperSize.Width;
|
|
|
+ documentSettingsInfo.DocumentHeight = PrintSettingsInfo.PrintDocument.DefaultPageSettings.PaperSize.Height;
|
|
|
+ documentSettingsInfo.margins = PrintSettingsInfo.PrintDocument.DefaultPageSettings.Margins;
|
|
|
+ documentSettingsInfo.DocumentBounds = PrintSettingsInfo.PrintDocument.DefaultPageSettings.Bounds;
|
|
|
CaculatePrintedPageCount();
|
|
|
SetPaperCollection();
|
|
|
if (PrintedPageCount != PreviousPrintedPageCount)
|
|
@@ -1598,9 +1659,6 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
|
|
|
}
|
|
|
SetViewBox(double.Parse(PaperHeight), double.Parse(PaperWidth));
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- }
|
|
|
CreateBlankBitmap();
|
|
|
}
|
|
|
|
|
@@ -1731,7 +1789,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
|
|
|
/// <param name="foreground"></param>
|
|
|
/// <param name="point"></param>
|
|
|
/// <returns></returns>
|
|
|
- public Bitmap CombineBitmap(Bitmap background, Bitmap foreground, System.Drawing.Point point)
|
|
|
+ public Bitmap CombineBitmap(Bitmap background, Bitmap foreground, System.Drawing.Point point)
|
|
|
{
|
|
|
if (background == null)
|
|
|
{
|
|
@@ -1823,10 +1881,20 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
|
|
|
double PreviewWidth = 0;
|
|
|
System.Drawing.Point startPoint = new System.Drawing.Point(0, 0);
|
|
|
Bitmap displayBitmap = null;
|
|
|
-
|
|
|
+ double effectiveHeight;
|
|
|
+ double effectiveWidth;
|
|
|
//计算有效打印区域
|
|
|
- double effectiveHeight = documentSettingsInfo.DocumentHeight;
|
|
|
- double effectiveWidth = documentSettingsInfo.DocumentWidth;
|
|
|
+ if (PrintSettingsInfo.EnumPrintOrientation == EnumPrintOrientation.StatusPortrait)
|
|
|
+ {
|
|
|
+ effectiveHeight = documentSettingsInfo.DocumentHeight;
|
|
|
+ effectiveWidth = documentSettingsInfo.DocumentWidth;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ effectiveHeight = documentSettingsInfo.DocumentWidth;
|
|
|
+ effectiveWidth = documentSettingsInfo.DocumentHeight;
|
|
|
+ }
|
|
|
+
|
|
|
//重叠
|
|
|
effectiveHeight = effectiveHeight - 2 * posterInfo.OverLap * 100 / 25.4;
|
|
|
effectiveWidth = effectiveWidth - 2 * posterInfo.OverLap * 100 / 25.4;
|
|
@@ -1846,7 +1914,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
|
|
|
if (posterInfo.EnumPosterMod == EnumPosterMod.StatusTile)
|
|
|
{
|
|
|
Bitmap bitmap;
|
|
|
- //TODO 放大倍数过高引起int超限
|
|
|
+ //TODO 放大倍数过高引起超限
|
|
|
try
|
|
|
{
|
|
|
bitmap = await ToolMethod.RenderPageBitmap(PDFViewer.Document, (int)(cPDFPage.PageSize.Width * dpiRatio * (posterInfo.TileRatio / 100.0)), (int)(cPDFPage.PageSize.Height * dpiRatio * (posterInfo.TileRatio / 100.0)), PrintSettingsInfo.PageRangeList[paperIndex], PrintSettingsInfo.IsPrintWithAnnot, PrintSettingsInfo.IsPrintWithForm);
|
|
@@ -2718,10 +2786,10 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
|
|
|
navigationContext.Parameters.TryGetValue<string>("Unicode", out Unicode);
|
|
|
if (PDFViewer != null && PrintSettingsInfo != null)
|
|
|
{
|
|
|
- documentSettingsInfo.DocumentWidth = PrintSettingsInfo.PrintDocument.DefaultPageSettings.PaperSize.Width;
|
|
|
- documentSettingsInfo.DocumentHeight = PrintSettingsInfo.PrintDocument.DefaultPageSettings.PaperSize.Width;
|
|
|
- documentSettingsInfo.margins = PrintSettingsInfo.PrintDocument.DefaultPageSettings.Margins;
|
|
|
- documentSettingsInfo.DocumentBounds = PrintSettingsInfo.PrintDocument.DefaultPageSettings.Bounds;
|
|
|
+ documentSettingsInfo.DocumentWidth = 827;
|
|
|
+ documentSettingsInfo.DocumentHeight = 1169;
|
|
|
+ documentSettingsInfo.margins = new Margins(0,0,0,0);
|
|
|
+ documentSettingsInfo.DocumentBounds = new Rectangle(0,0,827,1169);
|
|
|
SetPreviewExceptPoster();
|
|
|
CaculatePrintedPageCount();
|
|
|
SetPaperCollection();
|