Pregunta

¿Alguien sabe, cómo, en ITEXT, agregar texto multilínea en el cuadro delimitador (con coordenadas especificadas)?

Lo intenté

cb.showTextAligned(
    PdfContentByte.ALIGN_LEFT,
    text,
    bounds.getLeft(),
    TOTAL_HEIGHT-bounds.getTop(),
    0 );

Pero no admite nuevas líneas. También probé

PdfContentByte cb = writer.getDirectContent();
cb.moveText(300,400);
document.add(new Paragraph("TEST paragraph\nNewline"));

Esto admite nuevas líneas, pero no reacciona a Movetext, por lo que no sé cómo ponerlo en una posición dada o mejor: el cuadro delimitador.

Sospecho que los fragmentos o PDFTemplate o tal vez la mesa podría ayudar, pero no sé (todavía) cómo armarlo. Tia por ayuda.

¿Fue útil?

Solución

Prueba esto:

ColumnText ct = new ColumnText(cb);
Phrase myText = new Phrase("TEST paragraph\nAfter Newline");
ct.setSimpleColumn(myText, 34, 750, 580, 317, 15, Element.ALIGN_LEFT);
ct.go();

Los parámetros de setSimpleColumn son:

  1. la frase
  2. la esquina X inferior izquierda (izquierda)
  3. la esquina inferior izquierda (abajo)
  4. la esquina X superior derecha (derecha)
  5. la esquina superior y la parte superior (arriba)
  6. Altura de línea (líder)
  7. alineación.

Otros consejos

ColumnText ct = new ColumnText(content);
ct.setSimpleColumn(
    new Phrase("Very Long Text"),
    left=20, bottom=100, right=500, top=500,
    fontSize=18, Element.ALIGN_JUSTIFIED);
ct.go(); // for drawing
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top