|
@@ -337,6 +337,10 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
|
|
|
{
|
|
|
MessageBoxEx.Show("另一个进程正在占用该打印机或发生未知错误");
|
|
|
}
|
|
|
+ finally
|
|
|
+ {
|
|
|
+ printDocument.Dispose();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -478,6 +482,10 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
|
|
|
else
|
|
|
{
|
|
|
e.HasMorePages = false;
|
|
|
+ if (PrintIndex%2 == 0)
|
|
|
+ {
|
|
|
+ this.printDocumentEvent.GetEvent<SendFinishedFrontSideEvent>().Publish(new FinishedFrontSide { Unicode = this.Unicode });
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
//单面打印
|
|
@@ -576,10 +584,11 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
|
|
|
CPDFPage cPDFPage = PDFViewer.Document.PageAtIndex(PrintSettingsInfo.PageRangeList[posterPrintPaperIndex]);
|
|
|
if (cPDFPage != null)
|
|
|
{
|
|
|
+
|
|
|
+
|
|
|
///仅当每一页第一张纸打印时,进行一次渲染,,更换打印底图
|
|
|
if (HorizonPaperIndex == 0 && VerticalPaperIndex == 0)
|
|
|
{
|
|
|
- {
|
|
|
PosterCurrentBitmap = ToolMethod.RenderPageBitmapNoWait(PDFViewer.Document, (int)(cPDFPage.PageSize.Width * PDFToMediaDpiRatio * (posterInfo.TileRatio / 100.0) * widthDpiRatio), (int)(cPDFPage.PageSize.Height * PDFToMediaDpiRatio * (posterInfo.TileRatio / 100.0) * heightDpiRatio), PrintSettingsInfo.PageRangeList[posterPrintPaperIndex], PrintSettingsInfo.IsPrintWithAnnot, PrintSettingsInfo.IsPrintWithForm);
|
|
|
if (PrintSettingsInfo.IsGrayscale)
|
|
|
{
|
|
@@ -604,147 +613,142 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
|
|
|
startPoint.X = (int)((PreviewWidth - PosterCurrentBitmap.Width) / 2);
|
|
|
startPoint.Y = (int)((PreviewHeight - PosterCurrentBitmap.Height) / 2);
|
|
|
DisplayBitmap = CombineBitmap(DisplayBitmap, PosterCurrentBitmap, startPoint);
|
|
|
- }
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- /////当前页未打印完
|
|
|
- if (HorizonPaperIndex * VerticalPaperIndex < WholeCountSinglePage - 1)
|
|
|
+ if (WholeCountSinglePage > 1)
|
|
|
{
|
|
|
- ///取有效尺寸和重叠,边沿合并
|
|
|
- ///有效尺寸+重叠边
|
|
|
- Rectangle rectangle = new Rectangle((int)(HorizonPaperIndex * effectiveWidth), (int)(VerticalPaperIndex * effectiveHeight), (int)effectiveWidth, (int)effectiveHeight);
|
|
|
- ///左重叠
|
|
|
- if (HorizonPaperIndex != 0)
|
|
|
- {
|
|
|
- rectangle.Location = new System.Drawing.Point((int)(rectangle.Location.X - posterInfo.OverLap * mmToDpiRatio * widthDpiRatio), rectangle.Location.Y);
|
|
|
- }
|
|
|
-
|
|
|
- ///上重叠
|
|
|
- if (VerticalPaperIndex != 0)
|
|
|
- {
|
|
|
- rectangle.Size = new System.Drawing.Size(rectangle.Size.Width, (int)(rectangle.Size.Height + posterInfo.OverLap * mmToDpiRatio * heightDpiRatio));
|
|
|
- }
|
|
|
-
|
|
|
- ///右重叠
|
|
|
- if (HorizonPaperIndex != HorizonPaperCount)
|
|
|
- {
|
|
|
- rectangle.Size = new System.Drawing.Size((int)(rectangle.Size.Width + posterInfo.OverLap * mmToDpiRatio * widthDpiRatio), rectangle.Size.Height);
|
|
|
- }
|
|
|
-
|
|
|
- ///下重叠
|
|
|
- if (VerticalPaperIndex != VerticalPaperCount)
|
|
|
- {
|
|
|
- rectangle.Location = new System.Drawing.Point(rectangle.Location.X, (int)(rectangle.Location.Y - posterInfo.OverLap * mmToDpiRatio * heightDpiRatio));
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- ///当存在边沿时
|
|
|
- int margin = 0;
|
|
|
-
|
|
|
- ///Label和CutMarks
|
|
|
- ///
|
|
|
- if (posterInfo.HasLabel || posterInfo.HasCutMarks)
|
|
|
- {
|
|
|
- margin = 20;
|
|
|
- }
|
|
|
-
|
|
|
- if (posterInfo.HasLabel)
|
|
|
+ /////当前页未打印完
|
|
|
+ if (HorizonPaperIndex * VerticalPaperIndex < WholeCountSinglePage - 1)
|
|
|
{
|
|
|
- string sign = null;
|
|
|
- if (posterInfo.Label == null || posterInfo.Label == "")
|
|
|
+ ///取有效尺寸和重叠,边沿合并
|
|
|
+ ///有效尺寸+重叠边
|
|
|
+ Rectangle rectangle = new Rectangle((int)(HorizonPaperIndex * effectiveWidth), (int)(VerticalPaperIndex * effectiveHeight), (int)effectiveWidth, (int)effectiveHeight);
|
|
|
+ ///左重叠
|
|
|
+ if (HorizonPaperIndex != 0)
|
|
|
{
|
|
|
- sign = string.Format("({0},{1}) -{2} -{3}.pdf {4} {5}", HorizonPaperIndex + 1, VerticalPaperIndex + 1, PrintIndex + 1, PDFViewer.Document.FileName, System.DateTime.Today.ToString("yyyy/MM/dd"), System.DateTime.Now.ToString("HH:mm:ss"));
|
|
|
+ rectangle.Location = new System.Drawing.Point((int)(rectangle.Location.X - posterInfo.OverLap * mmToDpiRatio * widthDpiRatio), rectangle.Location.Y);
|
|
|
}
|
|
|
- else
|
|
|
+
|
|
|
+ ///上重叠
|
|
|
+ if (VerticalPaperIndex != 0)
|
|
|
{
|
|
|
- sign = posterInfo.Label;
|
|
|
+ rectangle.Size = new System.Drawing.Size(rectangle.Size.Width, (int)(rectangle.Size.Height + posterInfo.OverLap * mmToDpiRatio * heightDpiRatio));
|
|
|
}
|
|
|
- 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 != HorizonPaperCount)
|
|
|
+ {
|
|
|
+ rectangle.Size = new System.Drawing.Size((int)(rectangle.Size.Width + posterInfo.OverLap * mmToDpiRatio * widthDpiRatio), rectangle.Size.Height);
|
|
|
+ }
|
|
|
|
|
|
- if (!(HorizonPaperIndex == 0 && VerticalPaperIndex == 0))
|
|
|
+ ///下重叠
|
|
|
+ if (VerticalPaperIndex != VerticalPaperCount)
|
|
|
{
|
|
|
- e.Graphics.DrawRectangle(pen, new Rectangle(-margin, -margin, 2 * margin, 2 * margin));
|
|
|
+ rectangle.Location = new System.Drawing.Point(rectangle.Location.X, (int)(rectangle.Location.Y - posterInfo.OverLap * mmToDpiRatio * heightDpiRatio));
|
|
|
}
|
|
|
- if (!(HorizonPaperIndex == HorizonPaperCount - 1 && VerticalPaperIndex == 0))
|
|
|
+
|
|
|
+
|
|
|
+ ///当存在边沿时
|
|
|
+ int margin = 0;
|
|
|
+
|
|
|
+ ///Label和CutMarks
|
|
|
+ ///
|
|
|
+ if (posterInfo.HasLabel || posterInfo.HasCutMarks)
|
|
|
{
|
|
|
- e.Graphics.DrawRectangle(pen, new Rectangle(pageBound.Width - margin, -margin, margin * 2, margin * 2));
|
|
|
+ margin = 20;
|
|
|
}
|
|
|
- if (!(HorizonPaperIndex == 0 && VerticalPaperIndex == VerticalPaperCount - 1))
|
|
|
+
|
|
|
+ if (posterInfo.HasLabel)
|
|
|
{
|
|
|
- e.Graphics.DrawRectangle(pen, new Rectangle(-margin, pageBound.Height - margin, margin * 2, margin * 2));
|
|
|
+ string sign = null;
|
|
|
+ if (posterInfo.Label == null || posterInfo.Label == "")
|
|
|
+ {
|
|
|
+ sign = string.Format("({0},{1}) -{2} -{3}.pdf {4} {5}", HorizonPaperIndex + 1, VerticalPaperIndex + 1, PrintIndex + 1, PDFViewer.Document.FileName, System.DateTime.Today.ToString("yyyy/MM/dd"), System.DateTime.Now.ToString("HH:mm:ss"));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ sign = posterInfo.Label;
|
|
|
+ }
|
|
|
+ e.Graphics.DrawString(sign, new Font("Helvetica", 10.0f), System.Drawing.Brushes.Black, margin + 5, 0);
|
|
|
}
|
|
|
- if (!(HorizonPaperIndex == HorizonPaperCount - 1 && VerticalPaperIndex == VerticalPaperCount - 1))
|
|
|
+
|
|
|
+ if (posterInfo.HasCutMarks)
|
|
|
{
|
|
|
- e.Graphics.DrawRectangle(pen, new Rectangle(pageBound.Width - margin, (int)pageBound.Height - 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, 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));
|
|
|
+ }
|
|
|
+ pen.Dispose();
|
|
|
}
|
|
|
- pen.Dispose();
|
|
|
+ Bitmap currentPrintBitmap = Crop(DisplayBitmap, rectangle);
|
|
|
+ e.Graphics.DrawImage(currentPrintBitmap, new Rectangle(margin, margin, pageBound.Width - 2 * margin, pageBound.Height - 2 * margin), new Rectangle(0, 0, currentPrintBitmap.Width, currentPrintBitmap.Height), GraphicsUnit.Pixel);
|
|
|
+ currentPrintBitmap.Dispose();
|
|
|
}
|
|
|
- Bitmap currentPrintBitmap = Crop(DisplayBitmap, rectangle);
|
|
|
- e.Graphics.DrawImage(currentPrintBitmap, new Rectangle(margin, margin, pageBound.Width - 2 * margin, pageBound.Height - 2 * margin), new Rectangle(0, 0, currentPrintBitmap.Width, currentPrintBitmap.Height), GraphicsUnit.Pixel);
|
|
|
- currentPrintBitmap.Dispose();
|
|
|
- }
|
|
|
- ///三种进位:当前列,当前行,当前页
|
|
|
- if (HorizonPaperIndex < HorizonPaperCount - 1)
|
|
|
- {
|
|
|
- HorizonPaperIndex++;
|
|
|
- e.HasMorePages = true;
|
|
|
- }
|
|
|
- else if (VerticalPaperIndex < VerticalPaperCount - 1)
|
|
|
- {
|
|
|
- HorizonPaperIndex = 0;
|
|
|
- VerticalPaperIndex++;
|
|
|
- e.HasMorePages = true;
|
|
|
- }
|
|
|
- else if (posterPrintPaperIndex < PrintedPageCount - 1)
|
|
|
- {
|
|
|
- ///当前总文件未打印完
|
|
|
- posterPrintPaperIndex++;
|
|
|
- PosterCurrentBitmap.Dispose();
|
|
|
- DisplayBitmap.Dispose();
|
|
|
- GC.Collect();
|
|
|
- GC.WaitForPendingFinalizers();
|
|
|
- HorizonPaperIndex = 0;
|
|
|
- VerticalPaperIndex = 0;
|
|
|
- e.HasMorePages = true;
|
|
|
- }
|
|
|
+ ///三种进位:当前列,当前行,当前页
|
|
|
+ if (HorizonPaperIndex < HorizonPaperCount - 1)
|
|
|
+ {
|
|
|
+ HorizonPaperIndex++;
|
|
|
+ e.HasMorePages = true;
|
|
|
+ }
|
|
|
+ else if (VerticalPaperIndex < VerticalPaperCount - 1)
|
|
|
+ {
|
|
|
+ HorizonPaperIndex = 0;
|
|
|
+ VerticalPaperIndex++;
|
|
|
+ e.HasMorePages = true;
|
|
|
+ }
|
|
|
+ else if (posterPrintPaperIndex < PrintedPageCount - 1)
|
|
|
+ {
|
|
|
+ ///当前总文件未打印完
|
|
|
+ posterPrintPaperIndex++;
|
|
|
+ PosterCurrentBitmap.Dispose();
|
|
|
+ DisplayBitmap.Dispose();
|
|
|
+ GC.Collect();
|
|
|
+ GC.WaitForPendingFinalizers();
|
|
|
+ HorizonPaperIndex = 0;
|
|
|
+ VerticalPaperIndex = 0;
|
|
|
+ e.HasMorePages = true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ HorizonPaperIndex = 0;
|
|
|
+ VerticalPaperIndex = 0;
|
|
|
+ e.HasMorePages = false;
|
|
|
+ }
|
|
|
+ } //当一页只有一张打印纸的时候
|
|
|
else
|
|
|
{
|
|
|
- HorizonPaperIndex = 0;
|
|
|
- VerticalPaperIndex = 0;
|
|
|
- e.HasMorePages = false;
|
|
|
- }
|
|
|
- }
|
|
|
+ e.Graphics.DrawImage(DisplayBitmap, new Rectangle(0, 0, pageBound.Width, pageBound.Height), new Rectangle(0, 0, DisplayBitmap.Width, DisplayBitmap.Height), GraphicsUnit.Pixel);
|
|
|
|
|
|
- //当一页只有一张打印纸的时候
|
|
|
- else if (WholeCountSinglePage == 1)
|
|
|
- {
|
|
|
- if (PrintSettingsInfo.IsGrayscale)
|
|
|
- {
|
|
|
- PosterCurrentBitmap = ToGray(PosterCurrentBitmap, 0);
|
|
|
- }
|
|
|
- e.Graphics.DrawImage(DisplayBitmap, e.PageBounds);
|
|
|
- if (posterPrintPaperIndex < PrintedPageCount - 1)
|
|
|
- {
|
|
|
- ///当前总文件未打印完
|
|
|
- posterPrintPaperIndex++;
|
|
|
- PosterCurrentBitmap.Dispose();
|
|
|
- DisplayBitmap.Dispose();
|
|
|
- GC.Collect();
|
|
|
- GC.WaitForPendingFinalizers();
|
|
|
- HorizonPaperIndex = 0;
|
|
|
- VerticalPaperIndex = 0;
|
|
|
- e.HasMorePages = true;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- e.HasMorePages = false;
|
|
|
+ if (posterPrintPaperIndex < PrintedPageCount - 1)
|
|
|
+ {
|
|
|
+ ///当前总文件未打印完
|
|
|
+ posterPrintPaperIndex++;
|
|
|
+ PosterCurrentBitmap.Dispose();
|
|
|
+ DisplayBitmap.Dispose();
|
|
|
+ GC.Collect();
|
|
|
+ GC.WaitForPendingFinalizers();
|
|
|
+ HorizonPaperIndex = 0;
|
|
|
+ VerticalPaperIndex = 0;
|
|
|
+ e.HasMorePages = true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ e.HasMorePages = false;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -837,7 +841,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
|
|
|
if (posterInfo.Label == null || posterInfo.Label == "")
|
|
|
{
|
|
|
///Fix 13366: (行、列)文件名 时间 日期)
|
|
|
- sign = string.Format("({0},{1}){2}.pdf {3} {4}", HorizonPaperIndex + 1, VerticalPaperIndex + 1, PDFViewer.Document.FileName, System.DateTime.Today.ToString("yyyy-MM-dd"), System.DateTime.Now.ToString("HH:mm:ss"));
|
|
|
+ sign = string.Format("({0},{1}) -{2} -{3}.pdf {4} {5}", HorizonPaperIndex + 1, VerticalPaperIndex + 1, PrintIndex + 1, PDFViewer.Document.FileName, System.DateTime.Today.ToString("yyyy/MM/dd"), System.DateTime.Now.ToString("HH:mm:ss"));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -1107,6 +1111,10 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
|
|
|
else
|
|
|
{
|
|
|
e.HasMorePages = false;
|
|
|
+ if (PrintIndex % 2 == 0)
|
|
|
+ {
|
|
|
+ this.printDocumentEvent.GetEvent<SendFinishedFrontSideEvent>().Publish(new FinishedFrontSide { Unicode = this.Unicode });
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
//单面打印
|
|
@@ -1137,7 +1145,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
|
|
|
heightDpiRatio = (int)e.Graphics.DpiY / 100;
|
|
|
}
|
|
|
Bitmap printBitmap;
|
|
|
- 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);
|
|
|
+ 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);
|
|
|
double singlePageHeight;
|
|
|
double singlePageWidth;
|
|
|
if (PrintSettingsInfo.EnumPrintOrientation == EnumPrintOrientation.StatusPortrait)
|
|
@@ -1231,10 +1239,10 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
|
|
|
rightPage = null;
|
|
|
rightPage = null;
|
|
|
}
|
|
|
- if(rightPage != null)
|
|
|
+ if (rightPage != null)
|
|
|
{
|
|
|
startPoint.X = (int)singlePageWidth;
|
|
|
- rightBitmap = ToolMethod.RenderPageBitmapNoWait(PDFViewer.Document, (int)rightPage.PageSize.Width*widthDpiRatio, (int)rightPage.PageSize.Height*heightDpiRatio, rightPageIndex, PrintSettingsInfo.IsPrintWithAnnot, PrintSettingsInfo.IsPrintWithForm);
|
|
|
+ rightBitmap = ToolMethod.RenderPageBitmapNoWait(PDFViewer.Document, (int)rightPage.PageSize.Width * widthDpiRatio, (int)rightPage.PageSize.Height * heightDpiRatio, rightPageIndex, PrintSettingsInfo.IsPrintWithAnnot, PrintSettingsInfo.IsPrintWithForm);
|
|
|
if (bookletInfo.IsAutoRotate)
|
|
|
{
|
|
|
if ((rightPage.PageSize.Height / rightPage.PageSize.Width > 1 && (double)singlePageHeight / singlePageWidth < 1) ||
|
|
@@ -1353,7 +1361,7 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
|
|
|
resizedWidth = (int)(singlePageWidth * 0.96);
|
|
|
resizedHeight = (int)(singlePageWidth / rightBitmap.Width * rightBitmap.Height * 0.96);
|
|
|
}
|
|
|
- startPoint.X+= (int)(singlePageWidth - resizedWidth) / 2;
|
|
|
+ startPoint.X += (int)(singlePageWidth - resizedWidth) / 2;
|
|
|
startPoint.Y = (int)(singlePageHeight - resizedHeight) / 2;
|
|
|
if (PrintSettingsInfo.IsGrayscale)
|
|
|
{
|
|
@@ -1581,6 +1589,10 @@ namespace PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePagePrinter
|
|
|
else
|
|
|
{
|
|
|
e.HasMorePages = false;
|
|
|
+ if (PrintIndex % 2 == 0)
|
|
|
+ {
|
|
|
+ this.printDocumentEvent.GetEvent<SendFinishedFrontSideEvent>().Publish(new FinishedFrontSide { Unicode = this.Unicode });
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
//单面打印或自动双面
|