Hi!

Thank's for replying Tilman. What i want is to merge several different pdf's to 
one single document. I have a main document from a file and an adress-database. 
I take the main document, put an adress on it. Take the same main document, put 
the next adress on it and so on. This is done at "oneDocSerial". At the end of 
that loop i want to merge these documents into one single pdf. This single pdf 
shall now be displayed for the user and maybe printed out. Not saved to file.

The conversion into InputStream is done only for the reason being able to use 
your Example.

You mentioned this were an empty stream:
Compute docPer:
    private InputStream oneDocSerial(PDDocument doc) throws IOException {
        // do something with doc -> put an adress there
        PDStream ps = new PDStream(doc);
        InputStream output = ps.createInputStream();
        return output;
    }
The "doc" in "oneDocSerial" is the main document originally loaded from a file. 
Then an adress is added to this document. Could you please tell me how to 
convert the result into avalid InputStream to get your example working?

Or is there a directer way to merge the adress-pdf documents into one single 
without need using InputStream?

Kind regards,
Siegfried
-
Siegfried Gstöttner
[email protected]

-----Ursprüngliche Nachricht-----
Von: Tilman Hausherr [mailto:[email protected]] 
Gesendet: Mittwoch, 27. Juli 2016 19:40
An: [email protected]
Betreff: Re: Problem with PDFMergerExample()

Am 27.07.2016 um 14:42 schrieb Gstöttner Siegfried:
> Hello all!
>
> I am using the original example from
> https://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/
> apache/pdfbox/examples/util/PDFMergerExample.java?view=log
> and get an End-of-File-Error at the line 
> pdfMerger.mergeDocuments(MemoryUsageSetting.setupMainMemoryOnly());
> in
> public InputStream merge(List<InputStream> sources) throws IOException 
> {...}
>
> Snippets of my code are:
>
> List:
>      private final List<InputStream> mergedPDF = new ArrayList<InputStream>();
>      public List<InputStream> getMergedPDF() {
>          return mergedPDF;
>      }
>
> Load a pdf:
> PDDocument docPer = PDDocument.load(new File("..."));
>
> Adding items to the List in a loop:
> getMergedPDF().add(oneDocSerial(docPer));
>
> Compute docPer:
>      private InputStream oneDocSerial(PDDocument doc) throws IOException {
>          // do something with doc
>          PDStream ps = new PDStream(doc);
>          InputStream output = ps.createInputStream();
>          return output;
>      }

That is not a PDF. That is an empty stream.

> Could anybody please tell me what to do...? If possible in a more detailed 
> manner, I'm a beginner...

what do you want to do? If you want the input stream of a PDF (which doesn't 
make sense if you have the PDF as a file), then do this:

PDDocument.load(new FileInputStream(new File(...)))


Tilman


>
> Kind regards from Salzburg, Austria,
> Siegfried
> -
> Siegfried Gstöttner
> [email protected]
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to