It is rare in IT, but on occasion things do not have to be difficult or obscure :
String aMessage = aContext.source("arg:message",String.class);
ByteArrayOutputStream vBAOS = new ByteArrayOutputStream();
Document vMessageDocument = new Document();
PdfWriter.getInstance(vMessageDocument, vBAOS); vMessageDocument.setPageSize(PageSize.A8.rotate());
vMessageDocument.open();
Font vFont = new Font(FontFamily.COURIER, 14, Font.BOLD, BaseColor.BLACK);
vMessageDocument.add(new Paragraph(aMessage, vFont));
vMessageDocument.close();
ByteArrayRepresentation vBAR = new ByteArrayRepresentation(vBAOS);
INKFResponse vResponse = aContext.createResponseFrom(vBAR);
vResponse.setMimeType("application/pdf");
The relevant imports (in case you're conditioned to see Document as org.w3c.dom.Document) are :
import com.itextpdf.text.BaseColor;
import com.itextpdf.text.Document;
import com.itextpdf.text.Font;
import com.itextpdf.text.Font.FontFamily;
import com.itextpdf.text.PageSize;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.PdfWriter;
iText ® is a Belgian invention, check it out ! NetKernel ® is a British invention, check it out ! Integration of the former in the latter was quick and painless.
Have a great weekend !