Bläddra i källkod

ComPDFKit(win) - 修复Samples代码CRect上下值搞反的问题

TangJinZhou 11 månader sedan
förälder
incheckning
475c1112cd

+ 8 - 11
Demo/Examples/Samples/AnnotationTest/CS/AnnotationTest.cs

@@ -4,10 +4,7 @@ using ComPDFKit.PDFDocument;
 using ComPDFKit.PDFPage;
 using System;
 using System.Collections.Generic;
-using System.Drawing;
-using System.Drawing.Imaging;
 using System.IO;
-using System.Runtime.InteropServices;
 using ImageMagick;
 
 namespace AnnotationTest
@@ -101,7 +98,7 @@ namespace AnnotationTest
                 new CPoint(100,10),
             });
             ink.SetInkPath(points);
-            ink.SetInkRect(new CRect(10, 10, 200, 200));
+            ink.SetInkRect(new CRect(10, 200, 200, 10));
 
             ink.UpdateAp();
         }
@@ -131,7 +128,7 @@ namespace AnnotationTest
 
             // Circle
             CPDFCircleAnnotation circle = page.CreateAnnot(C_ANNOTATION_TYPE.C_ANNOTATION_CIRCLE) as CPDFCircleAnnotation;
-            circle.SetRect(new CRect(10, 300, 110, 410));
+            circle.SetRect(new CRect(10, 410, 110, 300));
             circle.SetLineColor(lineColor);
             circle.SetBgColor(bgColor);
             circle.SetTransparency(120);
@@ -161,7 +158,7 @@ namespace AnnotationTest
             textAnnotation.SetColor(new byte[] { 255, 0, 0 });
             textAnnotation.SetTransparency(255);
             textAnnotation.SetContent("ComPDFKit");
-            textAnnotation.SetRect(new CRect(300, 600, 350, 650));
+            textAnnotation.SetRect(new CRect(300, 650, 350, 600));
             textAnnotation.UpdateAp();
         }
 
@@ -173,7 +170,7 @@ namespace AnnotationTest
         {
             CPDFPage page = document.PageAtIndex(1);
             CPDFSoundAnnotation sound = page.CreateAnnot(C_ANNOTATION_TYPE.C_ANNOTATION_SOUND) as CPDFSoundAnnotation;
-            sound.SetRect(new CRect(400, 700, 450, 750));
+            sound.SetRect(new CRect(400, 750, 450, 700));
             sound.SetSoundPath(null,"Bird.wav");
             sound.UpdateAp();
         }
@@ -185,7 +182,7 @@ namespace AnnotationTest
         static private void CreateMarkupAnnotation(CPDFDocument document)
         {
             List<CRect> cRectList = new List<CRect>();
-            CRect rect = new CRect(300, 240, 400, 300);
+            CRect rect = new CRect(300, 300, 400, 240);
             cRectList.Add(rect);
             byte[] color = { 255, 0, 0 };
 
@@ -238,13 +235,13 @@ namespace AnnotationTest
             // Standard
             CPDFStampAnnotation standard = page.CreateAnnot(C_ANNOTATION_TYPE.C_ANNOTATION_STAMP) as CPDFStampAnnotation;
             standard.SetStandardStamp("Approved");
-            standard.SetRect(new CRect(300, 100, 450, 160));
+            standard.SetRect(new CRect(300, 160, 450, 100));
             standard.UpdateAp();
 
             // Text
             CPDFStampAnnotation text = page.CreateAnnot(C_ANNOTATION_TYPE.C_ANNOTATION_STAMP) as CPDFStampAnnotation;
             text.SetTextStamp("test", "detail text", C_TEXTSTAMP_SHAPE.TEXTSTAMP_LEFT_TRIANGLE, C_TEXTSTAMP_COLOR.TEXTSTAMP_RED);
-            text.SetRect(new CRect(300, 220, 450, 300));
+            text.SetRect(new CRect(300, 300, 450, 220));
 
             text.UpdateAp();
 
@@ -257,7 +254,7 @@ namespace AnnotationTest
                 stampAnnotation.SetImageStamp(byteArray, image.Width, image.Height);
             }
             
-            stampAnnotation.SetRect(new CRect(300, 320, 380, 400));
+            stampAnnotation.SetRect(new CRect(300, 400, 380, 320));
             stampAnnotation.SetTransparency(255);
             stampAnnotation.UpdateAp();
         }

+ 8 - 8
Demo/Examples/Samples/AnnotationTest/VB/AnnotationTest.vb

@@ -77,7 +77,7 @@ Module AnnotationTest
     })
 
         ink.SetInkPath(points)
-        ink.SetInkRect(New CRect(10, 10, 200, 200))
+        ink.SetInkRect(New CRect(10, 200, 200, 10))
 
         ink.UpdateAp()
     End Sub
@@ -100,7 +100,7 @@ Module AnnotationTest
 
         ' Circle
         Dim circle As CPDFCircleAnnotation = TryCast(page.CreateAnnot(C_ANNOTATION_TYPE.C_ANNOTATION_CIRCLE), CPDFCircleAnnotation)
-        circle.SetRect(New CRect(10, 300, 110, 410))
+        circle.SetRect(New CRect(10, 410, 110, 300))
         circle.SetLineColor(lineColor)
         circle.SetBgColor(bgColor)
         circle.SetTransparency(120)
@@ -125,20 +125,20 @@ Module AnnotationTest
         textAnnotation.SetColor(New Byte() {255, 0, 0})
         textAnnotation.SetTransparency(255)
         textAnnotation.SetContent("ComPDFKit")
-        textAnnotation.SetRect(New CRect(300, 600, 350, 650))
+        textAnnotation.SetRect(New CRect(300, 650, 350, 600))
         textAnnotation.UpdateAp()
     End Sub
     Private Sub CreateSoundAnnotation(document As CPDFDocument)
         Dim page As CPDFPage = document.PageAtIndex(0)
         Dim sound As CPDFSoundAnnotation = TryCast(page.CreateAnnot(C_ANNOTATION_TYPE.C_ANNOTATION_SOUND), CPDFSoundAnnotation)
-        sound.SetRect(New CRect(400, 700, 450, 750))
+        sound.SetRect(New CRect(400, 750, 450, 700))
         sound.SetSoundPath("","Bird.wav")
         sound.UpdateAp()
     End Sub
 
     Private Sub CreateMarkupAnnotation(document As CPDFDocument)
         Dim cRectList As New List(Of CRect)()
-        Dim rect As New CRect(300, 240, 400, 300)
+        Dim rect As New CRect(300, 300, 400, 240)
         cRectList.Add(rect)
         Dim color As Byte() = {255, 0, 0}
 
@@ -200,20 +200,20 @@ Module AnnotationTest
         ' Standard
         Dim standard As CPDFStampAnnotation = TryCast(page.CreateAnnot(C_ANNOTATION_TYPE.C_ANNOTATION_STAMP), CPDFStampAnnotation)
         standard.SetStandardStamp("Approved")
-        standard.SetRect(New CRect(300, 100, 450, 160))
+        standard.SetRect(New CRect(300, 160, 450, 100))
         standard.UpdateAp()
 
         ' Text
         Dim text As CPDFStampAnnotation = TryCast(page.CreateAnnot(C_ANNOTATION_TYPE.C_ANNOTATION_STAMP), CPDFStampAnnotation)
         text.SetTextStamp("test", "detail text", C_TEXTSTAMP_SHAPE.TEXTSTAMP_LEFT_TRIANGLE, C_TEXTSTAMP_COLOR.TEXTSTAMP_RED)
-        text.SetRect(New CRect(300, 220, 450, 300))
+        text.SetRect(New CRect(300, 300, 450, 220))
         text.UpdateAp()
 
         ' Image
         Dim bitmap As New Bitmap("logo.png")
         Dim image As CPDFStampAnnotation = TryCast(page.CreateAnnot(C_ANNOTATION_TYPE.C_ANNOTATION_STAMP), CPDFStampAnnotation)
         image.SetImageStamp(BitmapToByteArray(bitmap), bitmap.Width, bitmap.Height)
-        image.SetRect(New CRect(300, 320, 380, 400))
+        image.SetRect(New CRect(300, 400, 380, 320))
         image.SetTransparency(255)
         image.UpdateAp()
     End Sub

+ 1 - 2
Demo/Examples/Samples/DigitalSignatureTest/VB/DigitalSignatureTest.vb

@@ -1,5 +1,4 @@
-Imports System.Drawing
-Imports System.IO
+Imports System.IO
 Imports ComPDFKit.DigitalSign
 Imports ComPDFKit.Import
 Imports ComPDFKit.PDFAnnotation.Form

+ 1 - 1
Demo/Examples/Samples/InteractiveFormsTest/CS/InteractiveFormsTest.cs

@@ -49,7 +49,7 @@ namespace InteractiveFormsTest
         {
             CPDFPage page = document.PageAtIndex(0);
             CPDFTextWidget textField = page.CreateWidget(C_WIDGET_TYPE.WIDGET_TEXTFIELD) as CPDFTextWidget;
-            textField.SetRect(new CRect( 28, 32, 235, 75));
+            textField.SetRect(new CRect( 28, 75, 235, 32));
             textField.SetWidgetBorderRGBColor(new byte[] { 0, 0, 0 });
             textField.SetWidgetBgRGBColor(new byte[] {240,255,240});
         }

+ 1 - 5
Demo/Examples/Samples/InteractiveFormsTest/VB/InteractiveFormsTest.vb

@@ -4,11 +4,7 @@ Imports ComPDFKit.PDFAnnotation.Form
 Imports ComPDFKit.PDFDocument
 Imports ComPDFKit.PDFDocument.Action
 Imports ComPDFKit.PDFPage
-Imports ComPDFKit.PDFPage.Edit
-Imports System
-Imports System.Collections.Generic
 Imports System.IO
-Imports System.Text
 
 Module InteractiveFormsTest
     Private outputPath As String = Path.GetDirectoryName(Path.GetDirectoryName(Path.GetDirectoryName(System.IO.Directory.GetCurrentDirectory()))) & "\Output\VB"
@@ -36,7 +32,7 @@ Module InteractiveFormsTest
     Private Sub CreateTextField(document As CPDFDocument)
         Dim page As CPDFPage = document.PageAtIndex(0)
         Dim textField As CPDFTextWidget = TryCast(page.CreateWidget(C_WIDGET_TYPE.WIDGET_TEXTFIELD), CPDFTextWidget)
-        textField.SetRect(New CRect(28, 32, 235, 75))
+        textField.SetRect(New CRect(28, 75, 235, 32))
         textField.SetWidgetBorderRGBColor(New Byte() {0, 0, 0})
         textField.SetWidgetBgRGBColor(New Byte() {240, 255, 240})
     End Sub

+ 1 - 1
Demo/Examples/Samples/PDFRedactTest/CS/PDFRedactTest.cs

@@ -57,7 +57,7 @@ namespace PDFRedactTest
             CPDFPage page = document.PageAtIndex(0);
             CPDFRedactAnnotation redact = page.CreateAnnot(C_ANNOTATION_TYPE.C_ANNOTATION_REDACT) as CPDFRedactAnnotation;
             //Set radact rect: cover the title
-            redact.SetRect(new CRect(300, 240, 400, 300));
+            redact.SetRect(new CRect(300, 300, 400, 240));
             //Set overlay text: REDACTED
             redact.SetOverlayText("REDACTED");
 

+ 1 - 3
Demo/Examples/Samples/PDFRedactTest/VB/PDFRedactTest.vb

@@ -2,9 +2,7 @@
 Imports ComPDFKit.PDFAnnotation
 Imports ComPDFKit.PDFDocument
 Imports ComPDFKit.PDFPage
-Imports System
 Imports System.IO
-Imports System.Windows
 
 Module PDFRedactTest
     Private outputPath As String = Path.GetDirectoryName(Path.GetDirectoryName(Path.GetDirectoryName(System.IO.Directory.GetCurrentDirectory()))) & "\Output\VB"
@@ -43,7 +41,7 @@ Module PDFRedactTest
         Dim page As CPDFPage = document.PageAtIndex(0)
         Dim redactAnnot As CPDFRedactAnnotation = TryCast(page.CreateAnnot(C_ANNOTATION_TYPE.C_ANNOTATION_REDACT), CPDFRedactAnnotation)
         ' Set redact rect: cover the title
-        redactAnnot.SetRect(New CRect(300, 240, 400, 300))
+        redactAnnot.SetRect(New CRect(300, 300, 400, 240))
         ' Set overlay text: REDACTED
         redactAnnot.SetOverlayText("REDACTED")
 

+ 2 - 2
Demo/Examples/Samples/TextSearchTest/CS/TextSearchTest.cs

@@ -60,7 +60,7 @@ namespace TextSearchTest
                 while (searcher.FindNext(page, textPage, ref textRect, ref textContent, ref findIndex))
                 {
                     strings.Add(textContent);
-                    rects.Add(new CRect(textRect.left, textRect.top, textRect.width(), textRect.height()));
+                    rects.Add(new CRect(textRect.left, textRect.bottom, textRect.right, textRect.top));
                 }
             }
         }
@@ -71,7 +71,7 @@ namespace TextSearchTest
         static private bool HighlightTheFirstResult(CPDFPage page, CRect rect)
         {
             List<CRect> cRectList = new List<CRect>();
-            cRectList.Add(new CRect((float)rect.left, (float)rect.bottom, (float)rect.right, (float)rect.top));
+            cRectList.Add(new CRect(rect.left, rect.bottom, rect.right, rect.top));
 
             CPDFHighlightAnnotation annotation = page.CreateAnnot(C_ANNOTATION_TYPE.C_ANNOTATION_HIGHLIGHT) as CPDFHighlightAnnotation;
             byte[] color = { 0, 255, 0 };

+ 1 - 3
Demo/Examples/Samples/TextSearchTest/VB/TextSearchTest.vb

@@ -2,8 +2,6 @@ Imports ComPDFKit.Import
 Imports ComPDFKit.PDFAnnotation
 Imports ComPDFKit.PDFDocument
 Imports ComPDFKit.PDFPage
-Imports System
-Imports System.Collections.Generic
 Imports System.IO
 Imports System.Windows
 
@@ -55,7 +53,7 @@ Module TextSearchTest
     ' Highlight the first result
     Private Function HighlightTheFirstResult(page As CPDFPage, rect As Rect) As Boolean
         Dim cRectList As New List(Of CRect)()
-        cRectList.Add(New CRect(CSng(rect.Left), CSng(rect.Top), CSng(rect.Right), CSng(rect.Bottom)))
+        cRectList.Add(New CRect(CSng(rect.Left), CSng(rect.Bottom), CSng(rect.Right), CSng(rect.Top)))
 
         Dim annotation As CPDFHighlightAnnotation = CType(page.CreateAnnot(C_ANNOTATION_TYPE.C_ANNOTATION_HIGHLIGHT), CPDFHighlightAnnotation)
         Dim color As Byte() = {0, 255, 0}