Note that there are some explanatory texts on larger screens.

plurals
  1. POpdfbox java.io.IOException: Error: End-of-File, expected line
    text
    copied!<p>This is the process.</p> <ol> <li>Make a temp result pdf file using pdf merger.</li> <li>In this pdffile, I'll insert pagenumbers using pdfbox, this will be done.pdf -> this works fine</li> </ol> <p>In here I'm adding</p> <ol> <li>I want to make a Cover page for this done.pdf that will be the first page </li> </ol> <p>This has to be working but I have this</p> <p>java.io.IOException: Error: End-of-File, expected line</p> <p>from merger2.mergeDocuments(); &lt; - here</p> <p>i spent my whole day and still couldn't solve it.</p> <p>This is the code</p> <pre><code> public static void main(String args[]) { String tmpPdfPath = tempFolderPath + "\\" + "tempresult.pdf"; OutputStream bout = new BufferedOutputStream(new FileOutputStream(new File(tmpPdfPath))); System.out.println("temp pdf is written in ::::" + tempFolderPath + "\\" + "tempresult.pdf"); merger.setDestinationStream(bout); merger.mergeDocuments(); String finalPath = tempFolderPath + "\\" + "done.pdf"; PDFBoxParams params = new PDFBoxParams(tmpPdfPath, finalPath); params.setPageRange(PDFBoxParams.PAGE_RANGE_ALL); PDFBoxUtil.addMessage(params); System.out.println("Success!"); //new code ByteArrayOutputStream baos = new ByteArrayOutputStream(); PDFMergerUtility merger2 = new PDFMergerUtility(); merger2.addSource(PDFBoxUtil.displayTOC("hello")); merger2.addSource(new ByteArrayInputStream(baos.toByteArray())); OutputStream bout2 = new BufferedOutputStream(new FileOutputStream( "C:/hereisthefinal.pdf")); merger2.setDestinationStream(bout2); merger2.mergeDocuments(); System.out.println("done! check the pdf!"); } </code></pre> <p>** ok i found something. </p> <p>ByteArrayOutputStream baos = new ByteArrayOutputStream();</p> <p>this part, it has to have all the previous pdf data in it. but it is empty.</p> <p>how do i pull the data to here?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload