Package com.lowagie.text

Examples of com.lowagie.text.LwgRectangle


    public static void main(String[] args) {
       
        System.out.println("StudentCard as a form");
       
        // step 1: creation of a document-object
        LwgRectangle rect = new LwgRectangle(243, 153);
        rect.setBackgroundColor(new Color(0xFF, 0xFF, 0xCC));
        LwgDocument document = new LwgDocument(rect, 10, 10, 10, 10);
       
        try {
           
            // step 2:
            PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("studentcardform.pdf"));
           
            // step 3: we open the document
            document.open();
           
            // step 4:
            LwgFont font = FontFactory.getFont(FontFactory.HELVETICA, 14, LwgFont.BOLD, Color.BLUE);
            Paragraph p = new Paragraph("Ghent University", font);
            p.setAlignment(LwgElement.ALIGN_CENTER);
            document.add(p);
            LwgFont f = FontFactory.getFont(FontFactory.HELVETICA, 8);
            LwgPdfPTable outertable = new LwgPdfPTable(3);
            outertable.setTotalWidth(200);
            outertable.getDefaultCell().setBorder(LwgRectangle.NO_BORDER);
            float[] outer = { 60, 25, 15 };
            outertable.setWidths(outer);
            LwgPdfPTable innertable = new LwgPdfPTable(2);
            float[] inner = {35, 65};
            innertable.setWidths(inner);
            LwgPdfPCell cell;
            TextField text;
            innertable.add(new Paragraph("name:", f));
            cell = new LwgPdfPCell();
            text = new TextField(writer, new LwgRectangle(0, 0), "name");
            text.setOptions(TextField.MULTILINE);
            text.setFontSize(8);
            PdfFormField name = text.getTextField();
            cell.setCellEvent(new StudentCardForm(name));
            innertable.add(cell);
            innertable.add(new Paragraph("date of birth:", f));
            cell = new LwgPdfPCell();
            text = new TextField(writer, new LwgRectangle(0, 0), "birthday");
            text.setOptions(TextField.MULTILINE);
            text.setFontSize(8);
            PdfFormField birthdate = text.getTextField();
            cell.setCellEvent(new StudentCardForm(birthdate));
            innertable.add(cell);
            innertable.add(new Paragraph("Study Program:", f));
            cell = new LwgPdfPCell();
            text = new TextField(writer, new LwgRectangle(0, 0), "studyprogram");
            text.setOptions(TextField.MULTILINE);
            text.setFontSize(8);
            PdfFormField studyprogram = text.getTextField();
            studyprogram.setFieldName("studyprogram");
            cell.setCellEvent(new StudentCardForm(studyprogram));
            innertable.add(cell);
            innertable.add(new Paragraph("option:", f));
            cell = new LwgPdfPCell();
            text = new TextField(writer, new LwgRectangle(0, 0), "option");
            text.setOptions(TextField.MULTILINE);
            text.setFontSize(8);
            PdfFormField option = text.getTextField();
            option.setFieldName("option");
            cell.setCellEvent(new StudentCardForm(option));
View Full Code Here


     * Method that generates the actual PDF file.
     */
    public void generatePdf() {  
       
        // step 1: creation of a document-object
        LwgRectangle pageSize = new LwgRectangle(780, 525);
        if (backgroundcolor != null) pageSize.setBackgroundColor(backgroundcolor);
        LwgDocument document = new LwgDocument(pageSize);
       
        try {
            // step 2:
            // we create a writer that listens to the document
View Full Code Here

            // we create a reader for a certain document
            PdfReader reader = new PdfReader("ChapterSection.pdf");
            // we retrieve the total number of pages
            int n = reader.getNumberOfPages();
            // we retrieve the size of the first page
            LwgRectangle psize = reader.getPageSize(1);
            float width = psize.getHeight();
            float height = psize.getWidth();
           
            // step 1: creation of a document-object
            LwgDocument document = new LwgDocument(new LwgRectangle(width, height));
            // step 2: we create a writer that listens to the document
            PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("2on1.pdf"));
            // step 3: we open the document
            document.open();
            // step 4: we add content
View Full Code Here

           
            // step 3: we open the document
            document.open();
           
            // step 4:
            TextField tf = new TextField(writer, new LwgRectangle(100, 300, 100 + 100, 300 + 50), "Dickens");
            tf.setBackgroundColor(Color.RED);
            tf.setBorderColor(Color.BLUE);
            tf.setBorderWidth(2);
            tf.setBorderStyle(PdfBorderDictionary.STYLE_BEVELED);
            tf.setText("It was the best of times, it was the worst of times, it was the age of wisdom...");
            tf.setAlignment(LwgElement.ALIGN_CENTER);
            tf.setOptions(TextField.MULTILINE | TextField.REQUIRED);
            tf.setRotation(90);
            PdfFormField field = tf.getTextField();
            writer.addAnnotation(field);
           
            tf = new TextField(writer, new LwgRectangle(250, 300, 250 + 100, 300 + 20), "Combos");
            tf.setBackgroundColor(Color.RED);
            tf.setBorderColor(Color.BLUE);
            tf.setBorderWidth(2);
            tf.setFontSize(10);
            tf.setBorderStyle(PdfBorderDictionary.STYLE_INSET);
            tf.setVisibility(TextField.VISIBLE_BUT_DOES_NOT_PRINT);
            tf.setChoices(new String[]{"First", "Second"});
            tf.setChoiceExports(new String[]{"value1", "value2"});
            tf.setRotation(90);
            field = tf.getComboField();
            writer.addAnnotation(field);
           
            tf = new TextField(writer, new LwgRectangle(400, 300, 400 + 100, 300 + 50), "Lists");
            tf.setBackgroundColor(Color.YELLOW);
            tf.setBorderColor(Color.RED);
            tf.setBorderWidth(2);
            tf.setBorderStyle(PdfBorderDictionary.STYLE_DASHED);
            tf.setFontSize(10);
View Full Code Here

            tpOn.lineTo(19, 19);
            tpOn.moveTo(1, 19);
            tpOn.lineTo(19, 1);
            tpOn.stroke();
           
            field.setWidget(new LwgRectangle(100, 700, 120, 720), PdfAnnotation.HIGHLIGHT_INVERT);
            field.setFieldName("Urgent");
            field.setValueAsName("Off");
            field.setAppearanceState("Off");
            field.setAppearance(PdfAnnotation.APPEARANCE_NORMAL, "Off", tpOff);
            field.setAppearance(PdfAnnotation.APPEARANCE_NORMAL, "On", tpOn);
View Full Code Here

                width = x * (4 + 5 * 7 + 4 * 2);
                break;
            default:
                throw new RuntimeException(MessageLocalization.getComposedMessage("invalid.code.type"));
        }
        return new LwgRectangle(width, height);
    }
View Full Code Here

     * @param barColor the color of the bars. It can be <CODE>null</CODE>
     * @param textColor the color of the text. It can be <CODE>null</CODE>
     * @return the dimensions the barcode occupies
     */   
    public LwgRectangle placeBarcode(PdfContentByte cb, Color barColor, Color textColor) {
        LwgRectangle rect = getBarcodeSize();
        float barStartX = 0;
        float barStartY = 0;
        float textStartY = 0;
        if (font != null) {
            if (baseline <= 0)
View Full Code Here

            // step 4:
            PdfContentByte cb = writer.getDirectContent();
            cb.moveTo(0, 0);
            String options[] = {"Red", "Green", "Blue"};
            PdfFormField field = PdfFormField.createCombo(writer, true, options, 0);
            field.setWidget(new LwgRectangle(100, 700, 180, 720), PdfAnnotation.HIGHLIGHT_INVERT);
            field.setFieldName("ACombo");
            field.setValueAsString("Red");
            writer.addAnnotation(field);
           
        }
View Full Code Here

            down.fill();           
            pushbutton.setFieldName("PushMe");
            pushbutton.setAppearance(PdfAnnotation.APPEARANCE_NORMAL, normal);
            pushbutton.setAppearance(PdfAnnotation.APPEARANCE_ROLLOVER, rollover);
            pushbutton.setAppearance(PdfAnnotation.APPEARANCE_DOWN, down);
            pushbutton.setWidget(new LwgRectangle(100, 700, 200, 750), PdfAnnotation.HIGHLIGHT_PUSH);
            writer.addAnnotation(pushbutton);
           
        }
        catch(DocumentException de) {
            System.err.println(de.getMessage());
View Full Code Here

     * @param  bottom  the bottom position
     * @return  a <CODE>LwgRectangle</CODE>
     */

    public LwgRectangle rectangle(float top, float bottom) {
        LwgRectangle tmp = new LwgRectangle(getLeft(), getBottom(), getRight(), getTop());
        tmp.cloneNonPositionParameters(this);
        if (getTop() > top) {
            tmp.setTop(top);
            tmp.setBorder(_border - (_border & TOP));
        }
        if (getBottom() < bottom) {
            tmp.setBottom(bottom);
            tmp.setBorder(_border - (_border & BOTTOM));
        }
        return tmp;
    }
View Full Code Here

TOP

Related Classes of com.lowagie.text.LwgRectangle

Copyright © 2018 www.massapicom. 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.