Examples of IPdfStructureElement


Examples of com.itextpdf.text.pdf.interfaces.IPdfStructureElement

                        structureElement.setAttribute(PdfName.SPACEAFTER, new PdfNumber(p.getSpacingAfter()));
                    if (Float.compare(p.getFirstLineIndent(), 0f) != 0)
                        structureElement.setAttribute(PdfName.TEXTINDENT, new PdfNumber(p.getFirstLineIndent()));

                    // Setting inheritable attributes
                    IPdfStructureElement parent = getParentStructureInterface();
                    PdfObject obj = parent.getAttribute(PdfName.STARTINDENT);
                    if (obj instanceof PdfNumber) {
                        float startIndent = ((PdfNumber) obj).floatValue();
                        if (Float.compare(startIndent, p.getIndentationLeft()) != 0)
                            structureElement.setAttribute(PdfName.STARTINDENT, new PdfNumber(p.getIndentationLeft()));
                    }
                    else {
                        if (Math.abs(p.getIndentationLeft()) > Float.MIN_VALUE)
                            structureElement.setAttribute(PdfName.STARTINDENT, new PdfNumber(p.getIndentationLeft()));
                    }

                    obj = parent.getAttribute(PdfName.ENDINDENT);
                    if (obj instanceof PdfNumber) {
                        float endIndent = ((PdfNumber) obj).floatValue();
                        if (Float.compare(endIndent, p.getIndentationRight()) != 0)
                            structureElement.setAttribute(PdfName.ENDINDENT, new PdfNumber(p.getIndentationRight()));
                    }
                    else {
                        if (Float.compare(p.getIndentationRight(), 0) != 0)
                            structureElement.setAttribute(PdfName.ENDINDENT, new PdfNumber(p.getIndentationRight()));
                    }

                    PdfName align = null;
                    switch (p.getAlignment()){
                        case Element.ALIGN_LEFT:
                            align = PdfName.START;
                            break;
                        case Element.ALIGN_CENTER:
                            align = PdfName.CENTER;
                            break;
                        case Element.ALIGN_RIGHT:
                            align = PdfName.END;
                            break;
                        case Element.ALIGN_JUSTIFIED:
                            align = PdfName.JUSTIFY;
                            break;
                    }
                    obj = parent.getAttribute(PdfName.TEXTALIGN);
                    if (obj instanceof PdfName) {
                        PdfName textAlign = ((PdfName) obj);
                        if (align != null && !textAlign.equals(align))
                            structureElement.setAttribute(PdfName.TEXTALIGN, align);
                    }
View Full Code Here

Examples of com.itextpdf.text.pdf.interfaces.IPdfStructureElement

                        BaseColor color = (BaseColor)back[0];
                        this.setAttribute(PdfName.BACKGROUNDCOLOR, new PdfArray(new float[] {color.getRed()/255f, color.getGreen()/255f, color.getBlue()/255f}) );
                    }

                    // Setting inheritable attributes
                    IPdfStructureElement parent = (IPdfStructureElement) this.getParent(true);
                    PdfObject obj = parent.getAttribute(PdfName.COLOR);
                    if ((chunk.getFont() != null) && (chunk.getFont().getColor() != null)) {
                        BaseColor c = chunk.getFont().getColor();
                        setColorAttribute(c, obj, PdfName.COLOR);
                    }
                    PdfObject decorThickness  = parent.getAttribute(PdfName.TEXTDECORATIONTHICKNESS);
                    PdfObject decorColor  = parent.getAttribute(PdfName.TEXTDECORATIONCOLOR);
                    if (attr.containsKey(Chunk.UNDERLINE)){
                        Object[][] unders = (Object[][])attr.get(Chunk.UNDERLINE);
                        Object[] arr = unders[unders.length-1];
                        BaseColor color = (BaseColor)arr[0];
                        float [] floats = (float[]) arr[1];
                        float thickness = floats[0];
                        // Setting thickness
                        if (decorThickness instanceof PdfNumber){
                            float t = ((PdfNumber) decorThickness).floatValue();
                            if (Float.compare(thickness,t) != 0){
                                this.setAttribute(PdfName.TEXTDECORATIONTHICKNESS, new PdfNumber(thickness));
                            }
                        }
                        else
                            this.setAttribute(PdfName.TEXTDECORATIONTHICKNESS, new PdfNumber(thickness));

                        // Setting decoration color
                        if (color != null){
                            setColorAttribute(color, decorColor, PdfName.TEXTDECORATIONCOLOR);
                        }
                    }
                   
                    if (attr.containsKey(Chunk.LINEHEIGHT)){
                        float height = (Float)attr.get(Chunk.LINEHEIGHT);
                        PdfObject parentLH = parent.getAttribute(PdfName.LINEHEIGHT);
                        if (parentLH instanceof PdfNumber){
                            float pLH = ((PdfNumber)parentLH).floatValue();
                            if (Float.compare(pLH, height) != 0){
                                this.setAttribute(PdfName.LINEHEIGHT, new PdfNumber(height));
                            }
View Full Code Here

Examples of com.itextpdf.text.pdf.interfaces.IPdfStructureElement

                this.setAttribute(PdfName.SPACEBEFORE, new PdfNumber(paragraph.getSpacingBefore()));
            if (Float.compare(paragraph.getSpacingAfter(), 0f) != 0)
                this.setAttribute(PdfName.SPACEAFTER, new PdfNumber(paragraph.getSpacingAfter()));

            // Setting inheritable attributes
            IPdfStructureElement parent = (IPdfStructureElement) this.getParent(true);
            PdfObject obj = parent.getAttribute(PdfName.COLOR);
            if ((paragraph.getFont() != null) && (paragraph.getFont().getColor() != null)) {
                BaseColor c = paragraph.getFont().getColor();
                setColorAttribute(c, obj, PdfName.COLOR);
            }
            obj = parent.getAttribute(PdfName.TEXTINDENT);
            if (Float.compare(paragraph.getFirstLineIndent(), 0f) != 0) {
                boolean writeIndent = true;
                if (obj instanceof PdfNumber){
                    if (Float.compare(((PdfNumber)obj).floatValue(), new Float(paragraph.getFirstLineIndent())) == 0)
                        writeIndent = false;
                }
                if (writeIndent)
                    this.setAttribute(PdfName.TEXTINDENT, new PdfNumber(paragraph.getFirstLineIndent()));
            }
            obj = parent.getAttribute(PdfName.STARTINDENT);
            if (obj instanceof PdfNumber) {
                float startIndent = ((PdfNumber) obj).floatValue();
                if (Float.compare(startIndent, paragraph.getIndentationLeft()) != 0)
                    this.setAttribute(PdfName.STARTINDENT, new PdfNumber(paragraph.getIndentationLeft()));
            } else {
                if (Math.abs(paragraph.getIndentationLeft()) > Float.MIN_VALUE)
                    this.setAttribute(PdfName.STARTINDENT, new PdfNumber(paragraph.getIndentationLeft()));
            }

            obj = parent.getAttribute(PdfName.ENDINDENT);
            if (obj instanceof PdfNumber) {
                float endIndent = ((PdfNumber) obj).floatValue();
                if (Float.compare(endIndent, paragraph.getIndentationRight()) != 0)
                    this.setAttribute(PdfName.ENDINDENT, new PdfNumber(paragraph.getIndentationRight()));
            } else {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.