- Timestamp:
- 06/21/09 19:31:45 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/docx4j/src/main/java/org/docx4j/samples/CompareDocuments.java
r833 r838 60 60 public static void main(String[] args) throws Exception { 61 61 62 String newerfilepath = "/home/dev/workspace/docx4j/sample-docs/differencing_newer.docx"; 62 63 String olderfilepath = "/home/dev/workspace/docx4j/sample-docs/differencing_older.docx"; 63 String newerfilepath = "/home/dev/workspace/docx4j/sample-docs/differencing_newer.docx"; 64 65 // 1. Load the Packages 66 WordprocessingMLPackage newerPackage = WordprocessingMLPackage.load(new java.io.File(newerfilepath)); 67 WordprocessingMLPackage olderPackage = WordprocessingMLPackage.load(new java.io.File(olderfilepath)); 64 68 65 66 // 1. Load the Packages 67 WordprocessingMLPackage olderPackage = WordprocessingMLPackage.load(new java.io.File(olderfilepath)); 68 WordprocessingMLPackage newerPackage = WordprocessingMLPackage.load(new java.io.File(newerfilepath)); 69 69 Body newerBody = ((Document)newerPackage.getMainDocumentPart().getJaxbElement()).getBody(); 70 70 Body olderBody = ((Document)olderPackage.getMainDocumentPart().getJaxbElement()).getBody(); 71 Body newerBody = ((Document)newerPackage.getMainDocumentPart().getJaxbElement()).getBody();72 71 73 72 // 2. Do the differencing … … 79 78 Differencer pd = new Differencer(); 80 79 pd.setRelsDiffIdentifier("blagh"); // not necessary in this case 81 pd.diff(olderBody, newerBody, result, "someone", changeDate, 82 olderPackage.getMainDocumentPart().getRelationshipsPart(), 83 newerPackage.getMainDocumentPart().getRelationshipsPart()); 80 pd.diff(newerBody, olderBody, result, "someone", changeDate, 81 newerPackage.getMainDocumentPart().getRelationshipsPart(), 82 olderPackage.getMainDocumentPart().getRelationshipsPart() 83 ); 84 84 85 85 // 3. Get the result … … 90 90 91 91 // 4. Display the result as a PDF 92 // To do this, we'll replace the body in the older document93 ((Document) olderPackage.getMainDocumentPart().getJaxbElement()).setBody(newBody);92 // To do this, we'll replace the body in the newer document 93 ((Document)newerPackage.getMainDocumentPart().getJaxbElement()).setBody(newBody); 94 94 95 RelationshipsPart rp = olderPackage.getMainDocumentPart().getRelationshipsPart();95 RelationshipsPart rp = newerPackage.getMainDocumentPart().getRelationshipsPart(); 96 96 handleRels(pd, rp); 97 97 98 98 99 olderPackage.setFontMapper(new IdentityPlusMapper());99 newerPackage.setFontMapper(new IdentityPlusMapper()); 100 100 org.docx4j.convert.out.pdf.PdfConversion c 101 101 // = new org.docx4j.convert.out.pdf.viaHTML.Conversion(olderPackage); 102 = new org.docx4j.convert.out.pdf.viaXSLFO.Conversion( olderPackage);102 = new org.docx4j.convert.out.pdf.viaXSLFO.Conversion(newerPackage); 103 103 // = new org.docx4j.convert.out.pdf.viaIText.Conversion(olderPackage); 104 104 c.view();
Note: See TracChangeset
for help on using the changeset viewer.
