use of org.compiere.report.MReportColumn in project adempiere by adempiere.
the class SmjPdfReport method generate.
/**
* genera el PDF en un ByteArrayOutputStream ** Generate PDF Report into
* ByteArrayOutputStream
*
* @return ByteArrayOutputStream
*/
public ByteArrayOutputStream generate(LinkedList<ReportTO> dataReport, String nameTrx, String[] generalTitle, String clientName, String clientNIT, String periodName, String currencyName, MReportColumn[] m_columns, String codeFont, String city, Integer logoId) {
baosPDF = new ByteArrayOutputStream();
data = dataReport;
String[] fontPar = codeFont.split("-");
Integer lFont = Integer.parseInt(fontPar[2]);
titleFont = FontFactory.getFont(fontPar[0], lFont + 5, Font.BOLDITALIC);
titleTableFont = FontFactory.getFont(fontPar[0], lFont + 2, Font.BOLDITALIC);
catFont = FontFactory.getFont(fontPar[0], lFont + 2, Font.BOLD);
subFont = FontFactory.getFont(fontPar[0], lFont, Font.NORMAL);
try {
// izq-der-arrib
document = new Document(PageSize.LETTER, 20, 20, 20, 40);
writer = PdfWriter.getInstance(document, baosPDF);
document.open();
// metadata del documento
document.addTitle(generalTitle[0]);
document.addAuthor("SmartJSP S.A.S.");
document.addCreator("SmartJSP S.A.S.");
onOpenDocument(writer, document);
onEndPage(writer, document);
// //////////////////////////////////////////////////////////////////////////////////////
// agrega el logo
// add logo
java.awt.Image img;
if (logoId > 0) {
MImage mimage = MImage.get(Env.getCtx(), logoId);
byte[] imageData = mimage.getData();
img = Toolkit.getDefaultToolkit().createImage(imageData);
} else {
// 48x15
img = org.compiere.Adempiere.getImageLogoSmall(true);
}
com.lowagie.text.Image logo = com.lowagie.text.Image.getInstance(img, null);
logo.scaleToFit(100, 30);
document.add(logo);
// Titulo General - general Title
Paragraph genTitle = new Paragraph(dataNull(generalTitle[0]).toUpperCase(), titleFont);
genTitle.setAlignment(Paragraph.ALIGN_CENTER);
document.add(genTitle);
// empresa - Company
Paragraph clitName = new Paragraph(dataNull(clientName).toUpperCase(), titleFont);
clitName.setAlignment(Paragraph.ALIGN_CENTER);
document.add(clitName);
// Ciudad - City
Paragraph cliCity = new Paragraph(dataNull(city).toUpperCase(), titleFont);
cliCity.setAlignment(Paragraph.ALIGN_CENTER);
document.add(cliCity);
// NIT
Paragraph cliNIT = new Paragraph(dataNull(clientNIT).toUpperCase(), titleFont);
cliNIT.setAlignment(Paragraph.ALIGN_CENTER);
document.add(cliNIT);
// periodo - Period
String pn = "";
if (generalTitle[1] != null && generalTitle[1].length() > 0) {
pn = generalTitle[1] + " " + periodName;
} else {
pn = periodName;
}
if (generalTitle[2] != null && generalTitle[2].length() > 0) {
pn = pn + " " + generalTitle[2];
}
Paragraph perName = new Paragraph(dataNull(pn).toUpperCase(), titleTableFont);
perName.setAlignment(Paragraph.ALIGN_CENTER);
document.add(perName);
// tipo moneda - currency
Paragraph currency = new Paragraph(dataNull(currencyName), titleTableFont);
currency.setAlignment(Paragraph.ALIGN_CENTER);
addEmptyLine(currency, 2);
document.add(currency);
cols = m_columns.length + 2;
float[] columnWidths = new float[cols];
columnWidths[0] = 1f;
columnWidths[1] = 3f;
for (int i = 2; i < cols; i++) {
columnWidths[i] = 1f;
}
table = new PdfPTable(columnWidths);
// //Titulos de la tabla - Table titles
// Nombre - name
PdfPCell cellTitle = new PdfPCell(new Paragraph(Msg.translate(Env.getCtx(), "name").toUpperCase(), catFont));
cellTitle.setHorizontalAlignment(Paragraph.ALIGN_RIGHT);
cellTitle.setBackgroundColor(Color.LIGHT_GRAY);
table.addCell(cellTitle);
// Desripcion - description
cellTitle = new PdfPCell(new Paragraph(Msg.translate(Env.getCtx(), "description").toUpperCase(), catFont));
cellTitle.setHorizontalAlignment(Paragraph.ALIGN_LEFT);
cellTitle.setBackgroundColor(Color.LIGHT_GRAY);
table.addCell(cellTitle);
// columnas de valores - Value Columns
for (MReportColumn mcol : m_columns) {
String colName = mcol.getName();
cellTitle = new PdfPCell(new Paragraph(colName.toUpperCase(), catFont));
cellTitle.setHorizontalAlignment(Paragraph.ALIGN_RIGHT);
cellTitle.setBackgroundColor(Color.LIGHT_GRAY);
table.addCell(cellTitle);
}
//for columnas
// TABLA DEL REPORTE - REPORT TABLE
reportTable();
document.add(table);
// funciones que ponen el pie del porte - put footer
onEndPage(writer, document);
onCloseDocument(writer, document);
document.close();
} catch (Exception e) {
System.out.println("SMpdfReport(generar)ERROR:: al crear el documento PDF");
System.out.println(e.getMessage());
e.printStackTrace();
}
return baosPDF;
}
use of org.compiere.report.MReportColumn in project adempiere by adempiere.
the class ReportColumnSet_Copy method doIt.
// prepare
/**
* Perform process.
* @return Message
* @throws Exception
*/
protected String doIt() throws Exception {
int to_ID = super.getRecord_ID();
log.info("From PA_ReportColumnSet_ID=" + m_PA_ReportColumnSet_ID + ", To=" + to_ID);
if (to_ID < 1)
throw new Exception(MESSAGE_SaveErrorRowNotFound);
//
MReportColumnSet to = new MReportColumnSet(getCtx(), to_ID, get_TrxName());
MReportColumnSet rcSet = new MReportColumnSet(getCtx(), m_PA_ReportColumnSet_ID, get_TrxName());
MReportColumn[] rcs = rcSet.getColumns();
for (int i = 0; i < rcs.length; i++) {
MReportColumn rc = MReportColumn.copy(getCtx(), to.getAD_Client_ID(), to.getAD_Org_ID(), to_ID, rcs[i], get_TrxName());
rc.saveEx();
}
// Oper 1/2 were set to Null !
return "@Copied@=" + rcs.length;
}
use of org.compiere.report.MReportColumn in project adempiere by adempiere.
the class SmjXlsReport method titleTable.
// generate
/**
* Crea la fila de titulos - create title row
* @param wb
* @param hs
* @param fila
* @param colsName
*/
private void titleTable(HSSFWorkbook book, HSSFSheet sheet, int fila, MReportColumn[] m_columns) {
short col = 0;
// crea fuente - create font
HSSFFont font = book.createFont();
font.setFontHeightInPoints((short) 13);
font.setFontName(HSSFFont.FONT_ARIAL);
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
// font.setColor(HSSFColor.BLUE.index);
// estio celda - cell style
HSSFCellStyle cellStyle = book.createCellStyle();
cellStyle.setWrapText(true);
cellStyle.setAlignment(HSSFCellStyle.ALIGN_JUSTIFY);
cellStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_TOP);
// cellStyle.setFillPattern(HSSFCellStyle.SPARSE_DOTS);
// cellStyle.setFillBackgroundColor(HSSFColor.GREY_40_PERCENT.index);
cellStyle.setFont(font);
// //Titulos de la tabla - Table titles
HSSFRow row = sheet.createRow(fila);
// Nombre - name
HSSFRichTextString text = new HSSFRichTextString(Msg.translate(Env.getCtx(), "name").toUpperCase());
HSSFCell cell = row.createCell(col++);
cell.setCellStyle(cellStyle);
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
cell.setCellValue(text);
// Desripcion - description
text = new HSSFRichTextString(Msg.translate(Env.getCtx(), "description").toUpperCase());
cell = row.createCell(col++);
cell.setCellStyle(cellStyle);
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
cell.setCellValue(text);
// columnas de valores - Value Columns
for (MReportColumn mcol : m_columns) {
String colName = mcol.getName();
text = new HSSFRichTextString(colName.toUpperCase());
cell = row.createCell(col++);
cell.setCellStyle(cellStyle);
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
cell.setCellValue(text);
}
//for columnas
}
Aggregations