Browse Source

ComPDFKit.Tool(win) - 修复添加图片Stamp再删除后无法Undo的问题

TangJinZhou 3 days ago
parent
commit
631dcad19d

+ 11 - 3
Demo/Examples/ComPDFKit.Tool/UndoManger/AnnotHistory/StampAnnotHistory.cs

@@ -66,7 +66,7 @@ namespace ComPDFKit.Tool.UndoManger
             if (stampAnnot != null)
 			{
 				int annotIndex = pdfPage.GetAnnotCount() - 1;
-				switch(currentParam.StampType)
+                switch (currentParam.StampType)
 				{
 					case C_STAMP_TYPE.STANDARD_STAMP:
 						{
@@ -79,6 +79,7 @@ namespace ComPDFKit.Tool.UndoManger
 							stampAnnot.SetStandardStamp(stampText, pdfPage.Rotation);
                         }
 						break;
+
 					case C_STAMP_TYPE.TEXT_STAMP:
 						{
 							string dateText = currentParam.DateText;
@@ -101,6 +102,7 @@ namespace ComPDFKit.Tool.UndoManger
 								pdfPage.Rotation);
                         }
 						break;
+
 					case C_STAMP_TYPE.IMAGE_STAMP:
 						{
                             byte[] imageData = null;
@@ -109,6 +111,8 @@ namespace ComPDFKit.Tool.UndoManger
                             PDFHelp.ImageStreamToByte(currentParam.ImageStream, ref imageData, ref imageWidth, ref imageHeight);
 							if (imageData != null && imageWidth > 0 && imageHeight > 0)
 							{
+                                stampAnnot.SetSourceRect(currentParam.SourceRect);
+                                stampAnnot.AnnotationRotator.SetRotation(currentParam.Rotation);
                                 stampAnnot.SetImageStamp(
                                     imageData,
                                     imageWidth,
@@ -122,8 +126,12 @@ namespace ComPDFKit.Tool.UndoManger
 						break;
 				}
 
-                stampAnnot.SetSourceRect(currentParam.SourceRect);
-                stampAnnot.AnnotationRotator.SetRotation(currentParam.Rotation);
+                if(currentParam.StampType != C_STAMP_TYPE.IMAGE_STAMP)
+                {
+                    stampAnnot.SetSourceRect(currentParam.SourceRect);
+                    stampAnnot.AnnotationRotator.SetRotation(currentParam.Rotation);
+                }
+
                 stampAnnot.SetTransparency(currentParam.Transparency);
                 string imagePath = string.Empty;
                 if (currentParam.Transparency <255 && GetAnnotOpacityImage(stampAnnot, currentParam.Transparency / 255.0, 5, out imagePath) && File.Exists(imagePath))