- } else {
- // PDF
- // TODO: multiline support
-// try {
- AffineTransform at = g.getTransform();
- float height = writer.getPageSize().getHeight();
- Rectangle2D rr = textClip;
- // Point2D pt1 = new Point2D.Double(rr.getX(), rr.getY()+rr.getHeight());
- // Point2D pt2 = new Point2D.Double(rr.getX()+rr.getWidth(), rr.getY());
- Point2D pt1 = new Point2D.Double(0, 0);
- Point2D pt2 = new Point2D.Double(47.f/*+rr.getWidth()*/, -rr.getHeight());
- pt1 = at.transform(pt1, pt1);
- pt2 = at.transform(pt2, pt2);
- Rectangle rectangle = new Rectangle(
- (float) pt1.getX(),
- height-(float) pt1.getY(),
- (float) pt2.getX(),
- height-(float) pt2.getY());
-
- FontMapper mapper = (FontMapper) g.getRenderingHint(G2DPDFRenderingHints.KEY_PDF_FONTMAPPER);
-// FontMetrics fm = g.getFontMetrics(font);
-
- // TODO Oikea leveys
- // TODO Uniikki nimi
- /*
- PdfFormField field = PdfFormField.createTextField(writer, false, false, 20);
- field.setFieldName(this.getId().toString());
- field.setWidget(rectangle, PdfAnnotation.HIGHLIGHT_NONE);
- field.setQuadding(PdfFormField.Q_RIGHT);
- field.setFieldFlags(PdfFormField.FF_READ_ONLY);
- field.setRotate(90);
- writer.addAnnotation(field);
- */
-
-
- // Signature Field
- /*
- if (text==null) {
- PdfFormField field = PdfFormField.createSignature(writer);
- field.setWidget(rectangle, PdfAnnotation.HIGHLIGHT_NONE);
- field.setFieldName(fieldName);
- field.setQuadding(PdfFormField.Q_LEFT);
- field.setFlags(PdfAnnotation.FLAGS_PRINT);
- //field.setFieldFlags(PdfFormField.FF_READ_ONLY)
- field.setFieldFlags(PdfFormField.FF_EDIT);
- field.setPage();
- field.setMKBackgroundColor( backgroundColor!=null?Color.WHITE:backgroundColor );
- PdfAppearance tp = PdfAppearance.createAppearance(writer, 72, 48);
- tp.rectangle(rectangle);
- tp.stroke();
- field.setAppearance(PdfAnnotation.APPEARANCE_NORMAL, tp);
- writer.addAnnotation(field);
- } else */
- {
- // Text Field
- try {
- TextField textField = new TextField(writer, rectangle, fieldName);
- textField.setFieldName(fieldName);
- textField.setFont(mapper.awtToPdf(font));
- textField.setBorderStyle(0);
- //textField.setAlignment(Element.ALIGN_LEFT);
- textField.setAlignment(Element.ALIGN_BOTTOM);
- textField.setRotation(90);
- textField.setOptions(TextField.EDIT|TextField.DO_NOT_SPELL_CHECK);
- if ( text!=null ) {
- textField.setText(text);
- }
- if ( color!=null ) {
- textField.setTextColor(color);
- }
- textField.setBackgroundColor( backgroundColor!=null?Color.WHITE:backgroundColor );
- PdfFormField field = textField.getTextField();
- writer.addAnnotation(field);
- } catch (IOException e) {
- e.printStackTrace();
- } catch (DocumentException e) {
- e.printStackTrace();
- }
- }
-
-// } catch (IOException e) {
-// // TODO Auto-generated catch block
-// e.printStackTrace();
-// } catch (DocumentException e) {
-// // TODO Auto-generated catch block
-// e.printStackTrace();
-// }