|
|
@@ -10,22 +10,22 @@ let fs = require('fs');
|
|
|
let jpcCmnHelper = require('../rpt_component/helper/jpc_helper_common');
|
|
|
let DPI = jpcCmnHelper.getScreenDPI()[0];
|
|
|
let JV = require('../rpt_component/jpc_value_define');
|
|
|
+const uuidV1 = require('uuid/v1');
|
|
|
|
|
|
-// hwxsb.ttf: 华文中宋
|
|
|
-// Smart.ttf: 宋体(常规)
|
|
|
-// Smart-italic.ttf: 宋体(斜体)
|
|
|
-//目前不支持下划线
|
|
|
+let fontUtil = require('./rpt_font_util');
|
|
|
|
|
|
-module.exports ={
|
|
|
+// 目前不支持下划线
|
|
|
+
|
|
|
+module.exports = {
|
|
|
export_pdf_file:export_pdf_file
|
|
|
}
|
|
|
|
|
|
-
|
|
|
function export_pdf_file (pageData, paperSize, fName, callback) {
|
|
|
let offsetX= 10;
|
|
|
let offsetY=10;
|
|
|
let doc = new pdf({autoFirstPage: false});
|
|
|
- let newName = '' + (new Date()).valueOf();
|
|
|
+ // let newName = '' + (new Date()).valueOf();
|
|
|
+ let newName = uuidV1();
|
|
|
let stream = doc.pipe(fs.createWriteStream(__dirname.slice(0, __dirname.length - 21) + '/tmp/'+newName+'.pdf'));
|
|
|
let pageObj = pageData;
|
|
|
// doc.rect(5,5,1190,890).lineWidth(1).strokeColor('black').stroke();//边框
|
|
|
@@ -144,17 +144,12 @@ function export_pdf_file (pageData, paperSize, fName, callback) {
|
|
|
function private_drawText(val, area, font, control) {
|
|
|
let dftFontHeight = 12;
|
|
|
let output = [];
|
|
|
+ let fontFile = __dirname + '/pdf_base_files/simkai.ttf';
|
|
|
if (font) {
|
|
|
dftFontHeight = 1 * font[JV.FONT_PROPS[1]];
|
|
|
let dftFontBold = font[JV.FONT_PROPS[3]];
|
|
|
let dftFontItalic = font[JV.FONT_PROPS[4]];
|
|
|
- if (dftFontBold && dftFontBold === 'T') {
|
|
|
- doc.font(__dirname+'/pdf_base_files/hwxsb.ttf');
|
|
|
- }else if(dftFontItalic && dftFontItalic === 'T'){
|
|
|
- doc.font(__dirname+'/pdf_base_files/Smart-italic.ttf');
|
|
|
- }else {
|
|
|
- doc.font(__dirname+'/pdf_base_files/Smart.ttf');
|
|
|
- }
|
|
|
+ fontFile = __dirname + '/pdf_base_files/' + fontUtil.getActualFont(font[JV.FONT_PROPS[0]], (dftFontBold === 'T'), (dftFontItalic === 'T')) + '.ttf';
|
|
|
doc.fontSize(dftFontHeight);
|
|
|
}
|
|
|
let options={};
|
|
|
@@ -237,7 +232,8 @@ function export_pdf_file (pageData, paperSize, fName, callback) {
|
|
|
}
|
|
|
doc.rotate(font.FontAngle,rotateOptions);
|
|
|
}
|
|
|
- doc.text(val,output[0], output[1],options);
|
|
|
+ // doc.text(val,output[0], output[1],options);
|
|
|
+ doc.font(fontFile).text(val,output[0], output[1],options);
|
|
|
doc.restore();
|
|
|
}
|
|
|
|