use of com.lowagie.text.pdf.PdfPageEventHelper in project mes by qcadoo.
the class DispositionOrderPdfService method buildPdfContent.
@Override
protected void buildPdfContent(PdfWriter writer, Document document, Entity entity, Locale locale) throws DocumentException {
Entity documentPositionParameters = parameterService.getParameter().getBelongsToField("documentPositionParameters");
acceptanceOfDocumentBeforePrinting = documentPositionParameters.getBooleanField("acceptanceOfDocumentBeforePrinting");
class DispositionOrderHeader extends PdfPageEventHelper {
@Override
public void onEndPage(PdfWriter writer, Document document) {
try {
PdfContentByte cb = writer.getDirectContent();
cb.saveState();
float textBase = document.top();
cb.setColorFill(ColorUtils.getLightColor());
cb.setColorStroke(ColorUtils.getLightColor());
cb.beginText();
cb.setFontAndSize(FontUtils.getDejavu(), 7);
cb.setTextMatrix(document.left(), textBase + 20);
cb.showText((translationService.translate(L_PZ, locale) + ": " + DocumentDataProvider.pzLocation(entity)));
cb.endText();
cb.stroke();
cb.restoreState();
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
}
writer.setPageEvent(new DispositionOrderHeader());
String documentHeader = getDocumentHeader(entity, locale);
pdfHelper.addDocumentHeader(document, "", documentHeader, "", new Date());
addHeaderTable(document, entity, locale);
addPositionsTable(document, entity, locale);
addPlaceForComments(document, locale);
addPlaceForSignature(document, locale);
}
Aggregations