Example usage for com.itextpdf.text.pdf PdfName L

List of usage examples for com.itextpdf.text.pdf PdfName L

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf PdfName L.

Prototype

PdfName L

To view the source code for com.itextpdf.text.pdf PdfName L.

Click Source Link

Document

A name

Usage

From source file:pdfpruefbericht.PdfPruefbericht.java

License:Open Source License

public static void main(String[] args)
        throws IOException, DocumentException, SAXException, ParserConfigurationException, URISyntaxException {

    String RESULT = args[1];//from   ww w .ja  v a2s  . c  o m
    String RESOURCE = args[0];
    ContentParser cp;
    float compression;

    try {
        compression = Float.parseFloat(args[2]);
    } catch (NumberFormatException e) {
        System.out.println("Kompresion konnte nicht geparsed werden ... : " + e.getMessage());
        compression = 0.5f;
    }

    try {
        Document document = new Document(PageSize.A4);
        document.setMargins(36, 72, 36, 144);
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(RESULT));
        writer.setTagged();
        document.open();
        PdfStructureTreeRoot root = writer.getStructureTreeRoot();
        root.mapRole(new PdfName("Report"), PdfName.ROOT);
        root.mapRole(new PdfName("Norm"), PdfName.SECT);
        root.mapRole(new PdfName("Test"), PdfName.SEPARATION);
        root.mapRole(new PdfName("Comment"), PdfName.CO);
        root.mapRole(new PdfName("img"), PdfName.PI);
        root.mapRole(new PdfName("log"), PdfName.L);
        root.mapRole(new PdfName("Setup"), PdfName.SETTINGS);
        root.mapRole(new PdfName("device"), PdfName.D);
        root.mapRole(new PdfName("parameter"), PdfName.P);

        PdfStructureElement top = new PdfStructureElement(root, new PdfName("Report"));
        SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
        List<PdfStructureElement> elements = new ArrayList<>();
        cp = new ContentParser(document, writer, elements);
        parser.parse(new InputSource(new FileInputStream(RESOURCE)), new StructureParser(top, elements));
        parser.parse(new InputSource(new FileInputStream(RESOURCE)), cp);
        PdfBuilder pdf = new PdfBuilder(document, writer, cp.getReport(), compression);
        pdf.build();
        document.close();
    } catch (IOException | DocumentException | SAXException | ParserConfigurationException e) {
        System.out.println(e.getMessage());
    }
    //watermark watermark = new watermark();
}