pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Woude, Alexander van der" <alexander.vander.wo...@capgemini.com>
Subject Setting the version of pdf with PDFMergerUtility
Date Wed, 21 Dec 2011 12:31:11 GMT
Hello all,

I am facing a problem.

I retrieve documents from Oracle's UCM (content manager). I receive the doc=
uments  - all pdfs - from UCM as a stream.=20
A ByteArrayOutputStream to be precise.

My problems is that some docuemtns I retrieve are scanned, and stored as PD=
F1.2 format.
After I merge all the documents the generated PDF is 1.2. In that version a=
 fonttype is not available and cause that some docs in the concatenated pdf=
 is unreadable.
So I want to set the merged version to 1.4.

I tried to reuse the code from the PDFMergerUtility. mergeDocuments(), inco=
rporated it in my own code and alter it. See below.
Can someone suggest me what I do wrong or point me to a better way of doing=

Regards, Alexander

private void mergeDocuments(PDFMergerUtility mergeUtil) throws IOException,=
        PDDocument destination =3D null;
        InputStream sourceFile;
        PDDocument source;
        if (streamOfPDFFiles !=3D null && streamOfPDFFiles.size() > 0)
         java.util.Vector<PDDocument> tobeclosed =3D new java.util.Vector<P=
                Iterator<InputStream> sit =3D streamOfPDFFiles.iterator();
                sourceFile =3D sit.next();
                destination =3D PDDocument.load(sourceFile);
                while (sit.hasNext())
                    sourceFile =3D sit.next();
                    source =3D PDDocument.load(sourceFile);
                    mergeUtil.appendDocument(destination, source);
                if (destination !=3D null)
                 for(PDDocument doc : tobeclosed){

This message contains information that may be privileged or confidential and is the property
of the Capgemini Group. It is 
intended only for the person to whom it is addressed. If you are not the intended recipient,
you are not authorized to 
read, print, retain, copy, disseminate, distribute, or use this message or any part thereof.
If you receive this message 
in error, please notify the sender immediately and delete all copies of this message.

View raw message