"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "pdfbox/src/main/java/org/apache/pdfbox/multipdf/Splitter.java" between
pdfbox-2.0.23-src.zip and pdfbox-2.0.24-src.zip

About: Apache PDFBox is a Java PDF library tool that allows creation of new PDF documents, manipulation of existing documents and the ability to extract content from documents.

Splitter.java  (pdfbox-2.0.23-src):Splitter.java  (pdfbox-2.0.24-src)
skipping to change at line 49 skipping to change at line 49
public class Splitter public class Splitter
{ {
private PDDocument sourceDocument; private PDDocument sourceDocument;
private PDDocument currentDestinationDocument; private PDDocument currentDestinationDocument;
private int splitLength = 1; private int splitLength = 1;
private int startPage = Integer.MIN_VALUE; private int startPage = Integer.MIN_VALUE;
private int endPage = Integer.MAX_VALUE; private int endPage = Integer.MAX_VALUE;
private List<PDDocument> destinationDocuments; private List<PDDocument> destinationDocuments;
private int currentPageNumber = 0; private int currentPageNumber;
private MemoryUsageSetting memoryUsageSetting = null; private MemoryUsageSetting memoryUsageSetting = null;
/** /**
* @return the current memory setting. * @return the current memory setting.
*/ */
public MemoryUsageSetting getMemoryUsageSetting() public MemoryUsageSetting getMemoryUsageSetting()
{ {
return memoryUsageSetting; return memoryUsageSetting;
} }
/** /**
* Set the memory setting. * Set the memory setting.
* *
* @param memoryUsageSetting * @param memoryUsageSetting The memory setting.
*/ */
public void setMemoryUsageSetting(MemoryUsageSetting memoryUsageSetting) public void setMemoryUsageSetting(MemoryUsageSetting memoryUsageSetting)
{ {
this.memoryUsageSetting = memoryUsageSetting; this.memoryUsageSetting = memoryUsageSetting;
} }
/** /**
* This will take a document and split into several other documents. * This will take a document and split into several other documents.
* *
* @param document The document to split. * @param document The document to split.
* *
* @return A list of all the split documents. * @return A list of all the split documents. These should all be saved befo
re closing any
* documents, including the source document. Any further operations should b
e made after
* reloading them, to avoid problems due to resource sharing.
* *
* @throws IOException If there is an IOError * @throws IOException If there is an IOError
*/ */
public List<PDDocument> split(PDDocument document) throws IOException public List<PDDocument> split(PDDocument document) throws IOException
{ {
// reset the currentPageNumber for a case if the split method will be us
ed several times
currentPageNumber = 0;
destinationDocuments = new ArrayList<PDDocument>(); destinationDocuments = new ArrayList<PDDocument>();
sourceDocument = document; sourceDocument = document;
processPages(); processPages();
return destinationDocuments; return destinationDocuments;
} }
/** /**
* This will tell the splitting algorithm where to split the pages. The def ault * This will tell the splitting algorithm where to split the pages. The def ault
* is 1, so every page will become a new document. If it was two then each document would * is 1, so every page will become a new document. If it was two then each document would
* contain 2 pages. If the source document had 5 pages it would split into * contain 2 pages. If the source document had 5 pages it would split into
skipping to change at line 242 skipping to change at line 246
private void processAnnotations(PDPage imported) throws IOException private void processAnnotations(PDPage imported) throws IOException
{ {
List<PDAnnotation> annotations = imported.getAnnotations(); List<PDAnnotation> annotations = imported.getAnnotations();
for (PDAnnotation annotation : annotations) for (PDAnnotation annotation : annotations)
{ {
if (annotation instanceof PDAnnotationLink) if (annotation instanceof PDAnnotationLink)
{ {
PDAnnotationLink link = (PDAnnotationLink)annotation; PDAnnotationLink link = (PDAnnotationLink)annotation;
PDDestination destination = link.getDestination(); PDDestination destination = link.getDestination();
if (destination == null && link.getAction() != null) PDAction action = link.getAction();
if (destination == null && action instanceof PDActionGoTo)
{ {
PDAction action = link.getAction(); destination = ((PDActionGoTo) action).getDestination();
if (action instanceof PDActionGoTo)
{
destination = ((PDActionGoTo)action).getDestination();
}
} }
if (destination instanceof PDPageDestination) if (destination instanceof PDPageDestination)
{ {
// TODO preserve links to pages within the split result // TODO preserve links to pages within the split result
((PDPageDestination) destination).setPage(null); ((PDPageDestination) destination).setPage(null);
} }
} }
// TODO preserve links to pages within the split result // TODO preserve links to pages within the split result
annotation.setPage(null); annotation.setPage(null);
} }
 End of changes. 6 change blocks. 
9 lines changed or deleted 13 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)