Beispiel #1
0
        public void PDFiumBridge_FPDFAnnotGetAttachmentPoints_SimpleCall_NoException()
        {
            var points = new FS_QUADPOINTSF();

            _bridge.FPDFAnnot_GetAttachmentPoints(FPDF_ANNOTATION.InvalidHandle, 0, ref points);
        }
Beispiel #2
0
        public void PDFiumBridge_FPDFLinkGetQuadPoints_SimpleCall_NoException()
        {
            var points = new FS_QUADPOINTSF();

            _bridge.FPDFLink_GetQuadPoints(FPDF_LINK.InvalidHandle, 0, ref points);
        }
Beispiel #3
0
        public void PDFiumBridge_FPDFPageGetAnnot_TestForExistence_Success()
        {
            var pdfFile = Path.Combine(_pdfFilesFolder, "Annotations.pdf");
            var bridge  = new PDFiumBridge();

            var document = bridge.FPDF_LoadDocument(pdfFile, null);

            Assert.IsTrue(document.IsValid);

            var page = bridge.FPDF_LoadPage(document, 0);

            Assert.IsTrue(page.IsValid);

            var count = bridge.FPDFPage_GetAnnotCount(page);

            for (var index = 0; index < count; index++)
            {
                var annot = bridge.FPDFPage_GetAnnot(page, index);
                Assert.IsTrue(annot.IsValid);
                var realIndex = bridge.FPDFPage_GetAnnotIndex(page, annot);
                Assert.AreEqual(index, realIndex);
                var subtype = bridge.FPDFAnnot_GetSubtype(annot);
                Assert.IsTrue(subtype != FPDF_ANNOTATION_SUBTYPE.FPDF_ANNOT_UNKNOWN);

                var objectCount = bridge.FPDFAnnot_GetObjectCount(annot);
                for (var objectIndex = 0; objectIndex < objectCount; objectIndex++)
                {
                    var obj = bridge.FPDFAnnot_GetObject(annot, objectIndex);
                    Assert.IsTrue(obj.IsValid);
                }

                var pointsCount = bridge.FPDFAnnot_CountAttachmentPoints(annot);
                for (var pointsIndex = 0; pointsIndex < pointsCount; pointsIndex++)
                {
                    var points = new FS_QUADPOINTSF();
                    Assert.IsTrue(bridge.FPDFAnnot_GetAttachmentPoints(annot, pointsIndex, ref points));
                }

                var rect = new FS_RECTF();
                Assert.IsTrue(bridge.FPDFAnnot_GetRect(annot, ref rect));

                var verticesCount = bridge.FPDFAnnot_GetVertices(annot, IntPtr.Zero, 0);
                if (verticesCount != 0)
                {
                    var points       = new FS_POINTF[verticesCount];
                    var pointsIntPtr = NativeMethods.StructureArrayToIntPtr(points);
                    Assert.AreEqual(verticesCount, bridge.FPDFAnnot_GetVertices(annot, pointsIntPtr, verticesCount));
                    Marshal.FreeHGlobal(pointsIntPtr);
                }

                float horizontal_radius, vertical_radius, border_width;
                horizontal_radius = vertical_radius = border_width = -1f;
                if (bridge.FPDFAnnot_GetBorder(annot, ref horizontal_radius, ref vertical_radius, ref border_width))
                {
                    Assert.IsTrue(horizontal_radius != -1f);
                    Assert.IsTrue(vertical_radius != -1f);
                    Assert.IsTrue(border_width != -1f);
                }

                bridge.FPDFPage_CloseAnnot(annot);
            }

            bridge.FPDF_ClosePage(page);
            bridge.FPDF_CloseDocument(document);
            bridge.Dispose();
        }