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();
        }