From c68ad0ec056b37c82debebcecfcde1866d61b4d9 Mon Sep 17 00:00:00 2001 From: tknall Date: Tue, 25 Nov 2008 12:03:13 +0000 Subject: Removing pdfbox from source. git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/trunk@301 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- .../destination/PDDestination.java | 125 ------ .../destination/PDNamedDestination.java | 142 ------- .../destination/PDPageDestination.java | 155 -------- .../destination/PDPageFitDestination.java | 102 ----- .../destination/PDPageFitHeightDestination.java | 132 ------- .../destination/PDPageFitRectangleDestination.java | 188 --------- .../destination/PDPageFitWidthDestination.java | 134 ------- .../destination/PDPageXYZDestination.java | 159 -------- .../documentnavigation/destination/package.html | 9 - .../outline/PDDocumentOutline.java | 62 --- .../documentnavigation/outline/PDOutlineItem.java | 425 --------------------- .../documentnavigation/outline/PDOutlineNode.java | 320 ---------------- .../documentnavigation/outline/package.html | 9 - .../interactive/documentnavigation/package.html | 9 - 14 files changed, 1971 deletions(-) delete mode 100644 src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/destination/PDDestination.java delete mode 100644 src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/destination/PDNamedDestination.java delete mode 100644 src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/destination/PDPageDestination.java delete mode 100644 src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/destination/PDPageFitDestination.java delete mode 100644 src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/destination/PDPageFitHeightDestination.java delete mode 100644 src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/destination/PDPageFitRectangleDestination.java delete mode 100644 src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/destination/PDPageFitWidthDestination.java delete mode 100644 src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/destination/PDPageXYZDestination.java delete mode 100644 src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/destination/package.html delete mode 100644 src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/outline/PDDocumentOutline.java delete mode 100644 src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/outline/PDOutlineItem.java delete mode 100644 src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/outline/PDOutlineNode.java delete mode 100644 src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/outline/package.html delete mode 100644 src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/package.html (limited to 'src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation') diff --git a/src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/destination/PDDestination.java b/src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/destination/PDDestination.java deleted file mode 100644 index 98a0345..0000000 --- a/src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/destination/PDDestination.java +++ /dev/null @@ -1,125 +0,0 @@ -/** - * Copyright (c) 2004-2005, www.pdfbox.org - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of pdfbox; nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * http://www.pdfbox.org - * - */ -package org.pdfbox.pdmodel.interactive.documentnavigation.destination; - -import java.io.IOException; - -import org.pdfbox.cos.COSArray; -import org.pdfbox.cos.COSBase; -import org.pdfbox.cos.COSName; -import org.pdfbox.cos.COSString; - -import org.pdfbox.pdmodel.common.COSObjectable; - -/** - * This represents a destination in a PDF document. - * - * @author Ben Litchfield (ben@csh.rit.edu) - * @version $Revision: 1.4 $ - */ -public abstract class PDDestination implements COSObjectable -{ - - /** - * This will create a new destination depending on the type of COSBase - * that is passed in. - * - * @param base The base level object. - * - * @return A new destination. - * - * @throws IOException If the base cannot be converted to a Destination. - */ - public static PDDestination create( COSBase base ) throws IOException - { - PDDestination retval = null; - if( base == null ) - { - //this is ok, just return null. - } - else if( base instanceof COSArray && ((COSArray)base).size() > 0 ) - { - COSArray array = (COSArray)base; - COSName type = (COSName)array.getObject( 1 ); - String typeString = type.getName(); - if( typeString.equals( PDPageFitDestination.TYPE ) || - typeString.equals( PDPageFitDestination.TYPE_BOUNDED )) - { - retval = new PDPageFitDestination( array ); - } - else if( typeString.equals( PDPageFitHeightDestination.TYPE ) || - typeString.equals( PDPageFitHeightDestination.TYPE_BOUNDED )) - { - retval = new PDPageFitHeightDestination( array ); - } - else if( typeString.equals( PDPageFitRectangleDestination.TYPE ) ) - { - retval = new PDPageFitRectangleDestination( array ); - } - else if( typeString.equals( PDPageFitWidthDestination.TYPE ) || - typeString.equals( PDPageFitWidthDestination.TYPE_BOUNDED )) - { - retval = new PDPageFitWidthDestination( array ); - } - else if( typeString.equals( PDPageXYZDestination.TYPE ) ) - { - retval = new PDPageXYZDestination( array ); - } - else - { - throw new IOException( "Unknown destination type:" + type ); - } - } - else if( base instanceof COSString ) - { - retval = new PDNamedDestination( (COSString)base ); - } - else if( base instanceof COSName ) - { - retval = new PDNamedDestination( (COSName)base ); - } - else - { - throw new IOException( "Error: can't convert to Destination " + base ); - } - return retval; - } - - /** - * Return a string representation of this class. - * - * @return A human readable string. - */ - public String toString() - { - return super.toString(); - } -} diff --git a/src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/destination/PDNamedDestination.java b/src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/destination/PDNamedDestination.java deleted file mode 100644 index 11da8e7..0000000 --- a/src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/destination/PDNamedDestination.java +++ /dev/null @@ -1,142 +0,0 @@ -/** - * Copyright (c) 2005, www.pdfbox.org - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of pdfbox; nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * http://www.pdfbox.org - * - */ -package org.pdfbox.pdmodel.interactive.documentnavigation.destination; - -import java.io.IOException; - -import org.pdfbox.cos.COSBase; -import org.pdfbox.cos.COSName; -import org.pdfbox.cos.COSString; - -/** - * This represents a destination to a page by referencing it with a name. - * - * @author Ben Litchfield (ben@csh.rit.edu) - * @version $Revision: 1.2 $ - */ -public class PDNamedDestination extends PDDestination -{ - private COSBase namedDestination; - - /** - * Constructor. - * - * @param dest The named destination. - */ - public PDNamedDestination( COSString dest ) - { - namedDestination = dest; - } - - /** - * Constructor. - * - * @param dest The named destination. - */ - public PDNamedDestination( COSName dest ) - { - namedDestination = dest; - } - - /** - * Default constructor. - */ - public PDNamedDestination() - { - //default, so do nothing - } - - /** - * Default constructor. - * - * @param dest The named destination. - */ - public PDNamedDestination( String dest ) - { - namedDestination = new COSString( dest ); - } - - /** - * Convert this standard java object to a COS object. - * - * @return The cos object that matches this Java object. - */ - public COSBase getCOSObject() - { - return namedDestination; - } - - /** - * This will get the name of the destination. - * - * @return The name of the destination. - */ - public String getNamedDestination() - { - String retval = null; - if( namedDestination instanceof COSString ) - { - retval = ((COSString)namedDestination).getString(); - } - else if( namedDestination instanceof COSName ) - { - retval = ((COSName)namedDestination).getName(); - } - - return retval; - } - - /** - * Set the named destination. - * - * @param dest The new named destination. - * - * @throws IOException If there is an error setting the named destination. - */ - public void setNamedDestination( String dest ) throws IOException - { - if( namedDestination instanceof COSString ) - { - COSString string = ((COSString)namedDestination); - string.reset(); - string.append( dest.getBytes() ); - } - else if( dest == null ) - { - namedDestination = null; - } - else - { - namedDestination = new COSString( dest ); - } - } - -} diff --git a/src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/destination/PDPageDestination.java b/src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/destination/PDPageDestination.java deleted file mode 100644 index 74dbf9a..0000000 --- a/src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/destination/PDPageDestination.java +++ /dev/null @@ -1,155 +0,0 @@ -/** - * Copyright (c) 2005, www.pdfbox.org - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of pdfbox; nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * http://www.pdfbox.org - * - */ -package org.pdfbox.pdmodel.interactive.documentnavigation.destination; - -import org.pdfbox.cos.COSArray; -import org.pdfbox.cos.COSBase; -import org.pdfbox.cos.COSDictionary; -import org.pdfbox.cos.COSNumber; - -import org.pdfbox.pdmodel.PDPage; - -/** - * This represents a destination to a page, see subclasses for specific parameters. - * - * @author Ben Litchfield (ben@csh.rit.edu) - * @version $Revision: 1.1 $ - */ -public abstract class PDPageDestination extends PDDestination -{ - /** - * Storage for the page destination. - */ - protected COSArray array; - - /** - * Constructor to create empty page destination. - * - */ - protected PDPageDestination() - { - array = new COSArray(); - } - - /** - * Constructor to create empty page destination. - * - * @param arr A page destination array. - */ - protected PDPageDestination( COSArray arr ) - { - array = arr; - } - - /** - * This will get the page for this destination. A page destination - * can either reference a page or a page number(when doing a remote destination to - * another PDF). If this object is referencing by page number then this method will - * return null and getPageNumber should be used. - * - * @return The page for this destination. - */ - public PDPage getPage() - { - PDPage retval = null; - if( array.size() > 0 ) - { - COSBase page = array.getObject( 0 ); - if( page instanceof COSDictionary ) - { - retval = new PDPage( (COSDictionary)page ); - } - } - return retval; - } - - /** - * Set the page for this destination. - * - * @param page The page for the destination. - */ - public void setPage( PDPage page ) - { - array.set( 0, page ); - } - - /** - * This will get the page number for this destination. A page destination - * can either reference a page or a page number(when doing a remote destination to - * another PDF). If this object is referencing by page number then this method will - * return that number, otherwise -1 will be returned. - * - * @return The page number for this destination. - */ - public int getPageNumber() - { - int retval = -1; - if( array.size() > 0 ) - { - COSBase page = array.getObject( 0 ); - if( page instanceof COSNumber ) - { - retval = ((COSNumber)page).intValue(); - } - } - return retval; - } - - /** - * Set the page number for this destination. - * - * @param pageNumber The page for the destination. - */ - public void setPageNumber( int pageNumber ) - { - array.set( 0, pageNumber ); - } - - /** - * Convert this standard java object to a COS object. - * - * @return The cos object that matches this Java object. - */ - public COSBase getCOSObject() - { - return array; - } - - /** - * Convert this standard java object to a COS object. - * - * @return The cos object that matches this Java object. - */ - public COSArray getCOSArray() - { - return array; - } -} diff --git a/src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/destination/PDPageFitDestination.java b/src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/destination/PDPageFitDestination.java deleted file mode 100644 index 8f46bbe..0000000 --- a/src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/destination/PDPageFitDestination.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * Copyright (c) 2005, www.pdfbox.org - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of pdfbox; nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * http://www.pdfbox.org - * - */ -package org.pdfbox.pdmodel.interactive.documentnavigation.destination; - -import org.pdfbox.cos.COSArray; - -/** - * This represents a destination to a page and the page contents will be magnified to just - * fit on the screen. - * - * @author Ben Litchfield (ben@csh.rit.edu) - * @version $Revision: 1.1 $ - */ -public class PDPageFitDestination extends PDPageDestination -{ - /** - * The type of this destination. - */ - protected static final String TYPE = "Fit"; - /** - * The type of this destination. - */ - protected static final String TYPE_BOUNDED = "FitB"; - - /** - * Default constructor. - * - */ - public PDPageFitDestination() - { - super(); - array.growToSize(2); - array.setName( 1, TYPE ); - - } - - /** - * Constructor from an existing destination array. - * - * @param arr The destination array. - */ - public PDPageFitDestination( COSArray arr ) - { - super( arr ); - } - - /** - * A flag indicating if this page destination should just fit bounding box of the PDF. - * - * @return true If the destination should fit just the bounding box. - */ - public boolean fitBoundingBox() - { - return TYPE_BOUNDED.equals( array.getName( 1 ) ); - } - - /** - * Set if this page destination should just fit the bounding box. The default is false. - * - * @param fitBoundingBox A flag indicating if this should fit the bounding box. - */ - public void setFitBoundingBox( boolean fitBoundingBox ) - { - array.growToSize( 2 ); - if( fitBoundingBox ) - { - array.setName( 1, TYPE_BOUNDED ); - } - else - { - array.setName( 1, TYPE ); - } - } -} diff --git a/src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/destination/PDPageFitHeightDestination.java b/src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/destination/PDPageFitHeightDestination.java deleted file mode 100644 index 64df612..0000000 --- a/src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/destination/PDPageFitHeightDestination.java +++ /dev/null @@ -1,132 +0,0 @@ -/** - * Copyright (c) 2005, www.pdfbox.org - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of pdfbox; nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * http://www.pdfbox.org - * - */ -package org.pdfbox.pdmodel.interactive.documentnavigation.destination; - -import org.pdfbox.cos.COSArray; -import org.pdfbox.cos.COSBase; - -/** - * This represents a destination to a page at a x location and the height is magnified - * to just fit on the screen. - * - * @author Ben Litchfield (ben@csh.rit.edu) - * @version $Revision: 1.1 $ - */ -public class PDPageFitHeightDestination extends PDPageDestination -{ - /** - * The type of this destination. - */ - protected static final String TYPE = "FitV"; - /** - * The type of this destination. - */ - protected static final String TYPE_BOUNDED = "FitBV"; - - /** - * Default constructor. - * - */ - public PDPageFitHeightDestination() - { - super(); - array.growToSize(3); - array.setName( 1, TYPE ); - - } - - /** - * Constructor from an existing destination array. - * - * @param arr The destination array. - */ - public PDPageFitHeightDestination( COSArray arr ) - { - super( arr ); - } - - /** - * Get the left x coordinate. A return value of -1 implies that the current x-coordinate - * will be used. - * - * @return The left x coordinate. - */ - public int getLeft() - { - return array.getInt( 2 ); - } - - /** - * Set the left x-coordinate, a value of -1 implies that the current x-coordinate - * will be used. - * @param x The left x coordinate. - */ - public void setLeft( int x ) - { - array.growToSize( 3 ); - if( x == -1 ) - { - array.set( 2, (COSBase)null ); - } - else - { - array.setInt( 2, x ); - } - } - - /** - * A flag indicating if this page destination should just fit bounding box of the PDF. - * - * @return true If the destination should fit just the bounding box. - */ - public boolean fitBoundingBox() - { - return TYPE_BOUNDED.equals( array.getName( 1 ) ); - } - - /** - * Set if this page destination should just fit the bounding box. The default is false. - * - * @param fitBoundingBox A flag indicating if this should fit the bounding box. - */ - public void setFitBoundingBox( boolean fitBoundingBox ) - { - array.growToSize( 2 ); - if( fitBoundingBox ) - { - array.setName( 1, TYPE_BOUNDED ); - } - else - { - array.setName( 1, TYPE ); - } - } -} diff --git a/src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/destination/PDPageFitRectangleDestination.java b/src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/destination/PDPageFitRectangleDestination.java deleted file mode 100644 index 00fc5f1..0000000 --- a/src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/destination/PDPageFitRectangleDestination.java +++ /dev/null @@ -1,188 +0,0 @@ -/** - * Copyright (c) 2005, www.pdfbox.org - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of pdfbox; nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * http://www.pdfbox.org - * - */ -package org.pdfbox.pdmodel.interactive.documentnavigation.destination; - -import org.pdfbox.cos.COSArray; -import org.pdfbox.cos.COSBase; - -/** - * This represents a destination to a page at a y location and the width is magnified - * to just fit on the screen. - * - * @author Ben Litchfield (ben@csh.rit.edu) - * @version $Revision: 1.1 $ - */ -public class PDPageFitRectangleDestination extends PDPageDestination -{ - /** - * The type of this destination. - */ - protected static final String TYPE = "FitR"; - - /** - * Default constructor. - * - */ - public PDPageFitRectangleDestination() - { - super(); - array.growToSize(6); - array.setName( 1, TYPE ); - - } - - /** - * Constructor from an existing destination array. - * - * @param arr The destination array. - */ - public PDPageFitRectangleDestination( COSArray arr ) - { - super( arr ); - } - - /** - * Get the left x coordinate. A return value of -1 implies that the current x-coordinate - * will be used. - * - * @return The left x coordinate. - */ - public int getLeft() - { - return array.getInt( 2 ); - } - - /** - * Set the left x-coordinate, a value of -1 implies that the current x-coordinate - * will be used. - * @param x The left x coordinate. - */ - public void setLeft( int x ) - { - array.growToSize( 3 ); - if( x == -1 ) - { - array.set( 2, (COSBase)null ); - } - else - { - array.setInt( 2, x ); - } - } - - /** - * Get the bottom y coordinate. A return value of -1 implies that the current y-coordinate - * will be used. - * - * @return The bottom y coordinate. - */ - public int getBottom() - { - return array.getInt( 3 ); - } - - /** - * Set the bottom y-coordinate, a value of -1 implies that the current y-coordinate - * will be used. - * @param y The bottom y coordinate. - */ - public void setBottom( int y ) - { - array.growToSize( 6 ); - if( y == -1 ) - { - array.set( 3, (COSBase)null ); - } - else - { - array.setInt( 3, y ); - } - } - - /** - * Get the right x coordinate. A return value of -1 implies that the current x-coordinate - * will be used. - * - * @return The right x coordinate. - */ - public int getRight() - { - return array.getInt( 4 ); - } - - /** - * Set the right x-coordinate, a value of -1 implies that the current x-coordinate - * will be used. - * @param x The right x coordinate. - */ - public void setRight( int x ) - { - array.growToSize( 6 ); - if( x == -1 ) - { - array.set( 4, (COSBase)null ); - } - else - { - array.setInt( 4, x ); - } - } - - - /** - * Get the top y coordinate. A return value of -1 implies that the current y-coordinate - * will be used. - * - * @return The top y coordinate. - */ - public int getTop() - { - return array.getInt( 5 ); - } - - /** - * Set the top y-coordinate, a value of -1 implies that the current y-coordinate - * will be used. - * @param y The top ycoordinate. - */ - public void setTop( int y ) - { - array.growToSize( 6 ); - if( y == -1 ) - { - array.set( 5, (COSBase)null ); - } - else - { - array.setInt( 5, y ); - } - } -} diff --git a/src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/destination/PDPageFitWidthDestination.java b/src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/destination/PDPageFitWidthDestination.java deleted file mode 100644 index ef7385f..0000000 --- a/src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/destination/PDPageFitWidthDestination.java +++ /dev/null @@ -1,134 +0,0 @@ -/** - * Copyright (c) 2005, www.pdfbox.org - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of pdfbox; nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * http://www.pdfbox.org - * - */ -package org.pdfbox.pdmodel.interactive.documentnavigation.destination; - -import org.pdfbox.cos.COSArray; -import org.pdfbox.cos.COSBase; - -/** - * This represents a destination to a page at a y location and the width is magnified - * to just fit on the screen. - * - * @author Ben Litchfield (ben@csh.rit.edu) - * @version $Revision: 1.1 $ - */ -public class PDPageFitWidthDestination extends PDPageDestination -{ - - /** - * The type of this destination. - */ - protected static final String TYPE = "FitH"; - /** - * The type of this destination. - */ - protected static final String TYPE_BOUNDED = "FitBH"; - - /** - * Default constructor. - * - */ - public PDPageFitWidthDestination() - { - super(); - array.growToSize(3); - array.setName( 1, TYPE ); - - } - - /** - * Constructor from an existing destination array. - * - * @param arr The destination array. - */ - public PDPageFitWidthDestination( COSArray arr ) - { - super( arr ); - } - - - /** - * Get the top y coordinate. A return value of -1 implies that the current y-coordinate - * will be used. - * - * @return The top y coordinate. - */ - public int getTop() - { - return array.getInt( 2 ); - } - - /** - * Set the top y-coordinate, a value of -1 implies that the current y-coordinate - * will be used. - * @param y The top ycoordinate. - */ - public void setTop( int y ) - { - array.growToSize( 3 ); - if( y == -1 ) - { - array.set( 2, (COSBase)null ); - } - else - { - array.setInt( 2, y ); - } - } - - /** - * A flag indicating if this page destination should just fit bounding box of the PDF. - * - * @return true If the destination should fit just the bounding box. - */ - public boolean fitBoundingBox() - { - return TYPE_BOUNDED.equals( array.getName( 1 ) ); - } - - /** - * Set if this page destination should just fit the bounding box. The default is false. - * - * @param fitBoundingBox A flag indicating if this should fit the bounding box. - */ - public void setFitBoundingBox( boolean fitBoundingBox ) - { - array.growToSize( 2 ); - if( fitBoundingBox ) - { - array.setName( 1, TYPE_BOUNDED ); - } - else - { - array.setName( 1, TYPE ); - } - } -} diff --git a/src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/destination/PDPageXYZDestination.java b/src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/destination/PDPageXYZDestination.java deleted file mode 100644 index 543a33c..0000000 --- a/src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/destination/PDPageXYZDestination.java +++ /dev/null @@ -1,159 +0,0 @@ -/** - * Copyright (c) 2005, www.pdfbox.org - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of pdfbox; nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * http://www.pdfbox.org - * - */ -package org.pdfbox.pdmodel.interactive.documentnavigation.destination; - -import org.pdfbox.cos.COSArray; -import org.pdfbox.cos.COSBase; - -/** - * This represents a destination to a page at an x,y coordinate with a zoom setting. - * The default x,y,z will be whatever is the current value in the viewer application and - * are not required. - * - * @author Ben Litchfield (ben@csh.rit.edu) - * @version $Revision: 1.1 $ - */ -public class PDPageXYZDestination extends PDPageDestination -{ - /** - * The type of this destination. - */ - protected static final String TYPE = "XYZ"; - - /** - * Default constructor. - * - */ - public PDPageXYZDestination() - { - super(); - array.growToSize(5); - array.setName( 1, TYPE ); - - } - - /** - * Constructor from an existing destination array. - * - * @param arr The destination array. - */ - public PDPageXYZDestination( COSArray arr ) - { - super( arr ); - } - - /** - * Get the left x coordinate. A return value of -1 implies that the current x-coordinate - * will be used. - * - * @return The left x coordinate. - */ - public int getLeft() - { - return array.getInt( 2 ); - } - - /** - * Set the left x-coordinate, a value of -1 implies that the current x-coordinate - * will be used. - * @param x The left x coordinate. - */ - public void setLeft( int x ) - { - array.growToSize( 3 ); - if( x == -1 ) - { - array.set( 2, (COSBase)null ); - } - else - { - array.setInt( 2, x ); - } - } - - /** - * Get the top y coordinate. A return value of -1 implies that the current y-coordinate - * will be used. - * - * @return The top y coordinate. - */ - public int getTop() - { - return array.getInt( 3 ); - } - - /** - * Set the top y-coordinate, a value of -1 implies that the current y-coordinate - * will be used. - * @param y The top ycoordinate. - */ - public void setTop( int y ) - { - array.growToSize( 4 ); - if( y == -1 ) - { - array.set( 3, (COSBase)null ); - } - else - { - array.setInt( 3, y ); - } - } - - /** - * Get the zoom value. A return value of -1 implies that the current zoom - * will be used. - * - * @return The zoom value for the page. - */ - public int getZoom() - { - return array.getInt( 4 ); - } - - /** - * Set the zoom value for the page, a value of -1 implies that the current zoom - * will be used. - * @param zoom The zoom value. - */ - public void setZoom( int zoom ) - { - array.growToSize( 5 ); - if( zoom == -1 ) - { - array.set( 4, (COSBase)null ); - } - else - { - array.setInt( 4, zoom ); - } - } -} diff --git a/src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/destination/package.html b/src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/destination/package.html deleted file mode 100644 index 2122b1d..0000000 --- a/src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/destination/package.html +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - -The destination package allows destinations into a pdf document to be specified. - - diff --git a/src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/outline/PDDocumentOutline.java b/src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/outline/PDDocumentOutline.java deleted file mode 100644 index 157a36f..0000000 --- a/src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/outline/PDDocumentOutline.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Copyright (c) 2005, www.pdfbox.org - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of pdfbox; nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * http://www.pdfbox.org - * - */ -package org.pdfbox.pdmodel.interactive.documentnavigation.outline; - -import org.pdfbox.cos.COSDictionary; - -/** - * This represents an outline in a pdf document. - * - * @author Ben Litchfield (ben@csh.rit.edu) - * @version $Revision: 1.1 $ - */ -public class PDDocumentOutline extends PDOutlineNode -{ - - /** - * Default Constructor. - */ - public PDDocumentOutline() - { - super(); - node.setName( "Type", "Outlines" ); - } - - /** - * Constructor for an existing document outline. - * - * @param dic The storage dictionary. - */ - public PDDocumentOutline( COSDictionary dic ) - { - super( dic ); - } -} diff --git a/src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/outline/PDOutlineItem.java b/src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/outline/PDOutlineItem.java deleted file mode 100644 index 648eb64..0000000 --- a/src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/outline/PDOutlineItem.java +++ /dev/null @@ -1,425 +0,0 @@ -/** - * Copyright (c) 2005, www.pdfbox.org - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of pdfbox; nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * http://www.pdfbox.org - * - */ -package org.pdfbox.pdmodel.interactive.documentnavigation.outline; - -import java.io.IOException; -import java.util.List; - -import org.pdfbox.cos.COSArray; -import org.pdfbox.cos.COSDictionary; -import org.pdfbox.cos.COSFloat; -import org.pdfbox.exceptions.OutlineNotLocalException; -import org.pdfbox.pdmodel.PDDestinationNameTreeNode; -import org.pdfbox.pdmodel.PDDocument; -import org.pdfbox.pdmodel.PDDocumentNameDictionary; -import org.pdfbox.pdmodel.PDPage; -import org.pdfbox.pdmodel.documentinterchange.logicalstructure.PDStructureElement; -import org.pdfbox.pdmodel.graphics.color.PDColorSpaceInstance; -import org.pdfbox.pdmodel.graphics.color.PDDeviceRGB; -import org.pdfbox.pdmodel.interactive.action.type.PDAction; -import org.pdfbox.pdmodel.interactive.action.type.PDActionGoTo; -import org.pdfbox.pdmodel.interactive.action.PDActionFactory; -import org.pdfbox.pdmodel.interactive.documentnavigation.destination.PDDestination; -import org.pdfbox.pdmodel.interactive.documentnavigation.destination.PDNamedDestination; -import org.pdfbox.pdmodel.interactive.documentnavigation.destination.PDPageDestination; -import org.pdfbox.pdmodel.interactive.documentnavigation.destination.PDPageXYZDestination; - -/** - * This represents an outline in a pdf document. - * - * @author Ben Litchfield (ben@csh.rit.edu) - * @version $Revision: 1.5 $ - */ -public class PDOutlineItem extends PDOutlineNode -{ - - private static final int ITALIC_FLAG = 1; - private static final int BOLD_FLAG = 2; - - /** - * Default Constructor. - */ - public PDOutlineItem() - { - super(); - } - - /** - * Constructor for an existing outline item. - * - * @param dic The storage dictionary. - */ - public PDOutlineItem( COSDictionary dic ) - { - super( dic ); - } - - /** - * Insert a sibling after this node. - * - * @param item The item to insert. - */ - public void insertSiblingAfter( PDOutlineItem item ) - { - item.setParent( getParent() ); - PDOutlineItem next = getNextSibling(); - setNextSibling( item ); - item.setPreviousSibling( this ); - if( next != null ) - { - item.setNextSibling( next ); - next.setPreviousSibling( item ); - } - updateParentOpenCount( 1 ); - } - - /** - * Return the previous sibling or null if there is no sibling. - * - * @return The previous sibling. - */ - public PDOutlineItem getPreviousSibling() - { - PDOutlineItem last = null; - COSDictionary lastDic = (COSDictionary)node.getDictionaryObject( "Prev" ); - if( lastDic != null ) - { - last = new PDOutlineItem( lastDic ); - } - return last; - } - - /** - * Set the previous sibling, this will be maintained by this class. - * - * @param outlineNode The new previous sibling. - */ - protected void setPreviousSibling( PDOutlineNode outlineNode ) - { - node.setItem( "Prev", outlineNode ); - } - - /** - * Return the next sibling or null if there is no next sibling. - * - * @return The next sibling. - */ - public PDOutlineItem getNextSibling() - { - PDOutlineItem last = null; - COSDictionary lastDic = (COSDictionary)node.getDictionaryObject( "Next" ); - if( lastDic != null ) - { - last = new PDOutlineItem( lastDic ); - } - return last; - } - - /** - * Set the next sibling, this will be maintained by this class. - * - * @param outlineNode The new next sibling. - */ - protected void setNextSibling( PDOutlineNode outlineNode ) - { - node.setItem( "Next", outlineNode ); - } - - /** - * Get the title of this node. - * - * @return The title of this node. - */ - public String getTitle() - { - return node.getString( "Title" ); - } - - /** - * Set the title for this node. - * - * @param title The new title for this node. - */ - public void setTitle( String title ) - { - node.setString( "Title", title ); - } - - /** - * Get the page destination of this node. - * - * @return The page destination of this node. - * @throws IOException If there is an error creating the destination. - */ - public PDDestination getDestination() throws IOException - { - return PDDestination.create( node.getDictionaryObject( "Dest" ) ); - } - - /** - * Set the page destination for this node. - * - * @param dest The new page destination for this node. - */ - public void setDestination( PDDestination dest ) - { - node.setItem( "Dest", dest ); - } - - /** - * A convenience method that will create an XYZ destination using only the defaults. - * - * @param page The page to refer to. - */ - public void setDestination( PDPage page ) - { - PDPageXYZDestination dest = null; - if( page != null ) - { - dest = new PDPageXYZDestination(); - dest.setPage( page ); - } - setDestination( dest ); - } - - /** - * This method will attempt to find the page in this PDF document that this outline points to. - * If the outline does not point to anything then this method will return null. If the outline - * is an action that is not a GoTo action then this methods will throw the OutlineNotLocationException - * - * @param doc The document to get the page from. - * - * @return The page that this outline will go to when activated or null if it does not point to anything. - * @throws IOException If there is an error when trying to find the page. - */ - public PDPage findDestinationPage( PDDocument doc ) throws IOException - { - PDPage page = null; - PDDestination rawDest = getDestination(); - if( rawDest == null ) - { - PDAction outlineAction = getAction(); - if( outlineAction instanceof PDActionGoTo ) - { - rawDest = ((PDActionGoTo)outlineAction).getDestination(); - } - else if( outlineAction == null ) - { - //if the outline action is null then this outline does not refer - //to anything and we will just return null. - } - else - { - throw new OutlineNotLocalException( "Error: Outline does not reference a local page." ); - } - } - - PDPageDestination pageDest = null; - if( rawDest instanceof PDNamedDestination ) - { - //if we have a named destination we need to lookup the PDPageDestination - PDNamedDestination namedDest = (PDNamedDestination)rawDest; - PDDocumentNameDictionary namesDict = doc.getDocumentCatalog().getNames(); - if( namesDict != null ) - { - PDDestinationNameTreeNode destsTree = namesDict.getDests(); - if( destsTree != null ) - { - pageDest = (PDPageDestination)destsTree.getValue( namedDest.getNamedDestination() ); - } - } - } - else if( rawDest instanceof PDPageDestination) - { - pageDest = (PDPageDestination) rawDest; - } - else if( rawDest == null ) - { - //if the destination is null then we will simply return a null page. - } - else - { - throw new IOException( "Error: Unknown destination type " + rawDest ); - } - - if( pageDest != null ) - { - page = pageDest.getPage(); - if( page == null ) - { - int pageNumber = pageDest.getPageNumber(); - if( pageNumber != -1 ) - { - List allPages = doc.getDocumentCatalog().getAllPages(); - page = (PDPage)allPages.get( pageNumber ); - } - } - } - - return page; - } - - /** - * Get the action of this node. - * - * @return The action of this node. - */ - public PDAction getAction() - { - return PDActionFactory.createAction( (COSDictionary)node.getDictionaryObject( "A" ) ); - } - - /** - * Set the action for this node. - * - * @param action The new action for this node. - */ - public void setAction( PDAction action ) - { - node.setItem( "A", action ); - } - - /** - * Get the structure element of this node. - * - * @return The structure element of this node. - */ - public PDStructureElement getStructureElement() - { - PDStructureElement se = null; - COSDictionary dic = (COSDictionary)node.getDictionaryObject( "SE" ); - if( dic != null ) - { - se = new PDStructureElement( dic ); - } - return se; - } - - /** - * Set the structure element for this node. - * - * @param structureElement The new structure element for this node. - */ - public void setAction( PDStructureElement structureElement ) - { - node.setItem( "SE", structureElement ); - } - - /** - * Get the text color of this node. Default is black and this method - * will never return null. - * - * @return The structure element of this node. - */ - public PDColorSpaceInstance getTextColor() - { - PDColorSpaceInstance retval = null; - COSArray csValues = (COSArray)node.getDictionaryObject( "C" ); - if( csValues == null ) - { - csValues = new COSArray(); - csValues.growToSize( 3, new COSFloat( 0 ) ); - node.setItem( "C", csValues ); - } - retval = new PDColorSpaceInstance(csValues); - retval.setColorSpace( PDDeviceRGB.INSTANCE ); - return retval; - } - - /** - * Set the text color for this node. - * - * @param textColor The text color for this node. - */ - public void setTextColor( PDColorSpaceInstance textColor ) - { - node.setItem( "C", textColor.getCOSColorSpaceValue() ); - } - - /** - * A flag telling if the text should be italic. - * - * @return The italic flag. - */ - public boolean isItalic() - { - return (node.getInt( "F", 0 ) & ITALIC_FLAG) == ITALIC_FLAG; - } - - /** - * Set the italic property of the text. - * - * @param italic The new italic flag. - */ - public void setItalic( boolean italic ) - { - int f = node.getInt( "F", 0 ); - if( italic ) - { - f = f | ITALIC_FLAG; - } - else - { - f = f ^ ITALIC_FLAG; - } - node.setInt( "F", f ); - } - - /** - * A flag telling if the text should be bold. - * - * @return The bold flag. - */ - public boolean isBold() - { - return (node.getInt( "F", 0 ) & BOLD_FLAG) == BOLD_FLAG; - } - - /** - * Set the bold property of the text. - * - * @param bold The new bold flag. - */ - public void setBold( boolean bold ) - { - int f = node.getInt( "F", 0 ); - if( bold ) - { - f = f | BOLD_FLAG; - } - else - { - f = f ^ BOLD_FLAG; - } - node.setInt( "F", f ); - } - -} diff --git a/src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/outline/PDOutlineNode.java b/src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/outline/PDOutlineNode.java deleted file mode 100644 index 04cc45f..0000000 --- a/src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/outline/PDOutlineNode.java +++ /dev/null @@ -1,320 +0,0 @@ -/** - * Copyright (c) 2005, www.pdfbox.org - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of pdfbox; nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * http://www.pdfbox.org - * - */ -package org.pdfbox.pdmodel.interactive.documentnavigation.outline; - -import org.pdfbox.cos.COSBase; -import org.pdfbox.cos.COSDictionary; - -import org.pdfbox.pdmodel.common.COSObjectable; - -/** - * This represents an node in an outline in a pdf document. - * - * @author Ben Litchfield (ben@csh.rit.edu) - * @version $Revision: 1.1 $ - */ -public class PDOutlineNode implements COSObjectable -{ - /** - * The dictionary for this node. - */ - protected COSDictionary node; - - /** - * Default Constructor. - */ - public PDOutlineNode() - { - node = new COSDictionary(); - } - - /** - * Default Constructor. - * - * @param dict The dictionary storage. - */ - public PDOutlineNode( COSDictionary dict) - { - node = dict; - } - - /** - * Convert this standard java object to a COS object. - * - * @return The cos object that matches this Java object. - */ - public COSBase getCOSObject() - { - return node; - } - - /** - * Convert this standard java object to a COS object. - * - * @return The cos object that matches this Java object. - */ - public COSDictionary getCOSDictionary() - { - return node; - } - - /** - * Get the parent of this object. This will either be a DocumentOutline or an OutlineItem. - * - * @return The parent of this object, or null if this is the document outline and there - * is no parent. - */ - public PDOutlineNode getParent() - { - PDOutlineNode retval = null; - COSDictionary parent = (COSDictionary)node.getDictionaryObject( "Parent" ); - if( parent != null ) - { - if( parent.getDictionaryObject( "Parent") == null ) - { - retval = new PDDocumentOutline( parent ); - } - else - { - retval = new PDOutlineItem( parent ); - } - } - - return retval; - } - - /** - * Set the parent of this object, this is maintained by these objects and should not - * be called by any clients of PDFBox code. - * - * @param parent The parent of this object. - */ - protected void setParent( PDOutlineNode parent ) - { - node.setItem( "Parent", parent ); - } - - /** - * append a child node to this node. - * - * @param outlineNode The node to add. - */ - public void appendChild( PDOutlineItem outlineNode ) - { - outlineNode.setParent( this ); - if( getFirstChild() == null ) - { - int currentOpenCount = getOpenCount(); - setFirstChild( outlineNode ); - //1 for the the item we are adding; - int numberOfOpenNodesWeAreAdding = 1; - if( outlineNode.isNodeOpen() ) - { - numberOfOpenNodesWeAreAdding += outlineNode.getOpenCount(); - } - if( isNodeOpen() ) - { - setOpenCount( currentOpenCount + numberOfOpenNodesWeAreAdding ); - } - else - { - setOpenCount( currentOpenCount - numberOfOpenNodesWeAreAdding ); - } - updateParentOpenCount( numberOfOpenNodesWeAreAdding ); - } - else - { - PDOutlineItem previousLastChild = getLastChild(); - previousLastChild.insertSiblingAfter( outlineNode ); - } - setLastChild( outlineNode ); - } - - /** - * Return the first child or null if there is no child. - * - * @return The first child. - */ - public PDOutlineItem getFirstChild() - { - PDOutlineItem last = null; - COSDictionary lastDic = (COSDictionary)node.getDictionaryObject( "First" ); - if( lastDic != null ) - { - last = new PDOutlineItem( lastDic ); - } - return last; - } - - /** - * Set the first child, this will be maintained by this class. - * - * @param outlineNode The new first child. - */ - protected void setFirstChild( PDOutlineNode outlineNode ) - { - node.setItem( "First", outlineNode ); - } - - /** - * Return the last child or null if there is no child. - * - * @return The last child. - */ - public PDOutlineItem getLastChild() - { - PDOutlineItem last = null; - COSDictionary lastDic = (COSDictionary)node.getDictionaryObject( "Last" ); - if( lastDic != null ) - { - last = new PDOutlineItem( lastDic ); - } - return last; - } - - /** - * Set the last child, this will be maintained by this class. - * - * @param outlineNode The new last child. - */ - protected void setLastChild( PDOutlineNode outlineNode ) - { - node.setItem( "Last", outlineNode ); - } - - /** - * Get the number of open nodes. Or a negative number if this node - * is closed. See PDF Reference for more details. This value - * is updated as you append children and siblings. - * - * @return The Count attribute of the outline dictionary. - */ - public int getOpenCount() - { - return node.getInt( "Count", 0 ); - } - - /** - * Set the open count. This number is automatically managed for you - * when you add items to the outline. - * - * @param openCount The new open cound. - */ - protected void setOpenCount( int openCount ) - { - node.setInt( "Count", openCount ); - } - - /** - * This will set this node to be open when it is shown in the viewer. By default, when - * a new node is created it will be closed. - * This will do nothing if the node is already open. - */ - public void openNode() - { - //if the node is already open then do nothing. - if( !isNodeOpen() ) - { - int openChildrenCount = 0; - PDOutlineItem currentChild = getFirstChild(); - while( currentChild != null ) - { - //first increase by one for the current child - openChildrenCount++; - //then increase by the number of open nodes the child has - if( currentChild.isNodeOpen() ) - { - openChildrenCount += currentChild.getOpenCount(); - } - currentChild = currentChild.getNextSibling(); - } - setOpenCount( openChildrenCount ); - updateParentOpenCount( openChildrenCount ); - } - } - - /** - * Close this node. - * - */ - public void closeNode() - { - //if the node is already closed then do nothing. - if( isNodeOpen() ) - { - int openCount = getOpenCount(); - updateParentOpenCount( -openCount ); - setOpenCount( -openCount ); - } - } - - /** - * Node is open if the open count is greater than zero. - * @return true if this node is open. - */ - public boolean isNodeOpen() - { - return getOpenCount() > 0; - } - - /** - * The count parameter needs to be updated when you add or remove elements to - * the outline. When you add an element at a lower level then you need to - * increase all of the parents. - * - * @param amount The amount to update by. - */ - protected void updateParentOpenCount( int amount ) - { - PDOutlineNode parent = getParent(); - if( parent != null ) - { - int currentCount = parent.getOpenCount(); - //if the currentCount is negative or it is absent then - //we will treat it as negative. The default is to be negative. - boolean negative = currentCount < 0 || - parent.getCOSDictionary().getDictionaryObject( "Count" ) == null; - currentCount = Math.abs( currentCount ); - currentCount += amount; - if( negative ) - { - currentCount = -currentCount; - } - parent.setOpenCount( currentCount ); - //recursively call parent to update count, but the parents count is only - //updated if this is an open node - if( !negative ) - { - parent.updateParentOpenCount( amount ); - } - } - } -} diff --git a/src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/outline/package.html b/src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/outline/package.html deleted file mode 100644 index 4ec0032..0000000 --- a/src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/outline/package.html +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - -The outline package allows for a PDF outline(bookmarks) to be created. - - diff --git a/src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/package.html b/src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/package.html deleted file mode 100644 index b210cf5..0000000 --- a/src/main/java/org/pdfbox/pdmodel/interactive/documentnavigation/package.html +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - -A package to allow access to document level navigation within a PDF document. - - -- cgit v1.2.3