[2617308] Add PDF_FONT_DIR system config parameter for pdf export

This commit is contained in:
Heng Sin Low 2009-02-20 03:53:24 +00:00
parent 332822670d
commit 03d627444d
1 changed files with 16 additions and 1 deletions

View File

@ -22,6 +22,7 @@ import java.io.FileOutputStream;
import java.io.OutputStream;
import org.adempiere.pdf.viewer.PDFViewerBean;
import org.compiere.model.MSysConfig;
import com.lowagie.text.FontFactory;
import com.lowagie.text.Rectangle;
@ -41,6 +42,8 @@ public class Document {
FontFactory.registerDirectories();
}
private final static String PDF_FONT_DIR = "PDF_FONT_DIR";
private static void writePDF(Pageable pageable, OutputStream output)
{
try {
@ -54,6 +57,18 @@ public class Document {
writer.setPdfVersion(PdfWriter.VERSION_1_2);
document.open();
final DefaultFontMapper mapper = new DefaultFontMapper();
//Elaine 2009/02/17 - load additional font from directory set in PDF_FONT_DIR of System Configurator
String pdfFontDir = MSysConfig.getValue(PDF_FONT_DIR, "");
if(pdfFontDir != null && pdfFontDir.trim().length() > 0)
{
pdfFontDir = pdfFontDir.trim();
File dir = new File(pdfFontDir);
if(dir.exists() && dir.isDirectory())
mapper.insertDirectory(pdfFontDir);
}
//
final float w = (float) pf.getWidth();
final float h = (float) pf.getHeight();
final PdfContentByte cb = writer.getDirectContent();