java - PDFBOX 1.8.9 Overlay two PDF documents: Layout pages with COSArray currently not supported -


i want use apache pdfbox (1.8.9) library print white/invisible text on existing pdf documents, therefore create new document, add text in color.white , use "overlay" method merge 2 documents together. doing encountered following problem:

java.lang.unsupportedoperationexception: layout pages cosarray not supported. @ org.apache.pdfbox.overlay.collectlayoutpages(overlay.java:269) @ org.apache.pdfbox.overlay.overlay(overlay.java:224) @ com.db.jocr.main.overlay(main.java:194) @ com.db.jocr.main.main(main.java:91) 

the code looks this:

realdoc = pddocument.load(pathinputdoc); string pathwatermarkdoc = createwhiteonwhitedoc(text, pagecount, color); watermarkdoc = pddocument.load(pathwatermarkdoc); overlay overlay = new overlay(); overlay.overlay(realdoc,watermarkdoc); 

the code apparently "causes" error message not give me hint on how fix that:

        cosbase contents = page.getcosdictionary().getdictionaryobject( cosname.contents );         if( contents instanceof cosstream )         {             ...         }         else if( contents instanceof cosarray )         {             throw new unsupportedoperationexception("layout pages cosarray not supported.");             // layoutpages.add(new layoutpage(contents, res));         } 

can explain me difference between cosstream , cosarray , why cosarray-pages not supported?

grateful hint points me right direction,

thanks, daniel

p.s.: project working on is: https://github.com/dbrenk/jocr

edit: ok had wrong: overlaypdf class seems in pdfbox still

seems i´ve found workaround works: instead of using overlay.class use overlaypdf.class, adds layout original pdf can overlay "tif-based" pdf files too. interface of overlaypdf.class seems strange (no methods, main()) worked test pdf files, here´s code:

string[] args = {pathinputdoc, pathwatermarkdoc, pathoutputdoc}; overlaypdf.main(args); 

i´m still not sure happening in overlaypdf.class - if can explain - great.


Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -