|
@@ -449,10 +449,59 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
}
|
|
|
break;
|
|
|
case CPDFAnnotationType.Signature:
|
|
|
- AnnotParam signatureParam = new AnnotParam();
|
|
|
- CPDFSignatureData SignatureData = pdfAnnotationData as CPDFSignatureData;
|
|
|
- SetSignature(ref signatureParam, SignatureData);
|
|
|
- annotHandlerEventArgs = signatureParam;
|
|
|
+ {
|
|
|
+ AnnotParam signatureParam = new AnnotParam();
|
|
|
+ CPDFSignatureData SignatureData = pdfAnnotationData as CPDFSignatureData;
|
|
|
+ SetSignature(ref signatureParam, SignatureData);
|
|
|
+ BitmapDecoder decoder = null;
|
|
|
+ switch (signatureParam.CurrentType)
|
|
|
+ {
|
|
|
+ case C_ANNOTATION_TYPE.C_ANNOTATION_STAMP:
|
|
|
+ StampParam stampParam = (StampParam)signatureParam;
|
|
|
+ stampParam.ImageStream.Seek(0, SeekOrigin.Begin);
|
|
|
+ decoder = BitmapDecoder.Create(stampParam.ImageStream, BitmapCreateOptions.None, BitmapCacheOption.Default);
|
|
|
+ break;
|
|
|
+ case C_ANNOTATION_TYPE.C_ANNOTATION_INK:
|
|
|
+ if (!string.IsNullOrEmpty(SignatureData.SourcePath))
|
|
|
+ {
|
|
|
+ BitmapImage image = new BitmapImage(new Uri(SignatureData.SourcePath));
|
|
|
+ PngBitmapEncoder encoder = new PngBitmapEncoder();
|
|
|
+ encoder.Frames.Add(BitmapFrame.Create(image));
|
|
|
+ MemoryStream memoryStream = new MemoryStream();
|
|
|
+ encoder.Save(memoryStream);
|
|
|
+ decoder = BitmapDecoder.Create(memoryStream, BitmapCreateOptions.None, BitmapCacheOption.Default);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ BitmapFrame frame = null;
|
|
|
+ if (decoder != null && decoder.Frames.Count > 0)
|
|
|
+ {
|
|
|
+ frame = decoder.Frames[0];
|
|
|
+ }
|
|
|
+ if (frame != null)
|
|
|
+ {
|
|
|
+ byte[] imageArray = new byte[frame.PixelWidth * frame.PixelHeight * 4];
|
|
|
+ if (frame.Format != PixelFormats.Bgra32)
|
|
|
+ {
|
|
|
+ FormatConvertedBitmap covert = new FormatConvertedBitmap(
|
|
|
+ frame,
|
|
|
+ PixelFormats.Bgra32,
|
|
|
+ frame.Palette,
|
|
|
+ 0);
|
|
|
+ covert.CopyPixels(imageArray, frame.PixelWidth * 4, 0);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ frame.CopyPixels(imageArray, frame.PixelWidth * 4, 0);
|
|
|
+ }
|
|
|
+ pdfViewerControl.PDFViewTool.GetCPDFViewer().SetStampMouseImage(imageArray, frame.PixelWidth, frame.PixelHeight);
|
|
|
+ pdfViewerControl.PDFViewTool.GetCPDFViewer().SetIsVisibleCustomMouse(true);
|
|
|
+ pdfViewerControl.PDFViewTool.GetCPDFViewer().SetIsShowStampMouse(true);
|
|
|
+ annotHandlerEventArgs = signatureParam;
|
|
|
+ }
|
|
|
+ }
|
|
|
break;
|
|
|
case CPDFAnnotationType.Link:
|
|
|
if (annotHandlerEventArgs != null)
|
|
@@ -468,7 +517,7 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
break;
|
|
|
}
|
|
|
pdfViewerControl.PDFToolManager.SetToolType(ToolType.CreateAnnot);
|
|
|
- if (annotationType != CPDFAnnotationType.Stamp)
|
|
|
+ if (annotationType != CPDFAnnotationType.Stamp && annotationType != CPDFAnnotationType.Signature)
|
|
|
{
|
|
|
pdfViewerControl.PDFViewTool.GetCPDFViewer().SetIsShowStampMouse(false);
|
|
|
}
|
|
@@ -487,7 +536,7 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
annotParam = new StampParam();
|
|
|
|
|
|
annotParam.CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_STAMP;
|
|
|
- (annotParam as StampParam).Transparency = 1;
|
|
|
+ (annotParam as StampParam).Transparency = 255;
|
|
|
(annotParam as StampParam).StampType = C_STAMP_TYPE.IMAGE_STAMP;
|
|
|
if (!string.IsNullOrEmpty(stamp.SourcePath))
|
|
|
{
|
|
@@ -505,6 +554,7 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
case SignatureType.Drawing:
|
|
|
{
|
|
|
annotParam = new InkParam();
|
|
|
+ (annotParam as InkParam).Transparency = stamp.inkColor.A;
|
|
|
annotParam.CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_INK;
|
|
|
List<List<Point>> RawPointList = GetPoints(stamp.DrawingPath);
|
|
|
List<CPoint> linqList = new List<CPoint>();
|
|
@@ -793,7 +843,7 @@ namespace Compdfkit_Tools.PDFControl
|
|
|
pdfViewerControl.PDFToolManager.SetToolType(ToolType.CreateAnnot);
|
|
|
pdfViewerControl.PDFToolManager.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_STAMP);
|
|
|
}
|
|
|
- catch
|
|
|
+ catch
|
|
|
{
|
|
|
}
|
|
|
}
|