⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pdfdocument.java

📁 一个java操作pdf文件的开发包,很好用的.
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
                        case Annotation.URL_NET:                            annotations.add(new PdfAnnotation(writer, annot.llx(), annot.lly(), annot.urx(), annot.ury(), new PdfAction((URL) annot.attributes().get(Annotation.URL))));                            break;                        case Annotation.URL_AS_STRING:                            annotations.add(new PdfAnnotation(writer, annot.llx(), annot.lly(), annot.urx(), annot.ury(), new PdfAction((String) annot.attributes().get(Annotation.FILE))));                            break;                        case Annotation.FILE_DEST:                            annotations.add(new PdfAnnotation(writer, annot.llx(), annot.lly(), annot.urx(), annot.ury(), new PdfAction((String) annot.attributes().get(Annotation.FILE), (String) annot.attributes().get(Annotation.DESTINATION))));                            break;                        case Annotation.FILE_PAGE:                            annotations.add(new PdfAnnotation(writer, annot.llx(), annot.lly(), annot.urx(), annot.ury(), new PdfAction((String) annot.attributes().get(Annotation.FILE), ((Integer) annot.attributes().get(Annotation.PAGE)).intValue())));                            break;                        case Annotation.NAMED_DEST:                            annotations.add(new PdfAnnotation(writer, annot.llx(), annot.lly(), annot.urx(), annot.ury(), new PdfAction(((Integer) annot.attributes().get(Annotation.NAMED)).intValue())));                            break;                        case Annotation.LAUNCH:                            annotations.add(new PdfAnnotation(writer, annot.llx(), annot.lly(), annot.urx(), annot.ury(), new PdfAction((String) annot.attributes().get(Annotation.APPLICATION),(String) annot.attributes().get(Annotation.PARAMETERS),(String) annot.attributes().get(Annotation.OPERATION),(String) annot.attributes().get(Annotation.DEFAULTDIR))));                            break;                        default:                            annotations.add(new PdfAnnotation(writer, annot.llx(indentRight() - line.widthLeft()), annot.lly(indentTop() - currentHeight), annot.urx(indentRight() - line.widthLeft() + 20), annot.ury(indentTop() - currentHeight - 20), new PdfString(annot.title()), new PdfString(annot.content())));                    }                    pageEmpty = false;                    break;                }                case Element.PHRASE: {                    // we cast the element to a phrase and set the leading of the document                    leading = ((Phrase) element).leading();                    // we process the element                    element.process(this);                    break;                }                case Element.PARAGRAPH: {                    // we cast the element to a paragraph                    Paragraph paragraph = (Paragraph) element;                                        // we adjust the parameters of the document                    alignment = paragraph.alignment();                    leading = paragraph.leading();                                        carriageReturn();                    // we don't want to make orphans/widows                    if (currentHeight + line.height() + leading > indentTop() - indentBottom()) {                        newPage();                    }                    indentLeft += paragraph.indentationLeft();                    indentRight += paragraph.indentationRight();                                        carriageReturn();                                        //add by Jin-Hsia Yang                    isParagraphE = true;                    paraIndent += paragraph.indentationLeft();                    //end add by Jin-Hsia Yang                                        PdfPageEvent pageEvent = writer.getPageEvent();                    if (pageEvent != null && isParagraph)                        pageEvent.onParagraph(writer, this, indentTop() - currentHeight);                                        // if a paragraph has to be kept together, we wrap it in a table object                    if (paragraph.getKeepTogether()) {                        Table table = new Table(1, 1);                        table.setOffset(0f);                        table.setBorder(Table.NO_BORDER);                        table.setWidth(100f);                        table.setTableFitsPage(true);                        Cell cell = new Cell(paragraph);                        cell.setBorder(Table.NO_BORDER);                        table.addCell(cell);                        this.add(table);                        break;                    }                    else                        // we process the paragraph                        element.process(this);                                        //add by Jin-Hsia Yang and blowagie                    paraIndent -= paragraph.indentationLeft();                    //end add by Jin-Hsia Yang and blowagie                                        carriageReturn();                                        if (pageEvent != null && isParagraph)                        pageEvent.onParagraphEnd(writer, this, indentTop() - currentHeight);                                        alignment = Element.ALIGN_LEFT;                    indentLeft -= paragraph.indentationLeft();                    indentRight -= paragraph.indentationRight();                                        //add by Jin-Hsia Yang                    isParagraphE = false;                    //end add by Jin-Hsia Yang                                        break;                }                case Element.SECTION:                case Element.CHAPTER: {                    // Chapters and Sections only differ in their constructor                    // so we cast both to a Section                    Section section = (Section) element;                                        // if the section is a chapter, we begin a new page                    if (section.isChapter()) {                        newPage();                    }                    // otherwise, we begin a new line                    else {                        newLine();                    }                    float fith = indentTop() - currentHeight;                    int rotation = pageSize.getRotation();                    if (rotation == 90 || rotation == 180)                        fith = pageSize.height() - fith;                    PdfDestination destination = new PdfDestination(PdfDestination.FITH, fith);                    while (currentOutline.level() >= section.depth()) {                        currentOutline = currentOutline.parent();                    }                    PdfOutline outline = new PdfOutline(currentOutline, destination, section.title(), section.isBookmarkOpen());                    currentOutline = outline;                                        // some values are set                    carriageReturn();                    indentLeft += section.indentationLeft();                    indentRight += section.indentationRight();                                        PdfPageEvent pageEvent = writer.getPageEvent();                    if (pageEvent != null)                        if (element.type() == Element.CHAPTER)                            pageEvent.onChapter(writer, this, indentTop() - currentHeight, section.title());                        else                            pageEvent.onSection(writer, this, indentTop() - currentHeight, section.depth(), section.title());                                        // the title of the section (if any has to be printed)                    if (section.title() != null) {                        isParagraph = false;                        add(section.title());                        isParagraph = true;                    }                    indentLeft += section.indentation();                    // we process the section                    element.process(this);                    // some parameters are set back to normal again                    indentLeft -= section.indentationLeft() + section.indentation();                    indentRight -= section.indentationRight();                                        if (pageEvent != null)                        if (element.type() == Element.CHAPTER)                            pageEvent.onChapterEnd(writer, this, indentTop() - currentHeight);                        else                            pageEvent.onSectionEnd(writer, this, indentTop() - currentHeight);                                        break;                }                case Element.LIST: {                    // we cast the element to a List                    List list = (List) element;                    // we adjust the document                    listIndentLeft += list.indentationLeft();                    indentRight += list.indentationRight();                    // we process the items in the list                    element.process(this);                    // some parameters are set back to normal again                    listIndentLeft -= list.indentationLeft();                    indentRight -= list.indentationRight();                    break;                }                case Element.LISTITEM: {                    // we cast the element to a ListItem                    ListItem listItem = (ListItem) element;                    // we adjust the document                    alignment = listItem.alignment();                    listIndentLeft += listItem.indentationLeft();                    indentRight += listItem.indentationRight();                    leading = listItem.leading();                    carriageReturn();                    // we prepare the current line to be able to show us the listsymbol                    line.setListItem(listItem);                    // we process the item                    element.process(this);                    // if the last line is justified, it should be aligned to the left                    //				if (line.hasToBeJustified()) {                    //					line.resetAlignment();                    //				}                    // some parameters are set back to normal again                    carriageReturn();                    listIndentLeft -= listItem.indentationLeft();                    indentRight -= listItem.indentationRight();                    break;                }                case Element.RECTANGLE: {                    Rectangle rectangle = (Rectangle) element;                    graphics.rectangle(rectangle);                    pageEmpty = false;                    break;                }                case Element.PTABLE: {                    // before every table, we add a new line and flush all lines                    newLine();                    flushLines();                    PdfPTable ptable = (PdfPTable)element;                    float totalWidth = (indentRight() - indentLeft()) * ptable.getWidthPercentage() / 100;                    float xWidth = 0;                    switch (ptable.getHorizontalAlignment()) {                        case Element.ALIGN_LEFT:                            xWidth = indentLeft();                            break;                        case Element.ALIGN_RIGHT:                            xWidth = indentRight() - totalWidth;                            break;                        default:                            xWidth = (indentRight() + indentLeft() - totalWidth) / 2;                    }                    ptable.setTotalWidth(totalWidth);                    addPTable(ptable, xWidth);                                        break;                }                case Element.TABLE : {                                        /**                     * This is a list of people who worked on the Table functionality.                     * To see who did what, please check the CVS repository:                     *                     * Leslie Baski                     * Matt Benson                     * Francesco De Milato                     * David Freels                     * Bruno Lowagie                     * Veerendra Namineni                     * Geert Poels                     * Tom Ring                     * Paulo Soares                     * Gerald Fehringer                     */                                        // correct table : fill empty cells/ parse table in table                    ((Table) element).complete();                                        // before every table, we add a new line and flush all lines                    float offset = ((Table) element).getOffset();                    if (Float.isNaN(offset))                        offset = leading;                    carriageReturn();                    lines.add(new PdfLine(indentLeft(), indentRight(), alignment, offset));                    currentHeight += offset;                    flushLines();                                        // initialisation of parameters                    float pagetop = indentTop();                    float oldHeight = currentHeight;                    float cellDisplacement;                    PdfCell cell;                    PdfContentByte cellGraphics = new PdfContentByte(writer);                                        // constructing the PdfTable                    PdfTable table =                    new PdfTable(                    (Table) element,                    indentLeft(),                    indentRight(),                    currentHeight > 0 ? (pagetop - currentHeight) - 6 : pagetop);                                        boolean tableHasToFit =                    ((Table) element).hasToFitPageTable() ? table.bottom() < indentBottom() : false;                    if (pageEmpty)                        tableHasToFit = false;                    boolean cellsHaveToFit = ((Table) element).hasToFitPageCells();                                        // drawing the table                    ArrayList cells = table.getCells();                    ArrayList headercells = null;                    while (!cells.isEmpty()) {                        // initialisation of some extra parameters;                        float lostTableBottom = 0;                                                // loop over the cells                        boolean cellsShown = false;                        int currentGroupNumber = 0;                        boolean headerChecked = false;                        for (ListIterator iterator = cells.listIterator(); iterator.hasNext() && !tableHasToFit;) {                            cell = (PdfCell) iterator.next();                            if( cellsHaveToFit ) {                                if( !cell.isHeader() ) {                                    if (cell.getGroupNumber() != currentGroupNumber) {                                        boolean cellsFit = true;                                        currentGroupNumber = cell.getGroupNumber();                                        int cellCount = 0;                                        while (cell.getGroupNumber() == currentGroupNumber && cellsFit && iterator.hasNext()) {                                            if (cell.bottom() < indentBottom()) {                                                cellsFit = false;                                            }                                            cell = (PdfCell) iterator.next();                                            cellCount++;                                        }                                        if (!cellsFit) {                                            break;                                        }                                        for (int i = cellCount; i >= 0; i--) {                                            cell = (PdfCell) iterator.previous();                                        }                                    }                                }                                else {                                    if( !headerChecked ) {                                        headerChecked = true;                                        boolean cellsFit = true;                                        int cellCount = 0;                                        float firstTop = cell.top();                                        while (cell.isHeader() && cellsFit && iterator.hasNext()) {                                            if (firstTop - cell.bottom(0) > indentTop() - currentHeight - indentBottom()) {                                                cellsFit = false;                                            }                                            cell = (PdfCell) iterator.next();                                            cellCount++;                                        }                                        currentGroupNumber = cell.getGroupNumber();                                        while (cell.getGroupNumber() == cur

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -