java - ClassNotFoundException when handling PDF files using iText in Jdeveloper -
i need in solving following error
java.lang.classnotfoundexception: com.itextpdf.text.documentexception
which produced running simple void
method show pdf file in jdeveloper. added itext jar file in libraries , version having 5.5.6.
if writing simple pdf, method executed. when use below code, generates error. code is:
public class pdf { private streamedcontent streamedcontent; private static final long serialversionuid = 1l; @postconstruct public void createpdf() throws documentexception, ioexception { try{ document document = new document(pagesize.a4, 50, 50, 50, 50); outputstream out = new bytearrayoutputstream(); pdfwriter writer = pdfwriter.getinstance(document, out); document.open(); pdfptable table = new pdfptable(1); pdfpcell cell = new pdfpcell(new phrase("\u0627\u0644\u0633\u0644\u064a\u0637\u064a")); cell.setborder(rectangle.no_border); cell.setrundirection(pdfwriter.run_direction_rtl); table.addcell(cell); document.add(table); document.close(); out.close(); inputstream in =new bytearrayinputstream(((bytearrayoutputstream)out).tobytearray()); streamedcontent = new defaultstreamedcontent(in, "application/pdf"); //------- map<string, object> session = facescontext.getcurrentinstance().getexternalcontext().getsessionmap(); byte[] b = (byte[]) session.get("reportbytes"); if (b != null) { streamedcontent = new defaultstreamedcontent(new bytearrayinputstream(b), "application/pdf"); } } catch (exception e) { } }
the itext war file kept under /lib folder , has worked fine. compatible version itext 2.1.7 please refer dependencies in primefaces guide
Comments
Post a Comment