jPDFEditor comes packaged with Qoppa’s jPDFProcess library, providing access to a rich API to further manipulate PDF documents programmatically. This allows to manipulate the PDF document that is currently opened while the bean receives all the user interface notifications.

Here is sample code showing how to add a new “insert” button to the toolbar that will append another PDF to the PDF currently opened in the PDF editing bean. The bean will refresh correctly (including thumbnails) when the other PDF is appended. This sample can be easily edited to insert selected pages of the PDF instead of appending the whole PDF by using the insertPage() method instead of the appendDocument() method.

// create new PDFEditorBean
pdfEditorBean = new PDFEditorBean();
 
// Add a new insert button to the toolbar
JButton insertPages = new JButton("Insert");
pdfEditorBean.getAnnotToolbar().add(insertPages);
 
// action listener for the new button
insertPages.addActionListener(new ActionListener() {
 
public void actionPerformed(ActionEvent e)
{
	if (pdfEditorBean.getDocument() != null)
	{
		try
		{
			// append another PDF to the currently opened PDF
			pdfEditorBean.getDocument().appendDocument(new PDFDocument("c:\\myfolder\\input.pdf", null));
		}
		catch (PDFException e1)
			{
			 e1.printStackTrace();
			}
		}
	}  
});

Download the full sample that creates a simple Frame and adds the PDFEditorBean to it with a new “insert” button on the toolbar.
SimpleFrameManipulatePDF.java