当前位置: 首页>>代码示例>>Java>>正文


Java CssFile类代码示例

本文整理汇总了Java中com.itextpdf.tool.xml.css.CssFile的典型用法代码示例。如果您正苦于以下问题:Java CssFile类的具体用法?Java CssFile怎么用?Java CssFile使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CssFile类属于com.itextpdf.tool.xml.css包,在下文中一共展示了CssFile类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDefaultCSS

import com.itextpdf.tool.xml.css.CssFile; //导入依赖的package包/类
/**
 * Returns the default PDF CSS file
 * @return The default CSS file for PDF documents
 * @throws ExInternal If the default CSS could not be found
 */
private CssFile getDefaultCSS() throws ExInternal {
  String lDefaultCssPath = FoxGlobals.getInstance().getServletContext().getRealPath(DEFAULT_CSS_RELATIVE_PATH);

  try {
    return getCSSFile(new FileInputStream(lDefaultCssPath));
  }
  catch (FileNotFoundException e) {
    throw new ExInternal("Could not find default CSS '" + lDefaultCssPath + "'", e);
  }
}
 
开发者ID:Fivium,项目名称:FOXopen,代码行数:16,代码来源:CSSFileManager.java

示例2: getCSSFileFromModuleCSSItem

import com.itextpdf.tool.xml.css.CssFile; //导入依赖的package包/类
/**
 * Returns a CSS file resolved from a module css-list item
 * @param pSerialisationContext The serialisation context, used to get the file from the application components table
 * @param pModuleCSSItem The module css-list item
 * @return The resolved CSS file
 * @throws ExInternal If a fixed URI was specified in the module css item, see
 *         {@link net.foxopen.fox.entrypoint.uri.RequestURIBuilder#isFixedURI}
 */
private CssFile getCSSFileFromModuleCSSItem(SerialisationContext pSerialisationContext, CSSListItem pModuleCSSItem) throws ExInternal {
  CssFile lCSSFile;
  String lPath = pModuleCSSItem.getStyleSheetPath();

  if (!pSerialisationContext.createURIBuilder().isFixedURI(lPath)) {
    lCSSFile = getCSSFileFromComponent(pSerialisationContext, lPath);
  }
  else {
    throw new ExInternal("Fixed CSS file URIs cannot be used during PDF serialisation (URI: '" + lPath + "')",
                         new UnsupportedOperationException());
  }

  return lCSSFile;
}
 
开发者ID:Fivium,项目名称:FOXopen,代码行数:23,代码来源:CSSFileManager.java

示例3: getCSSFile

import com.itextpdf.tool.xml.css.CssFile; //导入依赖的package包/类
/**
 * Returns an immutable CSS file from the CSS file input stream
 * @param pCSSFileInputStream The input stream containing the CSS file
 * @return A CSS file taken from the input stream
 * @throws ExInternal If the CSS file input stream could not be read
 */
private CssFile getCSSFile(InputStream pCSSFileInputStream) throws ExInternal {
  FileRetrieve lFileRetriever = new FileRetrieveImpl();
  CssFileProcessor lCSSFileProcessor = new CssFileProcessor();

  try {
    lFileRetriever.processFromStream(pCSSFileInputStream, lCSSFileProcessor);
  }
  catch (IOException e) {
    throw new ExInternal("Failed to read CSS file input stream");
  }

  return new CSSFileWrapper(lCSSFileProcessor.getCss(), true);
}
 
开发者ID:Fivium,项目名称:FOXopen,代码行数:20,代码来源:CSSFileManager.java

示例4: fillDefaultHtmlCSS

import com.itextpdf.tool.xml.css.CssFile; //导入依赖的package包/类
public void fillDefaultHtmlCSS(CssFile cssFile) {
    cssFile.add(HTML.Tag.BASE, bodyCssStyles());
    cssFile.add(HTML.Tag.BODY, bodyCssStyles());
    cssFile.add(HTML.Tag.H1, h1CssStyles());
    cssFile.add(HTML.Tag.H2, h2CssStyles());
    cssFile.add(HTML.Tag.UL, ulCssStyles());
    cssFile.add(HTML.Tag.LI, liCssStyles());
    cssFile.add(HTML.Tag.P, pCssStyles());
}
 
开发者ID:Arnauld,项目名称:cucumber-contrib,代码行数:10,代码来源:Configuration.java

示例5: createPdf

import com.itextpdf.tool.xml.css.CssFile; //导入依赖的package包/类
/**
 * <a href="http://stackoverflow.com/questions/43610868/how-to-add-dynamic-variable-to-footer-without-calling-document-newpage-in-itex">
 * How to add dynamic variable to footer without calling document.newPage() in iText 5
 * </a>
 * <p>
 * generator method of the OP
 * </p>
 * @see #testDynamicFooterLikeAyZagen()
 */
public static void createPdf(ArrayList<String> htmlStrings, FooterTable footerEvt, String destinationPath)
        throws IOException, DocumentException {
    Document document = new Document(PageSize.A4);
    document.setMargins(68, 85, 75, 85);
    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(destinationPath));
    if (footerEvt != null)
        writer.setPageEvent(footerEvt);
    document.open();

    CSSResolver cssResolver = new StyleAttrCSSResolver();
    CssFile cssFile = XMLWorkerHelper
            .getCSS(new ByteArrayInputStream(/*readCSS("resources/content.min.css").getBytes()*/ "".getBytes()));
    cssResolver.addCss(cssFile);

    XMLWorkerFontProvider fontProvider = new XMLWorkerFontProvider(XMLWorkerFontProvider.DONTLOOKFORFONTS);
    fontProvider.register(/*"resources/ARIAL.TTF"*/ "c:/Windows/Fonts/arial.ttf");

    CssAppliers cssAppliers = new CssAppliersImpl(fontProvider);
    HtmlPipelineContext htmlContext = new HtmlPipelineContext(cssAppliers);
    htmlContext.setTagFactory(Tags.getHtmlTagProcessorFactory());

    PdfWriterPipeline pdf = new PdfWriterPipeline(document, writer);
    HtmlPipeline html = new HtmlPipeline(htmlContext, pdf);
    CssResolverPipeline css = new CssResolverPipeline(cssResolver, html);

    XMLWorker worker = new XMLWorker(css, true);
    XMLParser p = new XMLParser(worker);
    int i = 0;
    for (String htmlfile : htmlStrings) {
        i++;
        footerEvt.setTitleIndex("" + i);//or FooterTable.setTitleIndex("" + i);
        ByteArrayInputStream stream = new ByteArrayInputStream(htmlfile.getBytes("UTF-8"));
        p.parse(stream, Charset.forName("UTF-8"));
    }
    document.close();
}
 
开发者ID:mkl-public,项目名称:testarea-itext5,代码行数:46,代码来源:DynamicFooter.java

示例6: getDefaultCSS

import com.itextpdf.tool.xml.css.CssFile; //导入依赖的package包/类
private CssFile getDefaultCSS() {
    return XMLWorkerHelper.getInstance().getDefaultCSS();
}
 
开发者ID:Arnauld,项目名称:cucumber-contrib,代码行数:4,代码来源:MarkdownEmitter.java

示例7: getHtmlCSS

import com.itextpdf.tool.xml.css.CssFile; //导入依赖的package包/类
private CssFile getHtmlCSS() {
    CssFileImpl cssFile = new CssFileImpl();
    configuration.fillDefaultHtmlCSS(cssFile);
    return cssFile;
}
 
开发者ID:Arnauld,项目名称:cucumber-contrib,代码行数:6,代码来源:MarkdownEmitter.java

示例8: addCSSFile

import com.itextpdf.tool.xml.css.CssFile; //导入依赖的package包/类
/**
 * Add a CSS file to the list of loaded files
 * @param pCSSFile The CSS file to add
 */
private void addCSSFile(CssFile pCSSFile) {
  mCSSFiles.add(pCSSFile);
}
 
开发者ID:Fivium,项目名称:FOXopen,代码行数:8,代码来源:CSSFileManager.java

示例9: getCSSFileFromComponent

import com.itextpdf.tool.xml.css.CssFile; //导入依赖的package包/类
/**
 * Returns a CSS file from the given component path
 * @param pSerialisationContext The serialisation context, used to get the file from the application components table
 * @param pComponentPath The path to the component
 * @return The resolved CSS file
 */
private CssFile getCSSFileFromComponent(SerialisationContext pSerialisationContext, String pComponentPath) {
  FoxComponent lCSSComponent = FoxComponentUtils.getComponent(pSerialisationContext, pComponentPath);
  return getCSSFile(lCSSComponent.getInputStream());
}
 
开发者ID:Fivium,项目名称:FOXopen,代码行数:11,代码来源:CSSFileManager.java


注:本文中的com.itextpdf.tool.xml.css.CssFile类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。