当用户正在阅读PDF并完成阅读此文件并关闭PDF时,我需要保存用户在使用PDFBox库2.0.20关闭PDF之前阅读的最后一页
try {
InputStream bos = new ByteArrayInputStream(lib.getPdf()); // lib.getPdf returns the pdf file in byte[] array.
int tamañoPDF= bos.available();
byte [] datosPDF = new byte [tamañoPDF];
bos.read(datosPDF, 0 , tamañoPDF);
OutputStream out = new FileOutputStream (button.getText());
out.write(datosPDF);
button.addActionListener(new ActionListener(){ //setting an action to a button.
public void actionPerformed(ActionEvent ae)
{try {
Desktop.getDesktop().open(new File(button.getText())); //the pdf is opened
out.close(); //here I think I have to insert the code that save the page number
} catch (IOException ex) {
Logger.getLogger(InfoDelLibro.class.getName()).log(Level.SEVERE, null, ex);
}
}
});
} catch (IOException ex) {
Logger.getLogger(InfoDelLibro.class.getName()).log(Level.SEVERE, null, ex);
}
字符串
1条答案
按热度按时间qq24tv8q1#
字符串