Details
-
Type: Bug
-
Status: Closed
-
Priority: Major
-
Resolution: Fixed
-
Affects Version/s: 5.0.0 beta1
-
Fix Version/s: 5.0
-
Component/s: Core/Parsing
-
Labels:None
-
Environment:PRO
Description
Update the IncrementalUpdater class to output all changed objects in the StateManager. The output format will be generic byte[][] where each element is a changed object and the respective byte stream. The byte streams could then be serialized and read back as PDF objects using the Parser class.
Activity
Patrick Corless
created issue -
Patrick Corless
made changes -
Field | Original Value | New Value |
---|---|---|
Status | Open [ 1 ] | Resolved [ 5 ] |
Resolution | Fixed [ 1 ] |
Patrick Corless
made changes -
Fix Version/s | 5.0 [ 10314 ] |
Repository | Revision | Date | User | Message |
ICEsoft Public SVN Repository | #34188 | Tue Apr 02 10:28:16 MDT 2013 | patrick.corless | |
Files Changed | ||||
MODIFY
/icepdf/trunk/icepdf/core/src/org/icepdf/core/pobjects/StateManager.java
|
Patrick Corless
made changes -
Status | Resolved [ 5 ] | Closed [ 6 ] |
Added a new method to IncrementalUpdater which will write each PDF object's byte's to an byte[]. The method getUpdatedDocumentObjects() can be used to write out the changed PDF objects made by the most recent PDF edits.
The following code is n example of how to read the bytes back into the same PDF file.
try {
{ fileOutputStream.write(update); }// get the updated bites
byte[][] updates = IncrementalUpdater.getUpdatedDocumentObjects(document);
// write the bytes to file
FileOutputStream fileOutputStream = new FileOutputStream("changes.txt");
for (byte[] update : updates)
fileOutputStream.close();
controller.closeDocument();
// read the changes back into the document.
controller.openDocument(filePath);
FileInputStream fileInputStream = new FileInputStream("changes.txt");
Library library = document.getCatalog().getLibrary();
{ libraryObjects.add(streamObject); }Parser parser = new Parser(fileInputStream);
// keep a hard reference to the objects
ArrayList<Object> libraryObjects = new ArrayList<Object>();
for (Object streamObject = parser.getObject(library);
streamObject != null; streamObject = parser.getObject(library))
// iterate over the stream objects look for pages so we know which
// annotations should be added to which page.
pageComponents =
controller.getDocumentViewController()
.getDocumentViewModel().getPageComponents();
myAnnotationCallback = new org.icepdf.ri.common.MyAnnotationCallback(
controller.getDocumentViewController());
for (Object objects : libraryObjects){
if (objects instanceof PObject &&
((PObject)objects).getObject() instanceof Page){
Page page = (Page)((PObject)objects).getObject() ;
page.init();
int pageNumber = document.getPageTree().getPageNumber(page.getPObjectReference());
AbstractPageViewComponent pageViewComponent = pageComponents.get(pageNumber);
// add our new page to the library
{ AnnotationComponent annotationComponent = AnnotationComponentFactory.buildAnnotationComponent( annotation, controller.getDocumentViewController(), pageViewComponent, controller.getDocumentViewController().getDocumentViewModel()); myAnnotationCallback.newAnnotation(pageViewComponent, annotationComponent); }List<Annotation> annotations = page.getAnnotations();
// hook up the new annotations
for (Annotation annotation : annotations)
pageViewComponent.init();
}
}
} catch (IOException e)
{ e.printStackTrace(); } catch (PDFException e) { e.printStackTrace(); }