I need your help in opening the generated PDF file automatically after it is being written from a bean. I used iText
libraries to write a PDF file and in the below method, I am able to generate the PDF, but I do not know how to open it on the fly for the users.
public static void main(String[] args) throws DocumentException, FileNotFoundException, IOException {
Document document = new Document(PageSize.A4, 50, 50, 50, 50);
document.open();
BaseFont bf = BaseFont.createFont(
"c://windows/fonts/arialuni.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
Font font = new Font(bf, 25);
PdfPTable table = new PdfPTable(1);
PdfPCell cell = new PdfPCell(new Phrase("Good Morning", font));
cell.setBorder(Rectangle.NO_BORDER);
cell.setRunDirection(PdfWriter.RUN_DIRECTION_RTL);
table.addCell(cell);
document.add(table);
document.close();
}
I want the PDF file to be shown to the user after it is being written to allow him to print the file, so how can I do this?