use of com.lowagie.text.Document 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();
}
use of com.lowagie.text.Document in project OpenClinica by OpenClinica.
the class DownloadDiscrepancyNote method serializeListToPDF.
public void serializeListToPDF(String content, OutputStream stream) {
ServletOutputStream servletStream = (ServletOutputStream) stream;
Document pdfDoc = new Document();
try {
PdfWriter.getInstance(pdfDoc, servletStream);
pdfDoc.open();
pdfDoc.add(new Paragraph(content));
} catch (DocumentException e) {
e.printStackTrace();
}
pdfDoc.close();
}
use of com.lowagie.text.Document in project boxmaker by rahulbot.
the class Renderer method openDoc.
/**
* Create the document to write to (needed before any rendering can happen).
* @param widthMm the width of the document in millimeters
* @param heightMm the height of the document in millimeters
* @param fileName the name of the file to save
* @throws FileNotFoundException
* @throws DocumentException
*/
private void openDoc(float widthMm, float heightMm, String fileName) throws FileNotFoundException, DocumentException {
float docWidth = widthMm * DPI * INCH_PER_MM;
float docHeight = heightMm * DPI * INCH_PER_MM;
// System.out.println("doc = "+docWidth+" x "+docHeight);
doc = new Document(new Rectangle(docWidth, docHeight));
docPdfWriter = PdfWriter.getInstance(doc, new FileOutputStream(filePath));
String appNameVersion = BoxMakerConstants.APP_NAME + " " + BoxMakerConstants.VERSION;
doc.addAuthor(appNameVersion);
doc.open();
doc.add(new Paragraph("Produced by " + BoxMakerConstants.APP_NAME + " " + BoxMakerConstants.VERSION + "\n" + " on " + new Date() + "\n" + BoxMakerConstants.WEBSITE_URL));
}
use of com.lowagie.text.Document in project spring-framework by spring-projects.
the class AbstractPdfView method renderMergedOutputModel.
@Override
protected final void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception {
// IE workaround: write into byte array first.
ByteArrayOutputStream baos = createTemporaryOutputStream();
// Apply preferences and build metadata.
Document document = newDocument();
PdfWriter writer = newWriter(document, baos);
prepareWriter(model, writer, request);
buildPdfMetadata(model, document, request);
// Build PDF document.
document.open();
buildPdfDocument(model, document, writer, request, response);
document.close();
// Flush to HTTP response.
writeToResponse(response, baos);
}
use of com.lowagie.text.Document in project dhis2-core by dhis2.
the class GridUtils method toPdf.
/**
* Writes a PDF representation of the given list of Grids to the given
* OutputStream.
*/
public static void toPdf(List<Grid> grids, OutputStream out) {
if (hasNonEmptyGrid(grids)) {
Document document = openDocument(out);
for (Grid grid : grids) {
toPdfInternal(grid, document, 40F);
}
addPdfTimestamp(document, false);
closeDocument(document);
}
}
Aggregations