0 0 0 0


my wicket apliaction created some pdf file. now I want to add button to print it somethink like this: how I can do it ?

Best Answer:

it looks you mix two things together. Your example is a javascript. It is not a PDF, it is just printing your document. It is equal as browser menu File -> Print, but the event is invoked from a javascript that handles button action. You can use the same button as in that example and add @print CSS to your web page to make your document nicely printable.

Also there is another way. If you want to print a PDF document from your application and you generate the PDF from Java code, look the following example for Wicket 1.6:

add(new Link<Void>("myPdfLink") {
    private static final long serialVersionUID = 1L;
    public void onClick() {
        byte[] data = ... // TODO your data
        final ByteArrayInputStream stream = new ByteArrayInputStream(data);
        IResourceStream resourceStream = new AbstractResourceStream() {                    
            private static final long serialVersionUID = 1L;
            public InputStream getInputStream() throws ResourceStreamNotFoundException {
                return stream;
            public void close() throws IOException {
            public String getContentType() {
                return "application/pdf";
            new ResourceStreamRequestHandler(resourceStream)

Copyright © 2011 Dowemo All rights reserved.    Creative Commons   AboutUs