Java pdf generator

Joined
May 20, 2008
Messages
1
Reaction score
0
Im writing an Eclipse plugin which posses a function of generating pdf files. but im in a really weird situation. when i add this functionality (generation of pdf file) im not able to run the plugin and it doesnt through any exeption. i already tried two pdf libraries iText and pdfBox but its the same problem.
here is the function for generating the pdf file using iText library:


public void createPdf()
{
Document document = new Document();
PdfWriter writer;
try {
writer = PdfWriter.getInstance(document, new FileOutputStream("C:\\aaa\\aaa.pdf"));
document.open();
document.add(new Paragraph("cccccc"));
document.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (DocumentException e) {
e.printStackTrace();
}
}


and pretty much the same function using pdfBox library:


public static void pd()
{
try {
doc = new PDDocument();
PDPage page = new PDPage();
doc.addPage(page);
doc.save("C:\\film\\eldi.pdf");
} catch (IOException e) {
e.printStackTrace();
} catch (COSVisitorException e) {
e.printStackTrace();
}
finally
{
if(doc!=null)
try {
doc.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}


Can anyone help with this issue?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,173
Latest member
GeraldReund
Top