Example usage for com.lowagie.text.pdf BaseFont NOT_EMBEDDED

List of usage examples for com.lowagie.text.pdf BaseFont NOT_EMBEDDED

Introduction

In this page you can find the example usage for com.lowagie.text.pdf BaseFont NOT_EMBEDDED.

Prototype

boolean NOT_EMBEDDED

To view the source code for com.lowagie.text.pdf BaseFont NOT_EMBEDDED.

Click Source Link

Document

if the font doesn't have to be embedded

Usage

From source file:questions.directcontent.InterpretOCR.java

public static void main(String[] args) throws IOException, DocumentException {
    Document document = new Document(PageSize.LETTER);
    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(RESULT));
    document.open();//from   w  w w.  j  av  a 2s . c  o  m
    PdfContentByte cb = writer.getDirectContent();
    BaseFont font = BaseFont.createFont(BaseFont.TIMES_ROMAN, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED);
    cb.beginText();
    cb.setFontAndSize(font, 12);
    String line;
    String word;
    @SuppressWarnings("unused")
    float llx, lly, urx, ury;
    StringTokenizer tokenizer;
    BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(RESOURCE)));
    while ((line = reader.readLine()) != null) {
        tokenizer = new StringTokenizer(line);
        while (tokenizer.hasMoreTokens()) {
            tokenizer.nextToken();
            word = tokenizer.nextToken();
            llx = Float.parseFloat(tokenizer.nextToken() + "f") / 10;
            lly = document.top() - Float.parseFloat(tokenizer.nextToken() + "f") / 10;
            urx = Float.parseFloat(tokenizer.nextToken() + "f") / 10;
            ury = document.top() - Float.parseFloat(tokenizer.nextToken() + "f") / 10;
            cb.showTextAligned(Element.ALIGN_LEFT, word, (llx + urx) / 2, lly, 0);
        }
    }
    cb.endText();
    document.close();
}

From source file:questions.forms.RadioButtonsOnDifferentPages.java

public static void main(String[] args) {
    Document document = new Document();
    try {//from   www . ja v a  2 s.co m
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(RESULT));
        document.open();

        PdfContentByte cb = writer.getDirectContent();
        BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED);
        String[] languages = { "English", "French", "Dutch" };
        Rectangle rect;

        // create radio button field and its kids
        PdfFormField language = PdfFormField.createRadioButton(writer, true);
        language.setFieldName("language");
        language.setValueAsName(languages[0]);
        for (int i = 0; i < languages.length; i++) {
            rect = new Rectangle(40, 806 - i * 40, 60, 788 - i * 40);
            addRadioButton(writer, rect, language, languages[i], i == 0, writer.getPageNumber() + i);
        }
        writer.addAnnotation(language);

        // add the page content
        for (int i = 0; i < languages.length; i++) {
            cb.beginText();
            cb.setFontAndSize(bf, 18);
            cb.showTextAligned(Element.ALIGN_LEFT, languages[i], 70, 790 - i * 40, 0);
            cb.endText();
            document.newPage();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    // step 5: we close the document
    document.close();

}

From source file:questions.importpages.NameCard.java

public static void createOneCard() throws DocumentException, IOException {
    Rectangle rect = new Rectangle(Utilities.millimetersToPoints(86.5f), Utilities.millimetersToPoints(55));
    Document document = new Document(rect);
    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(CARD));
    writer.setViewerPreferences(PdfWriter.PrintScalingNone);
    document.open();//from   ww  w  .  j  a v  a  2  s  .  c  o m
    PdfReader reader = new PdfReader(LOGO);
    Image img = Image.getInstance(writer.getImportedPage(reader, 1));
    img.scaleToFit(rect.getWidth() / 1.5f, rect.getHeight() / 1.5f);
    img.setAbsolutePosition((rect.getWidth() - img.getScaledWidth()) / 2,
            (rect.getHeight() - img.getScaledHeight()) / 2);
    document.add(img);
    document.newPage();
    BaseFont bf = BaseFont.createFont(FONT, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED);
    Font font = new Font(bf, 12);
    font.setColor(new CMYKColor(1, 0.5f, 0, 0.467f));
    ColumnText column = new ColumnText(writer.getDirectContent());
    Paragraph p;
    p = new Paragraph("Bruno Lowagie\n1T3XT\nbruno@1t3xt.com", font);
    p.setAlignment(Element.ALIGN_CENTER);
    column.addElement(p);
    column.setSimpleColumn(0, 0, rect.getWidth(), rect.getHeight() * 0.75f);
    column.go();
    document.close();
}

From source file:questions.separators.PositionedMarks.java

public PositionedMarks(boolean start) throws DocumentException, IOException {
    this.start = start;
    bf = BaseFont.createFont(BaseFont.ZAPFDINGBATS, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED);
}

From source file:s2s.report.MyPageEvents.java

License:GNU General Public License

@Override
public void onOpenDocument(PdfWriter writer, Document m_document) {
    try {/*from   ww  w  .  j ava2 s.c o m*/
        bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
        cb = writer.getDirectContent();
        template = cb.createTemplate(50, 50);
        m_rect = bRotate ? PageSize.A4.rotate() : PageSize.A4;
    } catch (DocumentException de) {
        de.printStackTrace(System.err);
    } catch (IOException ioe) {
        ioe.printStackTrace(System.err);
    }
}

From source file:ua.karazin.math.deansoffice.business.pdf.PDFCreate.java

public byte[] PDFCreate(String WriteInFile, String FileName)
        throws DocumentException, IOException, ParserConfigurationException, SAXException {
    ITextRenderer renderer = new ITextRenderer();

    renderer.getFontResolver().addFont("c:\\windows\\Fonts\\VERDANA.TTF", BaseFont.IDENTITY_H,
            BaseFont.NOT_EMBEDDED);
    renderer.getFontResolver().addFont("c:\\windows\\Fonts\\TIMES.TTF", BaseFont.IDENTITY_H,
            BaseFont.NOT_EMBEDDED);//ww w .  j  a  v  a  2  s . com

    OutputStream file = new FileOutputStream(
            new File(System.getProperty("com.sun.aas.instanceRoot") + "/docroot/" + FileName + ".pdf"));
    final DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
    documentBuilderFactory.setValidating(false);
    DocumentBuilder builder = documentBuilderFactory.newDocumentBuilder();
    builder.setEntityResolver(FSEntityResolver.instance());
    org.w3c.dom.Document document = builder
            .parse(new ByteArrayInputStream(WriteInFile.toString().getBytes("UTF-8")));

    renderer.setDocument(document, null);
    renderer.layout();
    renderer.createPDF(file);
    Path path = Paths.get(System.getProperty("com.sun.aas.instanceRoot") + "/docroot/" + FileName + ".pdf");
    byte[] data = Files.readAllBytes(path);
    System.out.println(data);
    return data;
}