當前位置: 首頁>>代碼示例>>Java>>正文


Java XRLog類代碼示例

本文整理匯總了Java中com.openhtmltopdf.util.XRLog的典型用法代碼示例。如果您正苦於以下問題:Java XRLog類的具體用法?Java XRLog怎麽用?Java XRLog使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


XRLog類屬於com.openhtmltopdf.util包,在下文中一共展示了XRLog類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onStartup

import com.openhtmltopdf.util.XRLog; //導入依賴的package包/類
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    super.onStartup(servletContext);

    Thread.setDefaultUncaughtExceptionHandler(new DefaultExceptionHandler());

    configureSessionCookie(servletContext);
    
    CharacterEncodingFilter cef = new CharacterEncodingFilter();
    cef.setEncoding("UTF-8");
    cef.setForceEncoding(true);
    
    Dynamic characterEncodingFilter = servletContext.addFilter("CharacterEncodingFilter", cef);
    characterEncodingFilter.setAsyncSupported(true);
    characterEncodingFilter.addMappingForUrlPatterns(null, false, "/*");

    //force log initialization, then disable it
    XRLog.setLevel(XRLog.EXCEPTION, Level.WARNING);
    XRLog.setLoggingEnabled(false);

}
 
開發者ID:alfio-event,項目名稱:alf.io,代碼行數:22,代碼來源:Initializer.java

示例2: export

import com.openhtmltopdf.util.XRLog; //導入依賴的package包/類
public byte[] export(InputStream template, Map<String, Object> arguments) {
    XRLog.setLoggerImpl(new Slf4jLogger());

    try {
        String resultHtml = templater.transform(template, arguments);

        byte[] colorProfile = Utils.resourceBytes("srgb_profile.icm");

        PdfBoxRenderer renderer = new PdfRendererBuilder()
                .usePdfVersion(1.4f)
                .usePdfAConformance("A")
                .useColorProfile(colorProfile)
                .defaultTextDirection(PdfRendererBuilder.TextDirection.LTR)
                .withHtmlContent(resultHtml, "http://localhost:" + serverPort + "/")
                .buildPdfRenderer();

        PdfBoxFontResolver fontResolver = renderer.getFontResolver();

        byte[] fontBytesArial = resourceBytes("arial.ttf");
        byte[] fontBytesTahoma = resourceBytes("tahomar.ttf");
        byte[] fontBytesTahomaBold = resourceBytes("tahomabd.ttf");
        byte[] fontBytesTahomaItalic = resourceBytes("verdanait.ttf");

        fontResolver.addFont(() -> new ByteArrayInputStream(fontBytesArial), "Ariel", null, null, false);
        fontResolver.addFont(() -> new ByteArrayInputStream(fontBytesTahoma), "Tahoma", null, null, false);
        fontResolver.addFont(() -> new ByteArrayInputStream(fontBytesTahomaBold), "Tahoma", 700, null, false);
        fontResolver.addFont(() -> new ByteArrayInputStream(fontBytesTahomaItalic), "Tahoma", null, IdentValue.ITALIC, false);

        renderer.layout();

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        renderer.createPDF(out);

        return out.toByteArray();
    } catch (IOException ex) {
        throw new GeneralException(ex);
    }
}
 
開發者ID:LIBCAS,項目名稱:ARCLib,代碼行數:39,代碼來源:PdfExporter.java

示例3: PdfUtilExport

import com.openhtmltopdf.util.XRLog; //導入依賴的package包/類
public PdfUtilExport(String titleContent, String authorContent, String srcHtmlPath, String destPdfPath) {
    this.titleContent = titleContent.toUpperCase();
    this.authorContent = authorContent;
    this.srcHtmlPath = srcHtmlPath;
    this.destPdfPath = destPdfPath;
    XRLog.setLoggingEnabled(false);
}
 
開發者ID:firm1,項目名稱:zest-writer,代碼行數:8,代碼來源:PdfUtilExport.java


注:本文中的com.openhtmltopdf.util.XRLog類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。