Displaying PDF in UI

I want to display PDF in my UI and got the following error:

com.vaadin.event.ListenerMethod$MethodException
Cause: java.lang.AbstractMethodError: eu.livotov.tpt.gui.vdv.core.SinglePageDocumentRenderer.generateCell(Lcom/vaadin/ui/Table;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
	at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:532)
	at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:164)
	at com.vaadin.ui.AbstractComponent.fireEvent(AbstractComponent.java:1219)
	at com.vaadin.ui.Button.fireClick(Button.java:550)
	at com.vaadin.ui.Button.changeVariables(Button.java:217)
	at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.changeVariables(AbstractCommunicationManager.java:1445)
	at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariableBurst(AbstractCommunicationManager.java:1393)
	at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariables(AbstractCommunicationManager.java:1312)
	at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.doHandleUidlRequest(AbstractCommunicationManager.java:763)
	at com.vaadin.terminal.gwt.server.CommunicationManager.handleUidlRequest(CommunicationManager.java:296)
	at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:501)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:538)
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:478)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
	at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:517)
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:225)
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:937)
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:406)
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:183)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:871)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:110)
	at org.eclipse.jetty.server.Server.handle(Server.java:346)
	at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:589)
	at org.eclipse.jetty.server.HttpConnection$RequestHandler.content(HttpConnection.java:1065)
	at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:823)
	at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:220)
	at org.eclipse.jetty.server.HttpConnection.handle(HttpConnection.java:411)
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:531)
	at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:40)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:529)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.AbstractMethodError: eu.livotov.tpt.gui.vdv.core.SinglePageDocumentRenderer.generateCell(Lcom/vaadin/ui/Table;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;
	at com.vaadin.ui.Table.getVisibleCellsNoCache(Table.java:1691)
	at com.vaadin.ui.Table.refreshRenderedCells(Table.java:1479)
	at com.vaadin.ui.Table.attach(Table.java:3341)
	at com.vaadin.ui.AbstractComponentContainer.attach(AbstractComponentContainer.java:97)
	at com.vaadin.ui.AbstractComponentContainer.attach(AbstractComponentContainer.java:97)
	at com.vaadin.ui.AbstractComponentContainer.attach(AbstractComponentContainer.java:97)
	at com.vaadin.ui.AbstractComponentContainer.attach(AbstractComponentContainer.java:97)
	at com.vaadin.ui.AbstractComponent.setParent(AbstractComponent.java:560)
	at com.vaadin.ui.AbstractComponentContainer.addComponent(AbstractComponentContainer.java:211)
	at com.vaadin.ui.TabSheet.addTab(TabSheet.java:294)
	at com.vaadin.ui.TabSheet.addTab(TabSheet.java:332)
	at com.vaadin.ui.TabSheet.addTab(TabSheet.java:311)
	at com.complete.raspberry.webui.FileAdminView$SearchFormLayout$2.buttonClick(FileAdminView.java:166)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:512)
	... 32 more

My code is like this:

Button advanceSearchButton = new Button("Advance Search",
   new Button.ClickListener() {
    public void buttonClick(ClickEvent event) {

     DocumentViewer viewer = new DocumentViewer();
     viewer.loadDocument ( new PdfDocument ( new java.io.File ( "C:/handbook.pdf" ) ) );
     System.out.println("Pages pdf : " + viewer.getPagesCount());                           
     VerticalLayout myTabCoursPDF = new VerticalLayout();
     myTabCoursPDF.addComponent(viewer);  
     tabsheet.addTab(myTabCoursPDF);

I’ve also included the following JARs in my project:

icepdf-core.jar
icepdf-pro.jar
icepdf-pro-intl.jar
tpt-core.jar

Now what is the problem in my code… Can anyone plzz help me…

Well you are getting an AbstractMethodError, what means you are calling an abstract method without implementing it. I guess your usage of the PDFViewer is probably wrong, but I can’t help there as I don’t know that particular library.

As far as I know, ICEpdf Viewer is a swing viewer and you can not use it with vaadin which is browser based.
In browser based applications, you do not need a PDF viewer because the browser may be directly supporting PDF viewing (example: Chrome) or you can configure a PDF viewer plug-in.
In your example, you are trying to show a PDF file that was already available on your harddisk and you don’t need any PDF-specific library for that. Just use the FileResource to download it to the client.

As an addition: For display you can use the Embedded-Component with TYPE_BROWSER set.

thnx to all and now i want to restrict PDF printing in vaadin to some users… How can i do that??

You will have to encrypt the PDF using your PDF-generation-tool (iText or Adobe Pro). Otherwise it will always be possible to print and / or save the PDF.

is this possible with document viewer??

is this possible to show pdf from hard disk with tpt Document Viewer??