can't get same output when calling method from another class
<p>This is my code which run in this class only using main method but i cant get same output when i call that method from another class. why?</p>

<pre><code>public class generatepdf {
    public void pdfgenerator() throws DocumentException, FileNotFoundException, IOException {
        Document document=new Document();
        PdfWriter.getInstance(document,new FileOutputStream("hello.pdf"));
        JOptionPane.showMessageDialog(null, "step-2");
        document.open();

        document.add(new Paragraph("Hello PDF"));
        document.add(new Paragraph("I am kalpen patel"));
        document.add(new Paragraph("Aamir is here"));
        document.close();
        JOptionPane.showMessageDialog(null, "step-3");
    }
}
</code></pre>
