Example usage for com.lowagie.text FontFactory defaultEmbedding

List of usage examples for com.lowagie.text FontFactory defaultEmbedding

Introduction

In this page you can find the example usage for com.lowagie.text FontFactory defaultEmbedding.

Prototype

boolean defaultEmbedding

To view the source code for com.lowagie.text FontFactory defaultEmbedding.

Click Source Link

Document

This is the default value of the embedded variable.

Usage

From source file:buckley.compile.FontRegistry.java

License:Apache License

public FontRegistry() {
    FontFactory.defaultEmbedding = BaseFont.EMBEDDED;
}

From source file:de.cuseb.bilderbuch.pdf.PdfController.java

License:Open Source License

@RequestMapping(value = "/pdf", method = RequestMethod.GET)
public void generatePdf(HttpSession session, HttpServletResponse httpServletResponse) {

    try {//w  ww . j  a v a2 s  .com
        PdfRequest pdfRequest = (PdfRequest) session.getAttribute("pdfRequest");
        httpServletResponse.setContentType("application/pdf");

        Document document = new Document();
        PdfWriter writer = PdfWriter.getInstance(document, httpServletResponse.getOutputStream());
        writer.setDefaultColorspace(PdfName.COLORSPACE, PdfName.DEFAULTRGB);

        //document.addAuthor(pdfRequest.getAuthor());
        //document.addTitle(pdfRequest.getTitle());
        document.setPageSize(
                new Rectangle(Utilities.millimetersToPoints(156), Utilities.millimetersToPoints(148)));
        document.open();

        FontFactory.defaultEmbedding = true;
        FontFactory.register("IndieRock.ttf", "IndieRock");
        Font font = FontFactory.getFont("IndieRock");
        BaseFont baseFont = font.getBaseFont();
        PdfContentByte cb = writer.getDirectContent();

        Iterator<PdfPage> pages = pdfRequest.getPages().iterator();
        while (pages.hasNext()) {

            PdfPage page = pages.next();
            if (page.getImage() != null) {

                Image image = Image.getInstance(new URL(page.getImage().getUrl()));
                image.setDpi(300, 300);
                image.setAbsolutePosition(0f, 0f);
                image.scaleAbsolute(document.getPageSize().getWidth(), document.getPageSize().getHeight());
                document.add(image);

                cb.saveState();
                cb.beginText();
                cb.setColorFill(Color.WHITE);
                cb.moveText(10f, 10f);
                cb.setFontAndSize(baseFont, 18);
                cb.showText(page.getSentence());
                cb.endText();
                cb.restoreState();

                if (pages.hasNext()) {
                    document.newPage();
                }
            }
        }
        document.close();

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:org.mapfish.print.MapPrinter.java

License:Open Source License

/**
 * Register the user specified fonts in iText.
 *///from w w w  . j  a v  a2  s.  co  m
private void initFonts() {
    //we don't do that since it takes ages and that would hurt the perfs for
    //the python controller:
    //FontFactory.registerDirectories();

    FontFactory.defaultEmbedding = true;

    final TreeSet<String> fontPaths = config.getFonts();
    if (fontPaths != null) {
        for (String fontPath : fontPaths) {
            fontPath = fontPath.replaceAll("\\$\\{configDir\\}", configDir);
            File fontFile = new File(fontPath);
            if (fontFile.isDirectory()) {
                FontFactory.registerDirectory(fontPath, true);
            } else {
                FontFactory.register(fontPath);
            }
        }
    }
}