Example usage for com.lowagie.text.pdf PdfAction gotoRemotePage

List of usage examples for com.lowagie.text.pdf PdfAction gotoRemotePage

Introduction

In this page you can find the example usage for com.lowagie.text.pdf PdfAction gotoRemotePage.

Prototype

public static PdfAction gotoRemotePage(String filename, String dest, boolean isName, boolean newWindow) 

Source Link

Document

Creates a GoToR action to a named destination.

Usage

From source file:org.eclipse.birt.report.engine.emitter.pdf.PDFPage.java

License:Open Source License

/**
 * Creates a PdfAction.//from ww  w.ja  v a2  s.com
 *
 * @param hyperlink
 *            the hyperlink.
 * @param bookmark
 *            the bookmark.
 * @param target
 *            if target equals "_blank", the target will be opened in a new
 *            window, else the target will be opened in the current window.
 * @return the created PdfAction.
 */
private PdfAction createPdfAction(String hyperlink, String bookmark, String target, int type) {
    // patch from Ales Novy
    if ("_top".equalsIgnoreCase(target) || "_parent".equalsIgnoreCase(target)
            || "_blank".equalsIgnoreCase(target) || "_self".equalsIgnoreCase(target))
    // Opens the target in a new window.
    {
        if (hyperlink == null)
            hyperlink = "";
        boolean isUrl = hyperlink.startsWith("http");
        if (!isUrl) {
            Matcher matcher = PAGE_LINK_PATTERN.matcher(hyperlink);
            if (matcher.find()) {
                String fileName = matcher.group(1);
                String pageNumber = matcher.group(matcher.groupCount());
                return new PdfAction(fileName, Integer.valueOf(pageNumber));
            }
        }
        return new PdfAction(hyperlink);
    } else

    // Opens the target in the current window.
    {
        if (type == IHyperlinkAction.ACTION_BOOKMARK) {
            return PdfAction.gotoLocalPage(bookmark, false);
        } else {
            return PdfAction.gotoRemotePage(hyperlink, bookmark, false, false);
        }
    }
}