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

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

Introduction

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

Prototype

boolean NOT_EMBEDDED

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

Click Source Link

Document

if the font doesn't have to be embedded

Usage

From source file:fc.extensions.itext.Writer.java

License:MIT License

public Writer(String pdfFile, Rectangle pageSize, String fontPath, String ansiFontPath) throws Exception {
    this.pdfFile = new File(pdfFile);

    document = new Document(pageSize);
    pdfWriter = PdfWriter.getInstance(document, new FileOutputStream(this.pdfFile));
    pdfWriter.setPageEvent(this);
    document.open();//from  w ww. j  a  v a2  s  .c  o  m
    pdfWriterCB = pdfWriter.getDirectContent();
    baseColor = BaseColor.BLACK;
    baseFont = BaseFont.createFont(fontPath, BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
    engBaseFont = BaseFont.createFont(ansiFontPath, BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
}

From source file:gravabncertificado.GerandoArquivoCarimbado_1.java

public static void GerandoArquivoCarimbadoPDF(String caminhoarquivo, String BN) throws InvalidPdfException {
    //Copiando arquivo informado.
    try {//from ww  w  .j av  a2 s  .  c o  m

        // Adicionado parametro para nao retornar erro quando o documento for protegido.
        PdfReader.unethicalreading = true;
        //Cria o reader para o primeiro PDF

        PdfReader reader = new PdfReader(caminhoarquivo);

        // n recebe o numero total de paginas
        int n = reader.getNumberOfPages();

        //Tamanho da primeira Pagina
        ;

        //Cria Segundo PDF

        Document document = new Document(PageSize.A4, 36, 36, 36, 36);

        PdfWriter writer = PdfWriter.getInstance(document,
                new FileOutputStream(caminhoarquivo.substring(0, caminhoarquivo.length() - 4) + "-C.pdf"));

        document.open();

        // Adiciona conteudo ao PDF Carimbado.
        PdfContentByte cb = writer.getDirectContent();
        int i = 0;
        int p = 0;
        String caminhodestino = (caminhoarquivo.substring(0, caminhoarquivo.length() - BN.length()));

        // DESABILITADO PORQUE O MOVER NAO ESTAVA FUNCIONANDO.
        File destinooriginal = new File(caminhodestino + "ORIGINAL\\");
        if (!destinooriginal.exists()) {
            destinooriginal.mkdir();
        }

        caminhodestino = (caminhodestino + "ORIGINAL\\" + BN);

        //TESTANDO NOVA FORMA DE COPIAR

        File origem = new File(caminhoarquivo);
        File destino = new File(caminhodestino);

        FileInputStream fis = new FileInputStream(origem);
        FileOutputStream fos = new FileOutputStream(destino);

        FileChannel inChannel = fis.getChannel();
        FileChannel outChannel = fos.getChannel();

        long transferFrom = outChannel.transferFrom(inChannel, 0, inChannel.size());

        fis.close();
        fos.close();
        inChannel.close();
        outChannel.close();

        // Thread.sleep(10);

        BN = BN.substring(0, BN.length() - 4);

        while (i < n) {
            document.newPage();
            p++;
            i++;

            PdfContentByte under = writer.getDirectContentUnder();
            PdfImportedPage page1 = writer.getImportedPage(reader, i);
            cb.addTemplate(page1, 0, i * 0.2f);

            // Page 1: a rectangle
            /* RETANGULO DESATIVADO
            drawRectangle(under, 100, 50);
            under.setRGBColorFill(255, 220, 220);
            under.rectangle(width /50, 5, 118, 40);
            under.fill();
            */

            //CARIMBO DA BN

            BaseFont bf = BaseFont.createFont(BaseFont.COURIER_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED);
            cb.beginText();
            cb.setFontAndSize(bf, 14);
            cb.showTextAligned(PdfContentByte.ALIGN_CENTER, " ________________", width / 6, 44, 0);
            cb.showTextAligned(PdfContentByte.ALIGN_CENTER, " |               |", width / 6, 32, 0);
            cb.showTextAligned(PdfContentByte.ALIGN_CENTER, " |               |", width / 6, 22, 0);
            cb.showTextAligned(PdfContentByte.ALIGN_CENTER, " NR", width / 6, 28, 0);
            cb.showTextAligned(PdfContentByte.ALIGN_CENTER, " " + BN, width / 6, 16, 0);
            cb.showTextAligned(PdfContentByte.ALIGN_CENTER, " |               |", width / 6, 12, 0);
            cb.showTextAligned(PdfContentByte.ALIGN_CENTER, " ________________", width / 6, 14, 0);
            cb.endText();

        }

        document.close();
        writer.close();
        reader.close();
        origem.delete();

        /* PdfContentByte under = writer.getDirectContentUnder();
                 
         // Page 1: a rectangle
             drawRectangle(under, 20, 20);
             under.setRGBColorFill(0xFF, 0xD7, 0x00);
             under.rectangle(5, 5, 15, 15);
             under.fill(); */
        //document.newPage();

        //COPIANDO ARQUIVO CARIMBADO

        /* DESABILITADO PORQUE NAO ESTAVA FUNCIONANDO.
        boolean bool;
                
         //caminhoarquivo = caminhoarquivo.replace("\\", "\\\\");
         //caminhodestino = caminhodestino.replace("\\", "\\\\");
                    
        File origem = new File(caminhoarquivo);
        File destino = new File(caminhodestino);
                
                    
        bool = origem.renameTo(destino);
        System.out.println(origem);
        System.out.println(caminhodestino);
        */

    } catch (IOException | DocumentException ex) {
    }

}

From source file:gravabncertificado007.CarimboCertificado.java

public void aplicaCarimboBin(String BN, String caminhoarquivo)
        throws DocumentException, IOException, RuntimeException {

    PdfReader.unethicalreading = true;// ww w.j av  a  2 s .  com
    //Cria o reader para o primeiro PDF

    PdfReader reader = new PdfReader(caminhoarquivo);
    Rectangle psize = reader.getPageSize(1);
    float width = psize.getWidth();
    float height = psize.getHeight();

    Document document = new Document(new Rectangle(width, height));

    PdfWriter writer = PdfWriter.getInstance(document,
            new FileOutputStream(caminhoarquivo.substring(0, caminhoarquivo.length() - 4) + "-C.pdf"));

    document.open();

    int i = 0;
    BN = BN.substring(BN.length() - 13, BN.length() - 4);
    PdfContentByte cb = writer.getDirectContent();
    while (i < reader.getNumberOfPages()) {
        i++;

        document.newPage();

        PdfContentByte under = writer.getDirectContentUnder();
        PdfImportedPage page1 = writer.getImportedPage(reader, i);
        cb.addTemplate(page1, 0, i * 0.2f);

        //CARIMBO DA BN
        BaseFont bf = BaseFont.createFont(BaseFont.COURIER_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED);
        cb.beginText();
        cb.setFontAndSize(bf, 14);
        cb.showTextAligned(PdfContentByte.ALIGN_CENTER, " ________________", width / 6, 44, 0);
        cb.showTextAligned(PdfContentByte.ALIGN_CENTER, " |               |", width / 6, 32, 0);
        cb.showTextAligned(PdfContentByte.ALIGN_CENTER, " |               |", width / 6, 22, 0);
        cb.showTextAligned(PdfContentByte.ALIGN_CENTER, " NR", width / 6, 28, 0);
        cb.showTextAligned(PdfContentByte.ALIGN_CENTER, " " + BN, width / 6, 16, 0);
        cb.showTextAligned(PdfContentByte.ALIGN_CENTER, " |               |", width / 6, 12, 0);
        cb.showTextAligned(PdfContentByte.ALIGN_CENTER, " ________________", width / 6, 14, 0);
        cb.endText();

    }

    document.close();
    writer.close();
    reader.close();

}

From source file:gravabncertificado007.CarimboCertificado.java

public void aplicaCariboGedi(String BN, String caminhoarquivo)
        throws DocumentException, IOException, RuntimeException {

    PdfReader.unethicalreading = true;//from www  .  java  2s.  co m
    //Cria o reader para o primeiro PDF

    PdfReader reader = new PdfReader(caminhoarquivo);
    Rectangle psize = reader.getPageSize(1);
    float width = psize.getWidth();
    float height = psize.getHeight();

    Document document = new Document(new Rectangle(width, height));

    PdfWriter writer = PdfWriter.getInstance(document,
            new FileOutputStream(caminhoarquivo.substring(0, caminhoarquivo.length() - 4) + "-G.pdf"));

    document.open();

    int i = 0;
    BN = BN.substring(BN.length() - 13, BN.length() - 4);
    PdfContentByte cb = writer.getDirectContent();
    while (i < reader.getNumberOfPages()) {
        i++;

        document.newPage();

        PdfContentByte under = writer.getDirectContentUnder();
        PdfImportedPage page1 = writer.getImportedPage(reader, i);
        cb.addTemplate(page1, 0, i * 0.2f);

        BaseFont bf = BaseFont.createFont(BaseFont.COURIER_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED);
        cb.beginText();
        cb.setFontAndSize(bf, 14);
        cb.showTextAligned(PdfContentByte.ALIGN_CENTER, "  _________________  ", width / 6, 44, 0);
        cb.showTextAligned(PdfContentByte.ALIGN_CENTER, " |                 |", width / 6, 32, 0);
        cb.showTextAligned(PdfContentByte.ALIGN_CENTER, " |                 |", width / 6, 22, 0);
        cb.showTextAligned(PdfContentByte.ALIGN_CENTER, " |Copia Controlada |", width / 6, 28, 0);
        cb.showTextAligned(PdfContentByte.ALIGN_CENTER, " |                 |", width / 6, 16, 0);
        cb.showTextAligned(PdfContentByte.ALIGN_CENTER, " |                 |", width / 6, 12, 0);
        cb.showTextAligned(PdfContentByte.ALIGN_CENTER, " |_________________|", width / 6, 14, 0);
        cb.endText();
    }

    document.close();
    writer.close();
    reader.close();

}

From source file:hr.ws4is.tn3812.drivers.listeners.PdfListener.java

License:Open Source License

public PdfListener() {
    super();// w  w  w .  ja v  a2 s .c o  m
    try {
        courier = BaseFont.createFont(BaseFont.COURIER, BaseFont.CP1250, BaseFont.NOT_EMBEDDED);
    } catch (DocumentException documentException) {
        LOGGER.error(documentException.getMessage(), documentException);
    } catch (IOException ioException) {
        LOGGER.error(ioException.getMessage(), ioException);
    }
}

From source file:hsa.awp.admingui.report.printer.MergePDFUtil.java

License:Open Source License

private BaseFont getBaseFont() throws DocumentException, IOException {
    return BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
}

From source file:htmlparser.pdf.PDFFile.java

public PDFFile(Parser parser) {

    this.parser = parser;
    this.document = new Document();

    try {//from   ww w  . ja v  a2s  .  com

        PdfWriter.getInstance(this.document, new FileOutputStream(this.parser.getCompetitionName() + ".pdf"));
        this.document.open();
        this.fonttype = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1250, BaseFont.NOT_EMBEDDED);
        this.opened = true;

    } catch (Exception ex) {
        this.opened = false;
    }
}

From source file:jasperSoft.MergePDF.java

/**
 * //from   w ww . j  av a 2s  .com
 * @param streamOfPDFFiles
 * @param outputStream
 * @param paginate 
 */
public static void concatPDFs(List<InputStream> streamOfPDFFiles, OutputStream outputStream, boolean paginate) {

    Document document = new Document();
    try {
        List<InputStream> pdfs = streamOfPDFFiles;
        List<PdfReader> readers = new ArrayList<PdfReader>();
        int totalPages = 0;
        Iterator<InputStream> iteratorPDFs = pdfs.iterator();

        // Create Readers for the pdfs.
        while (iteratorPDFs.hasNext()) {
            InputStream pdf = iteratorPDFs.next();
            PdfReader pdfReader = new PdfReader(pdf);
            readers.add(pdfReader);
            totalPages += pdfReader.getNumberOfPages();
        }
        // Create a writer for the outputstream
        PdfWriter writer = PdfWriter.getInstance(document, outputStream);

        document.open();
        BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
        PdfContentByte cb = writer.getDirectContent(); // Holds the PDF
        // data

        PdfImportedPage page;
        int currentPageNumber = 0;
        int pageOfCurrentReaderPDF = 0;
        Iterator<PdfReader> iteratorPDFReader = readers.iterator();

        // Loop through the PDF files and add to the output.
        while (iteratorPDFReader.hasNext()) {
            PdfReader pdfReader = iteratorPDFReader.next();

            // Create a new page in the target for each source page.
            while (pageOfCurrentReaderPDF < pdfReader.getNumberOfPages()) {
                document.newPage();
                pageOfCurrentReaderPDF++;
                currentPageNumber++;
                page = writer.getImportedPage(pdfReader, pageOfCurrentReaderPDF);
                cb.addTemplate(page, 0, 0);

                // Code for pagination.
                if (paginate) {
                    cb.beginText();
                    cb.setFontAndSize(bf, 9);
                    cb.showTextAligned(PdfContentByte.ALIGN_CENTER,
                            "" + currentPageNumber + " of " + totalPages, 520, 5, 0);
                    cb.endText();
                }
            }
            pageOfCurrentReaderPDF = 0;
        }
        outputStream.flush();
        document.close();
        outputStream.close();
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        if (document.isOpen()) {
            document.close();
        }
        try {
            if (outputStream != null) {
                outputStream.close();
            }
        } catch (IOException ioe) {
            ioe.printStackTrace();
        }
    }
}

From source file:jati.GerandoArquivoCarimbado.java

public static void GerandoArquivoCarimbadoPDF(String caminhoarquivo, String BN)
        throws InvalidPdfException, IOException {
    //Copiando arquivo informado.

    try {// w w w.  ja va 2s . c  om

        // Adicionado parametro para nao retornar erro quando o documento for protegido.
        PdfReader.unethicalreading = true;

        PdfWriter writer = PdfWriter.getInstance(montaraAquivo(caminhoarquivo),
                new FileOutputStream(caminhoarquivo.substring(0, caminhoarquivo.length() - 4) + "-C.pdf"));
        // ABRE O DOCUMENTO CRIADO PARA MANUSEIO
        montaraAquivo(caminhoarquivo).open();

        //SUBSTRING RETIRA PARTE DO TEXTO ENTRE OS INDICES ESPECIFICADOS 
        //caminhoDestino RECEBE UM NOVO CAMINHO RESULTANTE DOS INDICES DE CAMINHO.LENGTH - BN.LENGTH
        // QUE FORMAM UMA NOVA STRING
        String caminhodestino = (caminhoarquivo.substring(0, caminhoarquivo.length() - BN.length()));

        File destinooriginal = new File(caminhodestino + "ORIGINAL\\");
        if (!destinooriginal.exists()) {
            destinooriginal.mkdir();
        }

        caminhodestino = (caminhodestino + "ORIGINAL\\" + BN);

        //TESTANDO NOVA FORMA DE COPIAR
        File origem = new File(caminhoarquivo);
        File destino = new File(caminhodestino);

        FileInputStream fis = new FileInputStream(origem);
        FileOutputStream fos = new FileOutputStream(destino);

        FileChannel inChannel = fis.getChannel();
        FileChannel outChannel = fos.getChannel();

        long transferFrom = outChannel.transferFrom(inChannel, 0, inChannel.size());

        fis.close();
        fos.close();
        inChannel.close();
        outChannel.close();

        // Thread.sleep(10);
        BN = BN.substring(0, BN.length() - 4);

        PdfContentByte cb = writer.getDirectContent();

        int i = 0;
        while (i < reader.getNumberOfPages()) {
            montaraAquivo(caminhodestino).newPage();

            i++;

            //PDFCONTETBYTE GERA UMA ESPECIE DE CODIGO DE BARRAS 
            PdfContentByte under = writer.getDirectContentUnder();
            PdfImportedPage page1 = writer.getImportedPage(reader, i);
            cb.addTemplate(page1, 0, i * 0.2f);

            //CARIMBO DA BN
            BaseFont bf = BaseFont.createFont(BaseFont.COURIER_BOLD, BaseFont.CP1250, BaseFont.NOT_EMBEDDED);
            cb.beginText();
            cb.setFontAndSize(bf, 14);
            cb.showTextAligned(PdfContentByte.ALIGN_CENTER, " ________________", width / 6, 44, 0);
            cb.showTextAligned(PdfContentByte.ALIGN_CENTER, " |               |", width / 6, 32, 0);
            cb.showTextAligned(PdfContentByte.ALIGN_CENTER, " |               |", width / 6, 22, 0);
            cb.showTextAligned(PdfContentByte.ALIGN_CENTER, " NR", width / 6, 28, 0);
            cb.showTextAligned(PdfContentByte.ALIGN_CENTER, " " + BN, width / 6, 16, 0);
            cb.showTextAligned(PdfContentByte.ALIGN_CENTER, " |               |", width / 6, 12, 0);
            cb.showTextAligned(PdfContentByte.ALIGN_CENTER, " ________________", width / 6, 14, 0);
            cb.endText();

        }

        montaraAquivo(caminhodestino).close();
        writer.close();
        reader.close();
        origem.delete();

    } catch (IOException | DocumentException ex) {
    }

}

From source file:Operaciones.Destajo.java

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
    // TODO add your handling code here:
    h = new Herramientas(usr, 0);
    h.session(sessionPrograma);//from  www . jav  a 2  s . c  o  m
    Session session = HibernateUtil.getSessionFactory().openSession();
    try {
        session.beginTransaction().begin();
        BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED);
        //Orden ord=buscaApertura();
        PDF reporte = new PDF();
        Date fecha = new Date();
        DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyyHH-mm-ss");//YYYY-MM-DD HH:MM:SS
        String valor = dateFormat.format(fecha);
        File folder = new File("reportes/" + ord);
        folder.mkdirs();
        reporte.Abrir(PageSize.LETTER.rotate(), "Valuacin", "reportes/" + ord + "/" + valor + "-destajo.pdf");
        Font font = new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD);
        BaseColor contenido = BaseColor.WHITE;
        int centro = Element.ALIGN_CENTER;
        int izquierda = Element.ALIGN_LEFT;
        int derecha = Element.ALIGN_RIGHT;
        float tam[] = new float[] { 150, 50, 100, 300 };
        PdfPTable tabla = reporte.crearTabla(4, tam, 100, Element.ALIGN_LEFT);

        DecimalFormat formatoPorcentaje = new DecimalFormat("#,##0.00");
        formatoPorcentaje.setMinimumFractionDigits(2);

        cabecera(reporte, bf, tabla);

        session.beginTransaction().begin();
        Orden dato = (Orden) session.get(Orden.class, Integer.parseInt(this.ord));
        List cuentas = null;
        for (int x = 0; x < t_datos.getRowCount(); x++) {
            tabla.addCell(reporte.celda(t_datos.getValueAt(x, 1).toString(), font, contenido, izquierda, 0, 1,
                    Rectangle.RECTANGLE));
            tabla.addCell(reporte.celda(formatoPorcentaje.format((Double) t_datos.getValueAt(x, 2)), font,
                    contenido, derecha, 0, 1, Rectangle.RECTANGLE));
            tabla.addCell(reporte.celda(formatoPorcentaje.format((Double) t_datos.getValueAt(x, 3)), font,
                    contenido, derecha, 0, 1, Rectangle.RECTANGLE));
            tabla.addCell(reporte.celda(t_datos.getValueAt(x, 4).toString(), font, contenido, izquierda, 0, 1,
                    Rectangle.RECTANGLE));
        }
        session.beginTransaction().rollback();

        tabla.setHeaderRows(1);
        reporte.agregaObjeto(tabla);
        reporte.cerrar();
        reporte.visualizar("reportes/" + ord + "/" + valor + "-destajo.pdf");

    } catch (Exception e) {
        System.out.println(e);
        e.printStackTrace();
        JOptionPane.showMessageDialog(this, "No se pudo realizar el reporte si el archivo esta abierto.");
    }
    if (session != null)
        if (session.isOpen()) {
            session.flush();
            session.clear();
            session.close();
        }
}