Example usage for com.itextpdf.text Chapter setNumberDepth

List of usage examples for com.itextpdf.text Chapter setNumberDepth

Introduction

In this page you can find the example usage for com.itextpdf.text Chapter setNumberDepth.

Prototype

public void setNumberDepth(final int numberDepth) 

Source Link

Document

Sets the depth of the sectionnumbers that will be shown preceding the title.

Usage

From source file:project1.SimplePdf.java

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    // TODO add your handling code here:

    int id;//  w w  w .  j  a  va 2s. c om
    String name;
    id = Integer.parseInt(txtid.getText());
    name = txtname.getText();

    try {

        OutputStream file = new FileOutputStream(new File("F:\\PDFFILES\\" + id + ".pdf"));

        Document document = new Document();
        PdfWriter.getInstance(document, file);

        document.open();
        //     Image im=Image.getInstance("E:\\PDFFILES\\FUUAST.png");
        //   document.add(new Paragraph(""));
        // document.add(im);
        Paragraph title1 = new Paragraph(name + id,

                FontFactory.getFont(FontFactory.HELVETICA,

                        36, Font.BOLDITALIC, new CMYKColor(0, 255, 255, 17)));

        Chapter chapter1 = new Chapter(title1, 1);

        chapter1.setNumberDepth(0);
        document.add(chapter1);

        document.add(new Paragraph("\n\n\n\n"));
        document.add(new Paragraph("Name: " + name));
        document.add(new Paragraph("Id: " + id));

        try {
            Desktop desktop = Desktop.getDesktop();
            if (desktop.isSupported(Desktop.Action.OPEN)) {
                desktop.open(new File("D:\\PDFFILES\\" + id + ".pdf"));
            } else {
                System.out.println("Open is not supported");
            }
        } catch (IOException exp) {
            exp.printStackTrace();
        }
        document.close();
        file.close();

    } catch (Exception e) {

        e.printStackTrace();
    }

}