Additional Blogs by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
0 Kudos

Better late than never...

... Is what I can say when I see the support for printing introduced in Web Dynpro CE.  A quick search tells me that there are 150 odd threads on printing issues alone. Web Dynpro on NW 7.0 had no native support for printing and the community came up with pretty good workarounds (converting to PDF, Java Scripting et. al).

But things are about to change in CE and how!! Today I'll demonstrate the newly introduced printing support in CE. Ok, enough blah...let's code 🙂

 

WDPrintService...

... Is a new class introduced in the "com.sap.tc.webdynpro.clientserver.print.api" package and as the name suggests, it provides a factory for client side printing services.

 

Demo...

... Will be based on the following scenario: In our view we have a table and we simply want to print it.  I'll not go through the steps to build the table, we all know it. Here's a screenshot of what this table looks like:

Basic table

The table has a toolbar and it has a single button labeled “Print”. No prizes for guessing that on click of this button we will invoke the print service and thereby print this table view. I have created an action Print and in the onActionPrint event handler method I wrote the following code:

 

//the print method takes a IWDViewController instance as parameter

WDPrintService.getPrintService().print(wdControllerAPI);

 

Once the application is run and the “Print” button on the table is clicked, you can see the framework generated print preview page which in this case looks like

Print Preview

By clicking on the “Print” button on the top of the print preview page, we get to see the good old Windows print dialog.

 

Dialog

 

Let me end...

... By saying that this newly introduced API will make it easier for us, the application developers, to obtain a very basic thing like printing. We no longer have to fight with workarounds. But looking at the API, we cannot print only a selected area of the view. Looking forward to the later SPs.

13 Comments