Hi, Am 08.12.2011 16:28, schrieb Haris Javaid:
Hello there,We are working on a product that supports highlighting a PDF as one of its features. The way we are currently highlighting a document is as follows: 1)Create an empty PDF which has the same number of pages as the ‘document to be highlighted’. 2)Draw a free form highlight on the empty document 3)Put the document to be highlighted on top of the empty document to highlight the text we want to highlight using library’s Overlay.overlay method as a.PDDocument finalDoc = *new*Overlay().overlay(overlayingPdf.getDocument(), bottomDocument); This all works perfectly until the document version changes i.e. it won’t work with a document that was created with Adobe version 1.3. Following is the code from PDDocument.java in PDFBox that hard codes version to be 1.4. *public*PDDocument() *throws*IOException { document = *new*COSDocument(); //First we need a trailer COSDictionary trailer = *new*COSDictionary(); document.setTrailer( trailer ); //Next we need the root dictionary. COSDictionary rootDictionary = *new*COSDictionary(); trailer.setItem( COSName.ROOT, rootDictionary ); rootDictionary.setItem( COSName.TYPE, COSName.CATALOG ); rootDictionary.setItem( COSName.VERSION, COSName.getPDFName( "1.4")); //next we need the pages tree structure COSDictionary pages = *new*COSDictionary(); rootDictionary.setItem( COSName.PAGES, pages ); pages.setItem( COSName.TYPE, COSName.PAGES ); COSArray kidsArray = *new*COSArray(); pages.setItem( COSName.KIDS, kidsArray ); pages.setItem( COSName.COUNT, COSInteger.ZERO ); } As you can see that the library sets up the PDF document version to be 1.4 (highlighted above). So if the version is 1.3, the library will only put highlighting and the original contents of the ‘document to be highlighted’ will be gone. Is it a limitation of the library? Is there a workaround this problem? We are trying to meet a deadline and were very happy with our approach until we hit this issue. I would really be thankful for your help into this matter. Attached is the original pdf and the resulted pdf. Cheers, Haris
That issue should be fixed in the current trunk, see [1] for further details. BR Andreas Lehmkühler [1] https://issues.apache.org/jira/browse/PDFBOX-879

