public int add_page_to_outline(String title, double pos, int parentId)
        {
            if (_outline == null)
            {
                int outlineId = _out.allocateId(1);
                _outline = new PDFOutline(outlineId);
            }

            int id = _out.allocateId(1);

            PDFDestination dest = new PDFDestination(id,
                                                     title,
                                                     _page.getId(),
                                                     pos);

            _outline.addDestination(dest, parentId);

            return(id);
        }
        public void addDestination(PDFDestination dest, int parentId)
        {
            PDFDestination parent = null;

            if (parentId > 0)
            {
                parent = _allDestinations.get(parentId);
            }

            if (parent != null)
            {
                parent.addChild(dest);
            }
            else
            {
                dest.setParentId(_id);
                _rootDestinations.add(dest);
            }

            _allDestinations.put(dest.getId(), dest);
        }
        private void writeOutlineItem(List <PDFDestination> destinations, int index)

        {
            PDFDestination dest = destinations.get(index);

            List <PDFDestination> children = dest.getChildren();

            for (int i = 0; i < children.size(); i++)
            {
                writeOutlineItem(children, i);
            }

            beginObject(dest.getId());

            println("  << /Title (" + PDFStream.pdfEscapeText(dest.getTitle()) + ")");
            println("     /Parent " + dest.getParentId() + " 0 R");
            println("     /Dest [" + dest.getPageId() + " 0 R /XYZ 0 " + dest.getPos() + " 0]");

            if (index > 0)
            {
                println("     /Prev " + destinations.get(index - 1).getId() + " 0 R");
            }

            if (index < (destinations.size() - 1))
            {
                println("     /Next " + destinations.get(index + 1).getId() + " 0 R");
            }

            if (!children.isEmpty())
            {
                println("     /First " + children.get(0).getId() + " 0 R");
                println("     /Last " + children.get(children.size() - 1).getId() + " 0 R");
                println("     /Count " + (children.size() * -1));
            }

            println("  >>");

            endObject();
        }
Beispiel #4
0
 public void addChild(PDFDestination child)
 {
     child.setParentId(_id);
     _children.add(child);
 }