Пример #1
0
        internal PDFAnnotation(PDAnnotation pdfBoxAnnotation)
        {
            this.pdfAnotation = pdfBoxAnnotation;
            string subtype = pdfBoxAnnotation.getSubtype();

            switch (subtype)
            {
            case "PDAnnotationLine":
            {
                this.annotationType = PDFAnnotationType.PDFAnnotationLine;
                break;
            }

            case "PDAnnotationLink":
            {
                this.annotationType = PDFAnnotationType.PDFAnnotationLink;
                break;
            }

            case "PDAnnotationPopup":
            {
                this.annotationType = PDFAnnotationType.PDFAnnotationPopup;
                break;
            }

            case "PDAnnotationRubberStamp":
            {
                this.annotationType = PDFAnnotationType.PDFAnnotationRubberStamp;
                break;
            }

            case "PDAnnotationSquareCircle":
            {
                this.annotationType = PDFAnnotationType.PDFAnnotationSquare;
                break;
            }

            case "PDAnnotationText":
            {
                this.annotationType = PDFAnnotationType.PDFAnnotationText;
                break;
            }

            case "PDAnnotationTextMarkup":
            {
                this.annotationType = PDFAnnotationType.PDFAnnotationTextMarkup;
                break;
            }
            }
            this.content  = pdfBoxAnnotation.getContents();
            this.position = new PDFRectangle(pdfBoxAnnotation.getRectangle());
        }
Пример #2
0
        public PDFAnnotation(PDFAnnotationType type, PDFRectangle position, string content)
        {
            PDColor color = PDFHelper.GetColor(PDFColor.Black);

            switch (type)
            {
            case PDFAnnotationType.PDFAnnotationLine:
            {
                this.Direction = PDFDirection.UP;
                PDAnnotationLine pDAnnotationLine = new PDAnnotationLine();
                (new PDBorderStyleDictionary()).setWidth(6f);
                pDAnnotationLine.setEndPointEndingStyle("ROpenArrow");
                pDAnnotationLine.setCaption(true);
                this.pdfAnotation = pDAnnotationLine;
                break;
            }

            case PDFAnnotationType.PDFAnnotationLink:
            {
                PDAnnotationLink pDAnnotationLink = new PDAnnotationLink();
                PDActionURI      pDActionURI      = new PDActionURI();
                pDActionURI.setURI(content);
                pDAnnotationLink.setAction(pDActionURI);
                pDAnnotationLink.setContents(content);
                this.pdfAnotation = pDAnnotationLink;
                break;
            }

            case PDFAnnotationType.PDFAnnotationPopup:
            {
                this.pdfAnotation = new PDAnnotationPopup();
                break;
            }

            case PDFAnnotationType.PDFAnnotationRubberStamp:
            {
                this.pdfAnotation = new PDAnnotationRubberStamp();
                break;
            }

            case PDFAnnotationType.PDFAnnotationSquare:
            {
                this.pdfAnotation = new PDAnnotationSquareCircle("Square");
                break;
            }

            case PDFAnnotationType.PDFAnnotationCircle:
            {
                this.pdfAnotation = new PDAnnotationSquareCircle("Circle");
                break;
            }

            case PDFAnnotationType.PDFAnnotationText:
            {
                this.pdfAnotation = new PDAnnotationText();
                break;
            }

            case PDFAnnotationType.PDFAnnotationTextMarkup:
            {
                PDAnnotationTextMarkup pDAnnotationTextMarkup = new PDAnnotationTextMarkup("FreeText");
                float[] array = new float[8];
                array[0] = position.PDFBoxRectangle.getLowerLeftX();
                array[1] = position.PDFBoxRectangle.getUpperRightY() - 2f;
                array[2] = position.PDFBoxRectangle.getUpperRightX();
                array[3] = array[1];
                array[4] = array[0];
                array[5] = position.PDFBoxRectangle.getLowerLeftY() - 2f;
                array[6] = array[2];
                array[7] = array[5];
                pDAnnotationTextMarkup.setQuadPoints(array);
                pDAnnotationTextMarkup.setContents(content);
                pDAnnotationTextMarkup.setConstantOpacity(0.2f);
                this.pdfAnotation = pDAnnotationTextMarkup;
                break;
            }
            }
            this.annotationType = type;
            this.position       = position;
            if (string.IsNullOrEmpty(this.pdfAnotation.getContents()))
            {
                this.pdfAnotation.setContents(content);
            }
            this.pdfAnotation.setColor(color);
        }
Пример #3
0
        public PDFAnnotation(PDFAnnotationType type, PDFRectangle position, string content, string subType)
        {
            this.SubType = subType;
            PDColor color = PDFHelper.GetColor(PDFColor.Black);

            switch (type)
            {
            case PDFAnnotationType.PDFAnnotationLine:
            {
                this.Direction = PDFDirection.UP;
                PDAnnotationLine pDAnnotationLine = new PDAnnotationLine();
                (new PDBorderStyleDictionary()).setWidth(6f);
                if (!string.IsNullOrEmpty(subType))
                {
                    pDAnnotationLine.setEndPointEndingStyle(subType);
                }
                else
                {
                    pDAnnotationLine.setEndPointEndingStyle("ROpenArrow");
                }
                pDAnnotationLine.setCaption(true);
                this.pdfAnotation = pDAnnotationLine;
                break;
            }

            case PDFAnnotationType.PDFAnnotationLink:
            {
                PDAnnotationLink pDAnnotationLink = new PDAnnotationLink();
                pDAnnotationLink.setContents(content);
                this.pdfAnotation = pDAnnotationLink;
                break;
            }

            case PDFAnnotationType.PDFAnnotationPopup:
            {
                this.pdfAnotation = new PDAnnotationPopup();
                break;
            }

            case PDFAnnotationType.PDFAnnotationRubberStamp:
            {
                this.pdfAnotation = new PDAnnotationRubberStamp();
                break;
            }

            case PDFAnnotationType.PDFAnnotationSquare:
            {
                this.pdfAnotation = new PDAnnotationSquareCircle("Square");
                break;
            }

            case PDFAnnotationType.PDFAnnotationCircle:
            {
                this.pdfAnotation = new PDAnnotationSquareCircle("Circle");
                break;
            }

            case PDFAnnotationType.PDFAnnotationText:
            {
                this.pdfAnotation = new PDAnnotationText();
                break;
            }

            case PDFAnnotationType.PDFAnnotationTextMarkup:
            {
                PDAnnotationTextMarkup pDAnnotationTextMarkup = null;
                pDAnnotationTextMarkup = (!string.IsNullOrEmpty(subType) ? new PDAnnotationTextMarkup(subType) : new PDAnnotationTextMarkup("FreeText"));
                pDAnnotationTextMarkup.setContents(content);
                this.pdfAnotation = pDAnnotationTextMarkup;
                break;
            }
            }
            this.annotationType = type;
            this.position       = position;
            if (string.IsNullOrEmpty(this.pdfAnotation.getContents()))
            {
                this.pdfAnotation.setContents(content);
            }
            this.pdfAnotation.setColor(color);
        }
Пример #4
0
 public void SetSize(PDFRectangle rectangle)
 {
     this.size = rectangle;
 }
Пример #5
0
 public void SetSize(PageSize pageSize)
 {
     this.size = PDFHelper.GetPDFRectangle(pageSize);
 }
Пример #6
0
 public PDFPage(PDFRectangle rectangle)
 {
     this.page     = new PDPage();
     this.MediaBox = rectangle;
 }
Пример #7
0
        public static PDAppearanceDictionary GetRubberStampAppearance(PDFDocument document, PDFRectangle rect, string subType)
        {
            PDAppearanceDictionary pDAppearanceDictionary;
            string empty = string.Empty;

            empty = (!System.IO.File.Exists(subType) ? PDFHelper.GetResourceLocation(subType) : subType);
            if (empty == null)
            {
                Console.WriteLine("Cant find rubber stamp");
                pDAppearanceDictionary = null;
            }
            else
            {
                PDImageXObject pDImageXObject = PDImageXObject.createFromFileByContent(new java.io.File(empty), document.PDFBoxDocument);
                float          lowerLeftX     = rect.PDFBoxRectangle.getLowerLeftX();
                float          lowerLeftY     = rect.PDFBoxRectangle.getLowerLeftY();
                rect.PDFBoxRectangle.getWidth();
                rect.PDFBoxRectangle.getHeight();
                rect.PDFBoxRectangle.getHeight();
                rect.PDFBoxRectangle.getWidth();
                PDFormXObject pDFormXObject = new PDFormXObject(document.PDFBoxDocument);
                pDFormXObject.setResources(new PDResources());
                pDFormXObject.setBBox(rect.PDFBoxRectangle);
                pDFormXObject.setFormType(1);
                OutputStream outputStream = pDFormXObject.getStream().createOutputStream();
                PDFHelper.drawXObject(pDImageXObject, pDFormXObject.getResources(), outputStream, lowerLeftX, lowerLeftY, (float)pDImageXObject.getWidth(), (float)pDImageXObject.getHeight());
                outputStream.close();
                PDAppearanceStream     pDAppearanceStream      = new PDAppearanceStream(pDFormXObject.getCOSObject());
                PDAppearanceDictionary pDAppearanceDictionary1 = new PDAppearanceDictionary(new COSDictionary());
                pDAppearanceDictionary1.setNormalAppearance(pDAppearanceStream);
                pDAppearanceDictionary = pDAppearanceDictionary1;
            }
            return(pDAppearanceDictionary);
        }
Пример #8
0
        internal static PDFRectangle GetPDFRectangle(PageSize pageSize)
        {
            PDFRectangle pDFRectangle;

            switch (pageSize)
            {
            case PageSize.A0:
            {
                pDFRectangle = new PDFRectangle(PDRectangle.A0.getWidth(), PDRectangle.A0.getHeight());
                break;
            }

            case PageSize.A1:
            {
                pDFRectangle = new PDFRectangle(PDRectangle.A1.getWidth(), PDRectangle.A1.getHeight());
                break;
            }

            case PageSize.A2:
            {
                pDFRectangle = new PDFRectangle(PDRectangle.A2.getWidth(), PDRectangle.A2.getHeight());
                break;
            }

            case PageSize.A3:
            {
                pDFRectangle = new PDFRectangle(PDRectangle.A3.getWidth(), PDRectangle.A3.getHeight());
                break;
            }

            case PageSize.A4:
            {
                pDFRectangle = new PDFRectangle(PDRectangle.A4.getWidth(), PDRectangle.A4.getHeight());
                break;
            }

            case PageSize.A5:
            {
                pDFRectangle = new PDFRectangle(PDRectangle.A5.getWidth(), PDRectangle.A5.getHeight());
                break;
            }

            case PageSize.A6:
            {
                pDFRectangle = new PDFRectangle(PDRectangle.A6.getWidth(), PDRectangle.A6.getHeight());
                break;
            }

            case PageSize.Letter:
            {
                pDFRectangle = new PDFRectangle(PDRectangle.LETTER.getWidth(), PDRectangle.LETTER.getHeight());
                break;
            }

            default:
            {
                goto case PageSize.Letter;
            }
            }
            return(pDFRectangle);
        }