Example usage for com.itextpdf.text Font BOLD

List of usage examples for com.itextpdf.text Font BOLD

Introduction

In this page you can find the example usage for com.itextpdf.text Font BOLD.

Prototype

int BOLD

To view the source code for com.itextpdf.text Font BOLD.

Click Source Link

Document

this is a possible style.

Usage

From source file:com.carfinance.module.common.controller.DocumentDownloadController.java

/**
 * ??/* ww  w.  j  ava2 s  . c o m*/
 * @param model
 * @param request
 * @param response
 */
@RequestMapping(value = "/pdfhunchecontrace", method = RequestMethod.GET)
public void pdfHuncheContrace(Model model, HttpServletRequest request, HttpServletResponse response) {
    String contrace_id_str = request.getParameter("contrace_id");

    String org_id = "";
    String contrace_no = "";
    String customer_name = "";
    String vehicle_id = "";
    String daily_available_km = "";

    VehicleContraceInfo vehicleContraceInfo = this.vehicleServiceManageService
            .getVehicleContraceInfoById(Long.valueOf(contrace_id_str));
    if (vehicleContraceInfo != null) {
        org_id = String.valueOf(vehicleContraceInfo.getOrg_id());
        contrace_no = vehicleContraceInfo.getContrace_no();
        customer_name = vehicleContraceInfo.getCustomer_name();
        daily_available_km = vehicleContraceInfo.getDaily_available_km() + "";
    } else {
        PropertyContraceInfo propertyContraceInfo = this.vehicleServiceManageService
                .getPropertyContraceInfoById(Long.valueOf(contrace_id_str));
        if (propertyContraceInfo != null) {
            org_id = String.valueOf(propertyContraceInfo.getOrg_id());
            contrace_no = propertyContraceInfo.getContrace_no();
            customer_name = propertyContraceInfo.getCustomer_name();
        }
    }

    List<VehicleContraceVehsInfo> vehicleContraceVehsInfoList = this.vehicleServiceManageService
            .getVehicleContraceVehsListByContraceId(Long.valueOf(contrace_id_str));

    //1.ContentType
    response.setContentType("multipart/form-data");
    //2.????(??a.pdf)
    response.setHeader("Content-Disposition", "attachment;fileName=" + contrace_no + ".pdf");

    Document pdfDoc = new Document(PageSize.A4, 50, 50, 50, 50);
    // ?? pdf ?
    try {
        BaseFont bfChinese = BaseFont.createFont("STSongStd-Light", "UniGB-UCS2-H", false);

        Font bold_fontChinese = new Font(bfChinese, 18, Font.BOLD, BaseColor.BLACK);
        Font normal_fontChinese = new Font(bfChinese, 12, Font.NORMAL, BaseColor.BLACK);
        Font normal_desc_fontChinese = new Font(bfChinese, 6, Font.NORMAL, BaseColor.BLACK);

        FileOutputStream pdfFile = new FileOutputStream(
                new File(appProps.get("hunche.contrace.download.path") + contrace_no + ".pdf"));
        // pdf ?
        Paragraph paragraph1 = new Paragraph("???", bold_fontChinese);
        paragraph1.setAlignment(Element.ALIGN_CENTER);

        Paragraph paragraph2 = new Paragraph(
                "???", normal_fontChinese);
        Paragraph paragraph3 = new Paragraph("" + customer_name + " (",
                normal_fontChinese);
        Paragraph paragraph4 = new Paragraph(
                "?????________________???",
                normal_fontChinese);
        Paragraph paragraph5 = new Paragraph("??????",
                normal_fontChinese);
        // table
        PdfPTable table = new PdfPTable(4);
        table.setWidthPercentage(100);
        table.setHorizontalAlignment(PdfPTable.ALIGN_LEFT);
        PdfPCell cell = new PdfPCell();
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        // 
        cell.setPhrase(new Paragraph("?", normal_fontChinese));
        table.addCell(cell);
        cell.setPhrase(new Paragraph("", normal_fontChinese));
        table.addCell(cell);
        cell.setPhrase(new Paragraph("?/", normal_fontChinese));
        table.addCell(cell);
        cell.setPhrase(new Paragraph("?", normal_fontChinese));
        table.addCell(cell);
        // ?
        for (VehicleContraceVehsInfo v : vehicleContraceVehsInfoList) {

            PdfPCell newcell = new PdfPCell();
            newcell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            newcell.setPhrase(new Paragraph("1", normal_fontChinese));
            table.addCell(newcell);
            newcell.setPhrase(new Paragraph(v.getModel(), normal_fontChinese));
            table.addCell(newcell);
            newcell.setPhrase(new Paragraph(v.getDaily_price() + "", normal_fontChinese));
            table.addCell(newcell);
            newcell.setPhrase(new Paragraph(daily_available_km, normal_fontChinese));
            table.addCell(newcell);
        }

        Paragraph paragraph6 = new Paragraph(
                "??_________________________________________________________________",
                normal_fontChinese);
        Paragraph paragraph7 = new Paragraph(
                "____________________________?______",
                normal_fontChinese);
        Paragraph paragraph8 = new Paragraph("????", normal_fontChinese);
        Paragraph paragraph9 = new Paragraph(
                "???________________________???________________________",
                normal_fontChinese);
        Paragraph paragraph10 = new Paragraph("?", normal_fontChinese);
        Paragraph paragraph11 = new Paragraph(
                "???????????????",
                normal_fontChinese);
        Paragraph paragraph12 = new Paragraph("?", normal_fontChinese);
        Paragraph paragraph13 = new Paragraph(
                "??????????????",
                normal_fontChinese);
        Paragraph paragraph14 = new Paragraph(
                "?????????",
                normal_fontChinese);
        Paragraph paragraph15 = new Paragraph("?????",
                normal_fontChinese);
        Paragraph paragraph16 = new Paragraph(
                "(/)                                       (/)",
                normal_fontChinese);
        Paragraph paragraph17 = new Paragraph(
                "                                                      ??", normal_fontChinese);
        Paragraph paragraph18 = new Paragraph(
                "??                                               ??  ",
                normal_fontChinese);
        Paragraph paragraph19 = new Paragraph(
                "                                                      201          ",
                normal_fontChinese);

        //  Document ?File  PdfWriter ?
        PdfWriter.getInstance(pdfDoc, pdfFile);
        pdfDoc.open(); //  Document 

        // ??
        pdfDoc.add(paragraph1);
        pdfDoc.add(new Chunk("\n\n"));
        pdfDoc.add(paragraph2);
        pdfDoc.add(paragraph3);
        pdfDoc.add(paragraph4);
        pdfDoc.add(paragraph5);
        pdfDoc.add(table);
        pdfDoc.add(paragraph6);
        pdfDoc.add(paragraph7);
        pdfDoc.add(paragraph8);
        pdfDoc.add(paragraph9);
        pdfDoc.add(paragraph10);
        pdfDoc.add(paragraph11);
        pdfDoc.add(paragraph12);
        pdfDoc.add(paragraph13);
        pdfDoc.add(paragraph14);
        pdfDoc.add(paragraph15);
        pdfDoc.add(paragraph16);
        pdfDoc.add(paragraph17);
        pdfDoc.add(paragraph18);
        pdfDoc.add(paragraph19);

        pdfDoc.close();

        ServletOutputStream out;
        //File(?download.pdf)
        File file = new File(appProps.get("hunche.contrace.download.path") + contrace_no + ".pdf");

        try {
            FileInputStream inputStream = new FileInputStream(file);
            //3.response?ServletOutputStream(out)
            out = response.getOutputStream();
            int b = 0;
            byte[] buffer = new byte[512];
            while (b != -1) {
                b = inputStream.read(buffer);
                //4.?(out)
                out.write(buffer, 0, b);
            }
            inputStream.close();
            out.close();
            out.flush();
        } catch (IOException e) {
            e.printStackTrace();
        }
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.centurylink.mdw.pdf.PdfExportHelper.java

License:Apache License

public PdfExportHelper(Project project) {
    super(project);
    chapterFont = FontFactory.getFont(FontFactory.TIMES, 20, Font.BOLD);
    sectionFont = FontFactory.getFont(FontFactory.TIMES, 16, Font.BOLD);
    subSectionFont = FontFactory.getFont(FontFactory.TIMES, 14, Font.BOLD);
    normalFont = FontFactory.getFont(FontFactory.TIMES, 12, Font.NORMAL);
    boldFont = FontFactory.getFont(FontFactory.TIMES, 12, Font.BOLD);
    fixedWidthFont = FontFactory.getFont(FontFactory.COURIER, 11, Font.NORMAL);
}

From source file:com.cib.statementstamper.windows.StatementStamperMainWindow.java

License:Open Source License

@Override
public void attach() {
    super.attach();
    try {//  w  w w. ja v  a2  s .  c o  m
        logo = Image
                .getInstance(StatementStamperMainWindow.class.getResource("/resources/images/cib_logo.jpg"));
        logo.setAlignment(Image.LEFT);
        logo.scalePercent(30);
        isplogo = Image
                .getInstance(StatementStamperMainWindow.class.getResource("/resources/images/isplogo.jpg"));
        isplogo.setAlignment(Image.LEFT);
        isplogo.scalePercent(50);
        baseFontArial = BaseFont.createFont("/resources/fonts/ARIAL.TTF", BaseFont.CP1250, BaseFont.EMBEDDED);
        myFontBase = BaseFont.createFont("/resources/fonts/courbd.ttf", BaseFont.CP1250, BaseFont.EMBEDDED);
        bottomFont = new Font(baseFontArial, 7, Font.NORMAL, BaseColor.BLACK);
        bottomFontBold = new Font(baseFontArial, 7, Font.BOLD, BaseColor.BLACK);
    } catch (DocumentException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    upload.addListener((Upload.SucceededListener) this);
    upload.addListener((Upload.StartedListener) this);
    upload.addListener((Upload.FinishedListener) this);
    upload.addListener((Upload.FailedListener) this);
    upload.setImmediate(true);
    addComponent(upload);
}

From source file:com.coast.PDFPrinter_iText.java

License:Apache License

/**
 * Prints the document at its actual size. This is the recommended way to print.
 *//*ww  w  .ja  va2  s .c  om*/
private static void print(String pFileName, String pPayload) throws IOException, Exception {
    Document document = new Document();
    // step 2
    PdfWriter.getInstance(document, new FileOutputStream(pFileName));
    // step 3
    document.open();
    // step 4
    String _dateTime = LocalDateTime.now().toString();
    document.addTitle("List of All Customers & their assets as of: " + _dateTime);
    document.addCreationDate();
    document.addSubject("List of All Customers & their assets as of: " + _dateTime);

    Font _font = new Font();
    _font.setColor(BaseColor.BLUE);
    _font.setStyle(Font.BOLD);
    _font.setSize(15);

    Chunk _chunk = new Chunk("List of All Customers & their assets as of: " + _dateTime);
    _chunk.setFont(_font);
    Paragraph _header = new Paragraph();
    _header.add(_chunk);
    document.add(_header);
    document.add(new Paragraph(pPayload));

    // step 5
    document.close();
}

From source file:com.coderbd.pos.pdf.CodePDF.java

public boolean genCodeVer2Pdf() throws UnsupportedEncodingException {

    if (isFixedRated == true) {
        barcodeQuantity = 12;/*from ww  w.  jav a 2s . co  m*/
    } else {
        barcodeQuantity = 15;
    }

    try {
        String filename = "";

        if (isFixedRated) {
            filename = directory + "\\" + product.getProductBarcode() + "_FIXED_TK" + ".pdf";
        } else {
            filename = directory + "\\" + product.getProductBarcode() + ".pdf";
        }

        Document document = new Document(PageSize.A4);
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(filename));
        document.open();
        PdfContentByte cb = writer.getDirectContent();
        Barcode128 code25 = new Barcode128();
        code25.setGenerateChecksum(true);
        code25.setCode(product.getProductBarcode());
        code25.setSize(10f);
        code25.setX(1.50f);

        PdfPTable pdfPTable = new PdfPTable(7);
        pdfPTable.setWidthPercentage(98);
        float[] widths = { 0.22f, 0.04f, 0.22f, 0.04f, 0.22f, 0.04f, 0.22f };
        pdfPTable.setWidths(widths);
        String codeName = getCodeName(product.getShop().getShopName(), product.getShop().getShopId(),
                (int) product.getProductBuyRate());

        System.out.println("BarCodeName:" + codeName);

        Image image = code25.createImageWithBarcode(cb, null, null);

        Font titleArialFont = FontFactory.getFont("Arial", BaseFont.WINANSI, BaseFont.EMBEDDED, 8, Font.NORMAL);
        Font priceFont = FontFactory.getFont("Arial", BaseFont.WINANSI, BaseFont.EMBEDDED, 8, Font.BOLD);

        Paragraph paragraph = new Paragraph(codeName, titleArialFont);
        paragraph.setSpacingBefore(10.0f);
        PdfPCell title = new PdfPCell(paragraph);
        title.setBorder(Rectangle.NO_BORDER);

        Paragraph fixedTKParagraph = new Paragraph("FIXED TK: " + product.getProductSellRate(), priceFont);
        PdfPCell fixedRateCell = new PdfPCell(fixedTKParagraph);
        fixedRateCell.setBorder(Rectangle.NO_BORDER);

        PdfPCell barcodeCell = new PdfPCell(image, true);
        barcodeCell.setBorder(Rectangle.NO_BORDER);

        PdfPCell blank = new PdfPCell();
        blank.setBorder(Rectangle.NO_BORDER);

        Paragraph blankParagraph = new Paragraph("-                           -");
        PdfPCell pdfPCellBlank = new PdfPCell(blankParagraph);
        pdfPCellBlank.setBorder(Rectangle.NO_BORDER);

        for (int i = 0; i < barcodeQuantity; i++) {
            /**
             * This is for barcode pdf title
             */
            pdfPTable.addCell(title);
            pdfPTable.addCell(blank);
            pdfPTable.addCell(title);
            pdfPTable.addCell(blank);
            pdfPTable.addCell(title);
            pdfPTable.addCell(blank);
            pdfPTable.addCell(title);

            /**
             * This is for barcode image
             */
            pdfPTable.addCell(barcodeCell);
            pdfPTable.addCell(blank);
            pdfPTable.addCell(barcodeCell);
            pdfPTable.addCell(blank);
            pdfPTable.addCell(barcodeCell);
            pdfPTable.addCell(blank);
            pdfPTable.addCell(barcodeCell);
            /**
             *
             */
            if (isFixedRated == true) {
                pdfPTable.addCell(fixedRateCell);
                pdfPTable.addCell(blank);
                pdfPTable.addCell(fixedRateCell);
                pdfPTable.addCell(blank);
                pdfPTable.addCell(fixedRateCell);
                pdfPTable.addCell(blank);
                pdfPTable.addCell(fixedRateCell);
            }
            /**
             * Blank space after barcode image
             */
            pdfPTable.addCell(pdfPCellBlank);
            pdfPTable.addCell(blank);
            pdfPTable.addCell(pdfPCellBlank);
            pdfPTable.addCell(blank);
            pdfPTable.addCell(pdfPCellBlank);
            pdfPTable.addCell(blank);
            pdfPTable.addCell(pdfPCellBlank);
        }
        document.add(pdfPTable);
        document.add(new Paragraph(
                "Shop Name: " + product.getShop().getShopName() + ", Name:" + product.getProductName()
                        + "\n,Qty: " + product.getProductStock() + ", " + new Date().toString(),
                titleArialFont));
        document.close();
        return true;
    } catch (DocumentException | FileNotFoundException dex) {
        System.out.println(dex.getMessage());
        return false;
    }
}

From source file:com.coderbd.pos.pdf.OrderReportPDF.java

public boolean genPdf() throws UnsupportedEncodingException {
    List<SupplierOrderProductReport> soprs = sor.getSupplierOrderProductReports();
    IDBuilder idBuilder = new IDBuilder();
    Font innerFont = FontFactory.getFont("Arial", BaseFont.WINANSI, BaseFont.EMBEDDED, 8, Font.NORMAL);
    Font headerFont = FontFactory.getFont("Arial", BaseFont.WINANSI, BaseFont.EMBEDDED, 8, Font.BOLD);
    try {//from www.  jav a2  s  .  co  m
        String timestamp = idBuilder.getUniqueTimeStampID();
        String filename = sor.getSupplier().getSupplierName() + "_O" + sor.getSupplierOrderId() + "_"
                + timestamp + ".pdf";
        String filePath = directory + "\\" + filename;

        Document document = new Document(PageSize.A4);
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(filePath));
        document.open();

        PdfPTable pdfPTable = new PdfPTable(5);

        pdfPTable.setWidthPercentage(90);
        float[] widths = { 0.40f, 0.13f, 0.15f, 0.15f, 0.17f };
        pdfPTable.addCell(new Paragraph("Product Name", headerFont));
        pdfPTable.addCell(new Paragraph("Buy Rate", headerFont));
        pdfPTable.addCell(new Paragraph("Primary Qty", headerFont));
        pdfPTable.addCell(new Paragraph("Unsold Qty", headerFont));
        pdfPTable.addCell(new Paragraph("Unsold Amount", headerFont));

        pdfPTable.setWidths(widths);
        for (SupplierOrderProductReport sopr : soprs) {

            SupplierOrderProduct sop = sopr.getSupplierOrderProduct();
            String name = sop.getSupplierProductName();
            Double rate = sop.getSupplierRate();
            Integer pQty = sop.getSupplierProductQuantity();
            Integer unQty = sopr.getUnSoldProductQuantity();
            Double unAmount = sopr.getUnSoldProductAmount();

            Paragraph nameParag = new Paragraph(name, innerFont);
            Paragraph buyRateParag = new Paragraph(rate.toString(), innerFont);
            Paragraph primaryQuantityParag = new Paragraph(pQty.toString(), innerFont);
            Paragraph unsoldQuantityParag = new Paragraph(unQty.toString(), innerFont);
            Paragraph unsoldAmountParag = new Paragraph(unAmount.toString(), innerFont);

            PdfPCell nameCell = new PdfPCell(nameParag);
            PdfPCell buyRateCell = new PdfPCell(buyRateParag);
            PdfPCell primaryQuantityCell = new PdfPCell(primaryQuantityParag);
            PdfPCell unsoldQuantityCell = new PdfPCell(unsoldQuantityParag);
            PdfPCell unsoldAmountCell = new PdfPCell(unsoldAmountParag);

            pdfPTable.addCell(nameCell);
            pdfPTable.addCell(buyRateCell);
            pdfPTable.addCell(primaryQuantityCell);
            pdfPTable.addCell(unsoldQuantityCell);
            pdfPTable.addCell(unsoldAmountCell);
        }
        document.add(getHeader());

        document.add(pdfPTable);
        document.add(getFooter());
        document.add(new Paragraph("            Report Generated: " + new Date().toString(), innerFont));
        document.close();
        return true;
    } catch (DocumentException | FileNotFoundException dex) {
        System.out.println(dex.getMessage());
        return false;
    }
}

From source file:com.coderbd.pos.pdf.OrderReportPDF.java

public PdfPTable getFooter() throws DocumentException {
    Font innerFont = FontFactory.getFont("Arial", BaseFont.WINANSI, BaseFont.EMBEDDED, 8, Font.NORMAL);
    Font headerFont = FontFactory.getFont("Arial", BaseFont.WINANSI, BaseFont.EMBEDDED, 8, Font.BOLD);

    PdfPTable pdfPTableFooter = new PdfPTable(2);
    pdfPTableFooter.setWidthPercentage(90);
    float[] widthsFooter = { 0.80f, 0.20f };
    pdfPTableFooter.setWidths(widthsFooter);

    Paragraph totalSoldPara = new Paragraph("Total Sold: " + sor.getOrderTotalSoldAmount().toString(),
            headerFont);//from  ww w.  j  a  va2 s  . c o m
    PdfPCell totalSoldCell = new PdfPCell(totalSoldPara);
    totalSoldCell.setBorder(Rectangle.NO_BORDER);

    Paragraph totalUnSoldPara = new Paragraph("Total UnSold: " + sor.getOrderTotalUnsoldAmount().toString(),
            headerFont);
    PdfPCell totalUnSoldCell = new PdfPCell(totalUnSoldPara);
    totalUnSoldCell.setBorder(Rectangle.NO_BORDER);

    Paragraph blankPara = new Paragraph("");
    PdfPCell blankCell = new PdfPCell(blankPara);
    blankCell.setBorder(Rectangle.NO_BORDER);

    Double bill = sor.getTotalBill();
    Double paid = sor.getTotalPaid();
    Double due = bill - paid;

    Paragraph billPara = new Paragraph("BILL: " + bill.toString(), headerFont);
    PdfPCell billCell = new PdfPCell(billPara);
    billCell.setBorder(Rectangle.NO_BORDER);

    Paragraph paidPara = new Paragraph("PAID: " + paid.toString(), headerFont);
    PdfPCell paidCell = new PdfPCell(paidPara);
    paidCell.setBorder(Rectangle.NO_BORDER);

    Paragraph duePara = new Paragraph("DUE: " + due.toString(), headerFont);
    PdfPCell dueCell = new PdfPCell(duePara);
    dueCell.setBorder(Rectangle.NO_BORDER);

    pdfPTableFooter.addCell(totalSoldCell);
    pdfPTableFooter.addCell(billCell);
    pdfPTableFooter.addCell(totalUnSoldCell);
    pdfPTableFooter.addCell(paidCell);
    pdfPTableFooter.addCell(blankCell);
    pdfPTableFooter.addCell(dueCell);

    return pdfPTableFooter;
}

From source file:com.coderbd.pos.pdf.OrderReportPDF.java

public PdfPTable getHeader() throws DocumentException {
    Font innerFont = FontFactory.getFont("Arial", BaseFont.WINANSI, BaseFont.EMBEDDED, 8, Font.NORMAL);
    Font headerFont = FontFactory.getFont("Arial", BaseFont.WINANSI, BaseFont.EMBEDDED, 12, Font.BOLD);

    PdfPTable tableHeader = new PdfPTable(1);
    tableHeader.setWidthPercentage(90);//  w  w w .j av  a2 s .  c o  m

    Paragraph supplierNamePara = new Paragraph(sor.getSupplier().getSupplierName(), headerFont);
    Paragraph addressPara = new Paragraph(sor.getSupplier().getSupplierAddress(), innerFont);
    Paragraph mobilePara = new Paragraph("Mobile: " + sor.getSupplier().getSupplierMobile(), innerFont);
    Paragraph orderPara = new Paragraph("Order: " + sor.getSupplierOrderId() + ", Time: " + sor.getOrderTime(),
            innerFont);

    PdfPCell supplierNameCell = new PdfPCell();
    supplierNameCell.setVerticalAlignment(PdfPCell.ALIGN_CENTER);
    supplierNameCell.setBorder(Rectangle.NO_BORDER);
    supplierNameCell.addElement(supplierNamePara);

    PdfPCell addressCell = new PdfPCell();
    addressCell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    addressCell.setBorder(Rectangle.NO_BORDER);
    addressCell.addElement(addressPara);

    PdfPCell mobileCell = new PdfPCell(mobilePara);
    mobileCell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    mobileCell.setBorder(Rectangle.NO_BORDER);
    mobileCell.addElement(mobilePara);

    PdfPCell orderCell = new PdfPCell(orderPara);
    orderCell.setBorder(Rectangle.NO_BORDER);

    PdfPCell bCell = new PdfPCell(new Paragraph(" "));
    bCell.setBorder(Rectangle.NO_BORDER);

    tableHeader.addCell(supplierNameCell);
    tableHeader.addCell(addressCell);
    tableHeader.addCell(mobileCell);
    tableHeader.addCell(orderCell);
    tableHeader.addCell(bCell);

    return tableHeader;
}

From source file:com.cs.sis.controller.gerador.GeradorPDF.java

public String gerarPdfDaVenda(Venda v, List<ItemDeVenda> itens, File destino) throws IOException {
    Document doc = new Document();

    try {//from  w w  w.  j a  v  a2s.  co m
        String path = a.getRelatorio().getCanonicalPath() + "/Venda_" + v.getId() + ".pdf";
        PdfWriter.getInstance(doc, new FileOutputStream(path));
        doc.open();
        String subTitulo = "Venda Realizada no dia "
                + new SimpleDateFormat("dd/MM/yyyy HH:mm").format(v.getDia().getTime());
        try {
            inserirHead(doc, "Venda do Cliente " + v.getCliente().getNome(), subTitulo);
        } catch (NullPointerException ne) {
            inserirHead(doc, "Venda  vista ID: " + v.getId(), subTitulo);
        }

        PdfPTable table = getTableDeItens(itens);

        doc.add(table);

        Paragraph p2 = new Paragraph("Total: " + new DecimalFormat("0.00").format(v.getTotal())
                + " \n Funcionrio: " + v.getFuncionario().getNome(),
                new Font(Font.FontFamily.COURIER, 16, Font.BOLD));
        doc.add(p2);

        doc.close();
        Arquivo.copyFile(new File(path), destino);
        return destino.getAbsolutePath();
    } catch (DocumentException e) {
        e.printStackTrace();
        return "";
    }

}

From source file:com.cs.sis.controller.gerador.GeradorPDF.java

public String gerarPdfDaVenda(Venda v, List<ItemDeVenda> itens) {
    Document doc = new Document();

    try {// w  w w.  j a  v a  2  s.c  om
        String path = a.getRelatorio().getCanonicalPath() + "/Venda_" + v.getId() + ".pdf";
        PdfWriter.getInstance(doc, new FileOutputStream(path));
        doc.open();
        String subTitulo = "Venda Realizada no dia "
                + new SimpleDateFormat("dd/MM/yyyy HH:mm").format(v.getDia().getTime());
        if (v.getCliente() != null) {
            inserirHead(doc, "Venda do Cliente " + v.getCliente().getNome(), subTitulo);
        } else {//venda a vista
            inserirHead(doc, "Venda  Vista", subTitulo);
        }

        PdfPTable table = getTableDeItens(itens);

        doc.add(table);

        Paragraph p2 = new Paragraph("Total: " + new DecimalFormat("0.00").format(v.getTotal())
                + " \n Funcionrio: " + v.getFuncionario().getNome(),
                new Font(Font.FontFamily.COURIER, 16, Font.BOLD));
        doc.add(p2);

        doc.close();
        return path;
    } catch (DocumentException | IOException e) {
        e.printStackTrace();
        return "";
    }

}