Example usage for com.itextpdf.text.html.simpleparser HTMLWorker LINK_PROVIDER

List of usage examples for com.itextpdf.text.html.simpleparser HTMLWorker LINK_PROVIDER

Introduction

In this page you can find the example usage for com.itextpdf.text.html.simpleparser HTMLWorker LINK_PROVIDER.

Prototype

String LINK_PROVIDER

To view the source code for com.itextpdf.text.html.simpleparser HTMLWorker LINK_PROVIDER.

Click Source Link

Document

Key used to store the link provider in the providers map.

Usage

From source file:com.masscustsoft.service.ToPdf.java

License:Open Source License

/**
 * Adds a link to the current paragraph.
 * @since 5.0.6//from  w w  w.java  2  s.c  o  m
 */
public void processLink() {
    if (currentParagraph == null) {
        currentParagraph = new Paragraph();
    }
    // The link provider allows you to do additional processing
    LinkProcessor i = (LinkProcessor) providers.get(HTMLWorker.LINK_PROVIDER);
    if (i == null || !i.process(currentParagraph, chain)) {
        // sets an Anchor for all the Chunks in the current paragraph
        String href = chain.getProperty(HtmlTags.HREF);
        if (href != null) {
            for (Chunk ck : currentParagraph.getChunks()) {
                ck.setAnchor(href);
            }
        }
    }
    // a link should be added to the current paragraph as a phrase
    if (stack.isEmpty()) {
        // no paragraph to add too, 'a' tag is first element
        Paragraph tmp = new Paragraph(new Phrase(currentParagraph));
        currentParagraph = tmp;
    } else {
        Paragraph tmp = (Paragraph) stack.pop();
        tmp.add(new Phrase(currentParagraph));
        currentParagraph = tmp;
    }
}