use of com.lowagie.text.Paragraph in project dhis2-core by dhis2.
the class PDFUtils method getCell.
/**
* Creates a cell.
*
* @param text The text to include in the cell.
* @param colspan The column span of the cell.
* @param font The font of the cell text.
* @param horizontalAlign The vertical alignment of the text in the cell.
* @return A PdfCell.
*/
public static PdfPCell getCell(String text, int colspan, Font font, int horizontalAlign) {
Paragraph paragraph = new Paragraph(text, font);
PdfPCell cell = new PdfPCell(paragraph);
cell.setColspan(colspan);
cell.setBorder(0);
cell.setMinimumHeight(15);
cell.setHorizontalAlignment(horizontalAlign);
return cell;
}
use of com.lowagie.text.Paragraph in project OpenClinica by OpenClinica.
the class DownloadDiscrepancyNote method serializeThreadsToPDF.
public void serializeThreadsToPDF(List<DiscrepancyNoteThread> listOfThreads, OutputStream stream, String studyIdentifier) {
ServletOutputStream servletStream = (ServletOutputStream) stream;
Document pdfDoc = new Document();
try {
PdfWriter.getInstance(pdfDoc, servletStream);
pdfDoc.open();
// Create header for the study identifier or name
if (studyIdentifier != null) {
HeaderFooter header = new HeaderFooter(new Phrase("Study Identifier: " + studyIdentifier + " pg."), true);
header.setAlignment(Element.ALIGN_CENTER);
Paragraph para = new Paragraph("Study Identifier: " + studyIdentifier, new Font(Font.HELVETICA, 18, Font.BOLD, new Color(0, 0, 0)));
para.setAlignment(Element.ALIGN_CENTER);
pdfDoc.setHeader(header);
pdfDoc.add(para);
}
for (DiscrepancyNoteThread discNoteThread : listOfThreads) {
pdfDoc.add(this.createTableThreadHeader(discNoteThread));
// Just the parent of the thread? discNoteThread.getLinkedNoteList()
for (DiscrepancyNoteBean discNoteBean : discNoteThread.getLinkedNoteList()) {
// DiscrepancyNoteBean discNoteBean = discNoteThread.getLinkedNoteList().getFirst();
if (discNoteBean.getParentDnId() > 0) {
pdfDoc.add(this.createTableFromBean(discNoteBean));
pdfDoc.add(new Paragraph("\n"));
}
}
}
// pdfDoc.add(new Paragraph(content));
} catch (DocumentException e) {
e.printStackTrace();
}
pdfDoc.close();
}
use of com.lowagie.text.Paragraph in project OpenClinica by OpenClinica.
the class DownloadDiscrepancyNote method createThreadHeader.
private Paragraph createThreadHeader(DiscrepancyNoteThread discNoteThread) {
String content = "";
int size = discNoteThread.getLinkedNoteList().size();
int counter = 0;
for (DiscrepancyNoteBean discBean : discNoteThread.getLinkedNoteList()) {
++counter;
content += discBean.getEntityName() + "; " + RESOLUTION_STATUS_MAP.get(discBean.getResolutionStatusId());
if (size > 1 && counter != size) {
content += " --->";
}
}
Paragraph para = new Paragraph(content, new Font(Font.HELVETICA, 16, Font.BOLD, new Color(0, 0, 0)));
return para;
}
use of com.lowagie.text.Paragraph in project OpenClinica by OpenClinica.
the class DownloadDiscrepancyNote method serializeListToPDF.
public void serializeListToPDF(List<DiscrepancyNoteBean> listOfBeans, OutputStream stream, String studyIdentifier) {
ServletOutputStream servletStream = (ServletOutputStream) stream;
Document pdfDoc = new Document();
try {
PdfWriter.getInstance(pdfDoc, servletStream);
pdfDoc.open();
// Create header for the study identifier or name
if (studyIdentifier != null) {
HeaderFooter header = new HeaderFooter(new Phrase("Study Identifier: " + studyIdentifier + " pg."), true);
header.setAlignment(Element.ALIGN_CENTER);
Paragraph para = new Paragraph("Study Identifier: " + studyIdentifier, new Font(Font.HELVETICA, 18, Font.BOLD, new Color(0, 0, 0)));
para.setAlignment(Element.ALIGN_CENTER);
pdfDoc.setHeader(header);
pdfDoc.add(para);
}
for (DiscrepancyNoteBean discNoteBean : listOfBeans) {
pdfDoc.add(this.createTableFromBean(discNoteBean));
pdfDoc.add(new Paragraph("\n"));
}
// pdfDoc.add(new Paragraph(content));
} catch (DocumentException e) {
e.printStackTrace();
}
pdfDoc.close();
}
use of com.lowagie.text.Paragraph in project OpenClinica by OpenClinica.
the class DownloadDiscrepancyNote method serializeToPDF.
private void serializeToPDF(EntityBean bean, OutputStream stream) {
ServletOutputStream servletStream = (ServletOutputStream) stream;
DiscrepancyNoteBean discNBean = (DiscrepancyNoteBean) bean;
StringBuilder writer = new StringBuilder();
writer.append(serializeToString(discNBean, false, 0));
Document pdfDoc = new Document();
try {
PdfWriter.getInstance(pdfDoc, servletStream);
pdfDoc.open();
pdfDoc.add(new Paragraph(writer.toString()));
} catch (DocumentException e) {
e.printStackTrace();
}
pdfDoc.close();
}
Aggregations