use of com.lowagie.text.Paragraph in project mdw-designer by CenturyLinkCloud.
the class ExportHelper method printGraphPdf.
private void printGraphPdf(GraphCommon graph, Chapter chapter) throws Exception {
Section section;
String tmp;
if (graph instanceof SubGraph) {
SubGraph subgraph = (SubGraph) graph;
String id = subgraph.getDisplayId(nodeIdType);
if (id == null || id.length() == 0)
id = subgraph.getId().toString();
tmp = "Subprocess " + id + ": \"" + subgraph.getName().replace('\n', ' ') + "\"";
} else {
tmp = "Process Description";
}
Paragraph sTitle = new Paragraph(tmp, sectionFont);
sTitle.setSpacingBefore(10);
section = chapter.addSection(sTitle, options.contains(SECTION_NUMBER) ? 2 : 0);
String summary = (graph instanceof SubGraph) ? ((SubGraph) graph).getProcessVO().getProcessDescription() : ((Graph) graph).getProcessVO().getProcessDescription();
if (summary != null && summary.length() > 0)
printBoldParagraphsPdf(section, summary);
if (options.contains(DOCUMENTATION)) {
String detail = graph.getProcessVO().getAttribute(WorkAttributeConstant.DOCUMENTATION);
if (detail != null && detail.length() > 0) {
printHtmlParagraphsPdf(section, detail, options.contains(SECTION_NUMBER) ? 2 : 0);
}
}
if (options.contains(ATTRIBUTES) && !graph.getProcessVO().getAttributes().isEmpty() && graph instanceof SubGraph) {
printAttributesPdf(section, graph.getProcessVO().getAttributes(), options.contains(SECTION_NUMBER) ? 2 : 0);
}
}
use of com.lowagie.text.Paragraph in project mdw-designer by CenturyLinkCloud.
the class ExportHelper method printAttributesPdf.
private void printAttributesPdf(Section section, List<AttributeVO> attrs, int parentLevel) {
Paragraph sTitle = new Paragraph("Activity Attributes", subSectionFont);
Section subsection = section.addSection(sTitle, parentLevel == 0 ? 0 : (parentLevel + 1));
com.lowagie.text.List list = new com.lowagie.text.List(false, false, 20.0f);
for (AttributeVO attr : attrs) {
if (excludeAttribute(attr.getAttributeName(), attr.getAttributeValue()))
continue;
Phrase phrase = new Phrase();
phrase.add(new Chunk(attr.getAttributeName(), fixedWidthFont));
String v = attr.getAttributeValue();
if (v == null)
v = "";
phrase.add(new Chunk(": " + v, normalFont));
list.add(new ListItem(phrase));
}
subsection.add(list);
}
use of com.lowagie.text.Paragraph in project ofbiz-framework by apache.
the class PdfSurveyServices method buildPdfFromSurveyResponse.
/**
*/
public static Map<String, Object> buildPdfFromSurveyResponse(DispatchContext dctx, Map<String, ? extends Object> rcontext) {
Map<String, Object> context = UtilMisc.makeMapWritable(rcontext);
Delegator delegator = dctx.getDelegator();
Map<String, Object> results = ServiceUtil.returnSuccess();
String surveyResponseId = (String) context.get("surveyResponseId");
String contentId = (String) context.get("contentId");
String surveyId = null;
Document document = new Document();
try {
if (UtilValidate.isNotEmpty(surveyResponseId)) {
GenericValue surveyResponse = EntityQuery.use(delegator).from("SurveyResponse").where("surveyResponseId", surveyResponseId).queryOne();
if (surveyResponse != null) {
surveyId = surveyResponse.getString("surveyId");
}
}
if (UtilValidate.isNotEmpty(surveyId) && UtilValidate.isEmpty(contentId)) {
GenericValue survey = EntityQuery.use(delegator).from("Survey").where("surveyId", surveyId).queryOne();
if (survey != null) {
String acroFormContentId = survey.getString("acroFormContentId");
if (UtilValidate.isNotEmpty(acroFormContentId)) {
context.put("contentId", acroFormContentId);
}
}
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PdfWriter.getInstance(document, baos);
List<GenericValue> responses = EntityQuery.use(delegator).from("SurveyResponseAnswer").where("surveyResponseId", surveyResponseId).queryList();
for (GenericValue surveyResponseAnswer : responses) {
String value = null;
String surveyQuestionId = (String) surveyResponseAnswer.get("surveyQuestionId");
GenericValue surveyQuestion = EntityQuery.use(delegator).from("SurveyQuestion").where("surveyQuestionId", surveyQuestionId).queryOne();
String questionType = surveyQuestion.getString("surveyQuestionTypeId");
// DEJ20060227 this isn't used, if needed in the future should get from SurveyQuestionAppl.externalFieldRef String fieldName = surveyQuestion.getString("description");
if ("OPTION".equals(questionType)) {
value = surveyResponseAnswer.getString("surveyOptionSeqId");
} else if ("BOOLEAN".equals(questionType)) {
value = surveyResponseAnswer.getString("booleanResponse");
} else if ("NUMBER_LONG".equals(questionType) || "NUMBER_CURRENCY".equals(questionType) || "NUMBER_FLOAT".equals(questionType)) {
Double num = surveyResponseAnswer.getDouble("numericResponse");
if (num != null) {
value = num.toString();
}
} else if ("SEPERATOR_LINE".equals(questionType) || "SEPERATOR_TEXT".equals(questionType)) {
// not really a question; ingore completely
} else {
value = surveyResponseAnswer.getString("textResponse");
}
Chunk chunk = new Chunk(surveyQuestion.getString("question") + ": " + value);
Paragraph p = new Paragraph(chunk);
document.add(p);
}
ByteBuffer outByteBuffer = ByteBuffer.wrap(baos.toByteArray());
results.put("outByteBuffer", outByteBuffer);
} catch (GenericEntityException | DocumentException e) {
Debug.logError(e, module);
results = ServiceUtil.returnError(e.getMessage());
}
return results;
}
use of com.lowagie.text.Paragraph 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.Paragraph in project dhis2-core by dhis2.
the class DefaultPdfDataEntryFormService method setDataSet_DocumentTopSection.
private void setDataSet_DocumentTopSection(Document document, DataSet dataSet) throws DocumentException {
document.add(new Paragraph(dataSet.getDisplayName(), pdfFormFontSettings.getFont(PdfFormFontSettings.FONTTYPE_TITLE)));
document.add(new Paragraph(dataSet.getDisplayDescription(), pdfFormFontSettings.getFont(PdfFormFontSettings.FONTTYPE_DESCRIPTION)));
}
Aggregations