Beispiel #1
0
 PDFPage(PDFWriter @out, int parent, double width, double height)
 {
     _parent = parent;
     _id     = @out.allocateId(1);
     _width  = width;
     _height = height;
     _stream = new PDFStream(@out.allocateId(1));
 }
        public void writeStream(int id, PDFStream stream)

        {
            stream.flush();
            int length = stream.getLength();

            beginObject(id);
            println(" << /Length " + length + " >>");

            println("stream");
            stream.writeToStream(_out);
            _offset += length;
            println();
            println("endstream");
            endObject();
        }
        public bool begin_page(double width, double height)

        {
            if (PAGE_GROUP_SIZE <= _pageGroup.size())
            {
                _out.writePageGroup(_pageParentId, _rootId, _pageGroup);
                _pageGroup.clear();

                _pagesGroupList.add(_pageParentId);
                _pageParentId = _out.allocateId(1);
            }

            _page   = new PDFPage(_out, _pageParentId, width, height);
            _stream = _page.getStream();

            _pageCount++;

            _pageGroup.add(_page);

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