In Apache FOP I recently developed experimental support for embedding existing PDFs in XSL-FO documents destined for PDF output as normal fo:external-graphic elements. I used PDFBox to parse the PDFs since FOP's PDF library doesn't support parsing. I wrote some adapter code that translates PDFBox's object model into FOP's.
While doing that I stumbled over the problem that I couldn't access the individual streams in a stream array. Therefore I added accessors for that. Please find these in the patch file. I'd be grateful if they could be added to PDFBox.
During my work I changed from the scratch file to a RandomAccessBuffer in PDStream's constructor. Since it was before my holidays I don't remember exactly why I did that. I think I had a case where more than one scratch file was needed. But I can't reproduce it anymore. That may just be something to think about. I'll re-raise this if I can reproduce the problem.