My favorites | Sign in
Project Home Downloads Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions

Issue 171 attachment: PdfPView.java.patch (3.3 KB)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
Index: src/org/jmesa/view/pdfp/PdfPView.java
===================================================================
--- src/org/jmesa/view/pdfp/PdfPView.java (revision 2276)
+++ src/org/jmesa/view/pdfp/PdfPView.java (working copy)
@@ -15,24 +15,28 @@
*/
package org.jmesa.view.pdfp;

-import com.lowagie.text.Font;
-import com.lowagie.text.FontFactory;
-import com.lowagie.text.Paragraph;
-import com.lowagie.text.pdf.PdfPCell;
-import com.lowagie.text.pdf.PdfPTable;
+import static org.jmesa.view.ViewUtils.isRowEven;
+
import java.awt.Color;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
+
import org.jmesa.core.CoreContext;
import org.jmesa.view.View;
-import static org.jmesa.view.ViewUtils.isRowEven;
import org.jmesa.view.component.Column;
import org.jmesa.view.component.Row;
import org.jmesa.view.component.Table;
import org.jmesa.view.html.toolbar.Toolbar;
import org.jmesa.web.WebContext;

+import com.lowagie.text.Font;
+import com.lowagie.text.FontFactory;
+import com.lowagie.text.Paragraph;
+import com.lowagie.text.pdf.BaseFont;
+import com.lowagie.text.pdf.PdfPCell;
+import com.lowagie.text.pdf.PdfPTable;
+
/**
* A PDF view that uses the iText PdfPTable.
*
@@ -83,6 +87,25 @@
}

public PdfPTable render() {
+
+ Font cellFont = null;
+ Font headerCellFont = null;
+ final String fontName = coreContext.getPreference("export.pdf.fontName");
+ final String fontEncoding =coreContext.getPreference("export.pdf.fontEncoding");
+ if(fontName != null && fontEncoding != null){
+ try {
+ BaseFont bfChinese = BaseFont.createFont(fontName, fontEncoding, BaseFont.NOT_EMBEDDED);
+ cellFont = new Font(bfChinese, 12, 0);
+ headerCellFont=new Font(bfChinese, 12, 0,getHeaderFontColor());
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ }
+ if( null == cellFont){
+ cellFont = FontFactory.getFont("Helvetica", 12F, 0);
+ headerCellFont = FontFactory.getFont("Helvetica", 12F, 0, getHeaderFontColor());
+ }
+
PdfPTable pdfpTable = new PdfPTable(getTable().getRow().getColumns().size());
pdfpTable.setSpacingBefore(3);

@@ -93,7 +116,7 @@
// build table headers
for (Iterator<Column> iter = columns.iterator(); iter.hasNext();) {
Column column = iter.next();
- PdfPCell cell = new PdfPCell(new Paragraph(column.getTitle(), FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL, getHeaderFontColor())));
+ PdfPCell cell = new PdfPCell(new Paragraph(column.getTitle(),headerCellFont));
cell.setPadding(3.0f);
cell.setBackgroundColor(getHeaderBackgroundColor());
pdfpTable.addCell(cell);
@@ -112,7 +135,7 @@

String property = column.getProperty();
Object value = column.getCellRenderer().getCellEditor().getValue(item, property, rowcount);
- PdfPCell cell = new PdfPCell(new Paragraph(value == null ? "" : String.valueOf(value), FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL)));
+ PdfPCell cell = new PdfPCell(new Paragraph(value == null ? "" : String.valueOf(value), cellFont));
cell.setPadding(3.0f);

if (isRowEven(rowcount)) {
Powered by Google Project Hosting