|
@@ -1663,17 +1663,32 @@ namespace PDF_Master.ViewModels.Tools
|
|
|
var stampPicture = dlg.FileName;
|
|
|
if (menu.tag.ToString() == "PDF")
|
|
|
{
|
|
|
- var writeStamp = annot.GetStampDrawing();
|
|
|
- var tempDoc = new CPDFViewer();
|
|
|
- tempDoc.CreateDocument();
|
|
|
- if (tempDoc.Document == null)
|
|
|
- {
|
|
|
- AlertsMessage alertsMessage = new AlertsMessage();
|
|
|
- alertsMessage.ShowDialog("", App.MainPageLoader.GetString("Create PDF failed"), App.ServiceLoader.GetString("Text_ok"));
|
|
|
- return;
|
|
|
- }
|
|
|
- byte[] buffer;
|
|
|
+ try
|
|
|
+ {
|
|
|
+ var writeStamp = annot.GetStampDrawing();
|
|
|
+ var tempDoc = new CPDFViewer();
|
|
|
+ tempDoc.CreateDocument();
|
|
|
+ if (tempDoc.Document == null)
|
|
|
+ {
|
|
|
+ AlertsMessage alertsMessage = new AlertsMessage();
|
|
|
+ alertsMessage.ShowDialog("", App.MainPageLoader.GetString("Create PDF failed"), App.ServiceLoader.GetString("Text_ok"));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ byte[] buffer = new byte[writeStamp.PixelWidth * writeStamp.PixelHeight * 4];
|
|
|
+ writeStamp.CopyPixels(buffer, writeStamp.PixelWidth * 4, 0);
|
|
|
+
|
|
|
+ tempDoc.Document.InsertPage(0, writeStamp.PixelWidth, writeStamp.PixelHeight, buffer, CPDFDocumentImageMode.CPDFDocumentImageModeScaleAspectFit);
|
|
|
+ var result = tempDoc.Document.WriteToFilePath(dlg.FileName);
|
|
|
+ if (result)
|
|
|
+ {
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ }
|
|
|
|
|
|
+ #region
|
|
|
+ //之前的方法1
|
|
|
//var encoder = new PngBitmapEncoder();
|
|
|
//encoder.Frames.Add(BitmapFrame.Create(writeStamp));
|
|
|
//using (var memoryStream = new MemoryStream())
|
|
@@ -1687,11 +1702,13 @@ namespace PDF_Master.ViewModels.Tools
|
|
|
//if (result)
|
|
|
//{
|
|
|
//}
|
|
|
- string imagePath = SaveImage(writeStamp);
|
|
|
- if (CreateFile(imagePath, tempDoc))
|
|
|
- {
|
|
|
- bool result = tempDoc.Document.WriteToFilePath(dlg.FileName);
|
|
|
- }
|
|
|
+ //之前的方法2
|
|
|
+ //string imagePath = SaveImage(writeStamp);
|
|
|
+ //if (CreateFile(imagePath, tempDoc))
|
|
|
+ //{
|
|
|
+ // bool result = tempDoc.Document.WriteToFilePath(dlg.FileName);
|
|
|
+ //}
|
|
|
+ #endregion 注释右键菜单事件
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -1703,7 +1720,7 @@ namespace PDF_Master.ViewModels.Tools
|
|
|
encoder5.Save(stream5);
|
|
|
}
|
|
|
}
|
|
|
- System.Diagnostics.Process.Start("explorer", "/select,\"" + stampPicture + "\"");
|
|
|
+ CommonHelper.ExplorerFile(dlg.FileName);
|
|
|
}
|
|
|
}
|
|
|
}
|