// process core-render
Document document = XMLResource.load(
new ByteArrayInputStream(templateOut.toByteArray()))
.getDocument();
ITextRenderer iTextRenderer = new ITextRenderer();
out = new ByteArrayOutputStream();
// 設定字型
ITextFontResolver fontResolver = iTextRenderer.getFontResolver();
fontResolver.addFont(getFontPath(), BaseFont.IDENTITY_H,
BaseFont.NOT_EMBEDDED);
PDFEncryption pdfEncryption = new PDFEncryption();
// 設定加密
if (reportData.containsKey(ReportParamEnum.encrypt.toString())) {
String password = (String) reportData
.get(ReportParamEnum.encrypt.toString());
if (!CapString.isEmpty(password)) {
pdfEncryption.setUserPassword(password.getBytes());
}
}
// 設定權限
if (getAllowedPrivileges() != -1) {
pdfEncryption.setAllowedPrivileges(getAllowedPrivileges());
}
iTextRenderer.setPDFEncryption(pdfEncryption);
iTextRenderer.setDocument(document, fileUrlPrefix
+ servletContext.getRealPath("").replace("\\", "/") + "/");
iTextRenderer.layout();
iTextRenderer.createPDF(out);
} catch (Exception e) {
if (e.getCause() != null) {
throw new CapException(e.getCause(), e.getClass());
} else {