Example usage for com.lowagie.text Paragraph getFirstLineIndent

List of usage examples for com.lowagie.text Paragraph getFirstLineIndent

Introduction

In this page you can find the example usage for com.lowagie.text Paragraph getFirstLineIndent.

Prototype

public float getFirstLineIndent() 

Source Link

Document

Getter for property firstLineIndent.

Usage

From source file:fr.opensagres.poi.xwpf.converter.pdf.internal.PdfMapper.java

License:Open Source License

@Override
protected void visitTabs(CTTabs tabs, IITextContainer pdfParagraphContainer) throws Exception {
    if (currentRunX == null) {
        Paragraph paragraph = null;
        if (pdfParagraphContainer instanceof Paragraph) {
            paragraph = (Paragraph) pdfParagraphContainer;
        } else {//from   www . j  a v a  2s  . c o  m
            paragraph = (Paragraph) ((StylableAnchor) pdfParagraphContainer).getITextContainer();
        }
        currentRunX = paragraph.getFirstLineIndent();
        List<Chunk> chunks = paragraph.getChunks();
        for (Chunk chunk : chunks) {
            currentRunX += chunk.getWidthPoint();
        }
    } else {
        if (currentRunX >= pdfDocument.getPageWidth()) {
            currentRunX = 0f;
        }
    }

    Float tabPosition = null;
    STTabTlc.Enum tabLeader = null;
    STTabJc.Enum tabVal = null;
    boolean useDefaultTabStop = false;
    if (tabs != null) {
        List<CTTabStop> tabList = tabs.getTabList();

        CTTabStop tabStop = getTabStop(tabList);
        if (tabStop != null) {

            float lastX = DxaUtil.dxa2points(tabStop.getPos().floatValue());
            if (lastX > currentRunX) {
                tabPosition = lastX;
                tabLeader = tabStop.getLeader();
                tabVal = tabStop.getVal();
            } else {
                useDefaultTabStop = true;
            }
        }
    }
    if (tabs == null || useDefaultTabStop) {
        // default tab
        float defaultTabStop = stylesDocument.getDefaultTabStop();
        float pageWidth = pdfDocument.getPageWidth();
        int nbInterval = (int) (pageWidth / defaultTabStop);
        Float lastX = getTabStopPosition(currentRunX, defaultTabStop, nbInterval);
        if (lastX != null) {
            tabPosition = lastX;
        }
    }

    if (tabPosition != null) {
        currentRunX = tabPosition;
        // tab leader : Specifies the character which shall be used to fill
        // in the space created by a tab
        // which
        // ends
        // at this custom tab stop. This character shall be repeated as
        // required to completely fill the
        // tab spacing generated by the tab character.
        VerticalPositionMark mark = createVerticalPositionMark(tabLeader);
        Chunk pdfTab = null;
        if (STTabJc.RIGHT.equals(tabVal)) {
            pdfTab = new Chunk(mark);
        } else {
            pdfTab = new Chunk(mark, currentRunX);
        }
        pdfParagraphContainer.addElement(pdfTab);
    }
}