Generate PDF

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

Generate PDF

ramlael
Hi Friends,

I have requirement need to generate pdf with string data which is in byte stream and need to open in new window (pop up).  I have used below code , but its displaying in same window, not in pop up.. please can you help me on this.

  public void downloadPdf(RequestCycle requestCycle, final String eStatement, String filename) {
       
        final WebResponse webResponse = (WebResponse) requestCycle.getResponse();
        webResponse.setContentType("APPLICATION/PDF");
        webResponse.setHeader("Content-Disposition", "inline; filename=\"" + filename + "\"");
        requestCycle.setRequestTarget(new IRequestTarget() {
           
            public void respond(RequestCycle requestCycle) {
                try {

                    OutputStream stream = webResponse.getOutputStream();
                    OutputStreamWriter writer = new OutputStreamWriter(stream, "ISO-8859-1");
                    writer.write(eStatement);
                   writer.flush();
                    writer.close();
                } catch (IOException ex) {
                    ex.printStackTrace();
                }
            }

            public void detach(RequestCycle requestCycle) {
            }

        });
    }
 

Thanks in advance
Rambabu
Reply | Threaded
Open this post in threaded view
|

Re: Generate PDF

Igor Vaynberg-2
put a target="export" attribute on the link tag.

-igor

On Thu, Jul 7, 2011 at 5:32 AM, ramlael <[hidden email]> wrote:

> Hi Friends,
>
> I have requirement need to generate pdf with string data which is in byte
> stream and need to open in new window (pop up).  I have used below code ,
> but its displaying in same window, not in pop up.. please can you help me on
> this.
>
>  public void downloadPdf(RequestCycle requestCycle, final String
> eStatement, String filename) {
>
>        final WebResponse webResponse = (WebResponse)
> requestCycle.getResponse();
>        webResponse.setContentType("APPLICATION/PDF");
>        webResponse.setHeader("Content-Disposition", "inline; filename=\"" +
> filename + "\"");
>        requestCycle.setRequestTarget(new IRequestTarget() {
>
>            public void respond(RequestCycle requestCycle) {
>                try {
>
>                    OutputStream stream = webResponse.getOutputStream();
>                    OutputStreamWriter writer = new
> OutputStreamWriter(stream, "ISO-8859-1");
>                    writer.write(eStatement);
>                   writer.flush();
>                    writer.close();
>                } catch (IOException ex) {
>                    ex.printStackTrace();
>                }
>            }
>
>            public void detach(RequestCycle requestCycle) {
>            }
>
>        });
>    }
>
>
> Thanks in advance
> Rambabu
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Generate-PDF-tp3651354p3651354.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Generate PDF

ramlael
Hi, its working fine with normal link, but not with ajax link, any idea about this problem?
Reply | Threaded
Open this post in threaded view
|

Re: Generate PDF

Martin Grigorov-4
Why do you use Ajax for this ?

On Wed, Jul 13, 2011 at 4:38 PM, ramlael <[hidden email]> wrote:

> Hi, its working fine with normal link, but not with ajax link, any idea about
> this problem?
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Generate-PDF-tp3651354p3665040.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>



--
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: Generate PDF

Stefan Lindner
In reply to this post by ramlael
Here is my code for generating PDF from AjaxLink in a seperate window



public abstract class AjaxPdfGenerationIconPanel<T extends Serializable> extends AbstractPdfGenerationPanel<T> {

        private static final long serialVersionUID = 1L;

        private final SimpleAttributeModifier[] behaviors;

        public AjaxPdfGenerationIconPanel(final String id, final IModel<T> model, SimpleAttributeModifier...behaviors) {
                super(id, model);

                this.behaviors = behaviors;


                final AJAXDownload download = new AJAXDownload();
                add(download);


                AjaxLink<T> pdfLink = new AjaxLink<T>("pdf") {
                        private static final long serialVersionUID = 1L;
                        @Override
                        public void onClick(AjaxRequestTarget target) {
                                AjaxPdfGenerationIconPanel.this.onClick(target);

                                download.initiate(target);
                        }
                };


                pdfLink.add(getIcon("icon"));

                add(pdfLink);
        }


        protected VImage getIcon(final String id) {
                return new VImage(id, Icons.drucken25x25, behaviors);
        }


        private class AJAXDownload extends AbstractAjaxBehavior {
                private static final long serialVersionUID = 1L;

                public void initiate(AjaxRequestTarget target) {
                        target.appendJavascript("window.open('" + getCallbackUrl() + "', '', 'scrollbars=yes,location=no,menuBar=no,resizable=yes,status=no,toolbar=no')");
                }

                public void onRequest() {
                        getComponent().getRequestCycle().setRequestTarget(new ResourceStreamRequestTarget(new MyResourceStreamWriter()));
                }
        }



        protected void onClick(final AjaxRequestTarget target) { }

}














=== and ==============================



import java.io.OutputStream;
import java.io.Serializable;

import org.apache.wicket.model.IModel;
import org.apache.wicket.util.resource.AbstractResourceStreamWriter;

import de.visionet.wicket.wrapper.VPanel;


abstract class AbstractPdfGenerationPanel<T extends Serializable> extends VPanel<T> {

        private static final long serialVersionUID = 1L;

        public AbstractPdfGenerationPanel(final String id, final IModel<T> model) {
                super(id, model);
        }

        public class MyResourceStreamWriter extends AbstractResourceStreamWriter {
                private static final long serialVersionUID = 1L;

                public MyResourceStreamWriter() {
                }

                @Override
                public void write(final OutputStream output) {
                        getOutput(output, getModel());
                        try {
                                output.flush();
                        } catch (Exception e) {
                                e.printStackTrace();
                        }
                }

                @Override
                public String getContentType() {
                        return "application/pdf";
                }
        }



        protected abstract void getOutput(final OutputStream output, IModel<T> model);

}


-----Ursprüngliche Nachricht-----
Von: ramlael [mailto:[hidden email]]
Gesendet: Mittwoch, 13. Juli 2011 15:39
An: [hidden email]
Betreff: Re: Generate PDF

Hi, its working fine with normal link, but not with ajax link, any idea about this problem?

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Generate-PDF-tp3651354p3665040.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Generate PDF

ramlael
In reply to this post by Martin Grigorov-4
I have requirement like, the 'pdf'/'html url' coming from web services,  based on condition I need to display pdf/html in new window, if I use normal Link, not able to open the html in different window, if its ajax link I can add java script for opening in new window.

Regards,
Rambabu
Reply | Threaded
Open this post in threaded view
|

Re: Generate PDF

Martin Grigorov-4
better check the documentation for <A> HTML element, specifically
'target' attribute

you don't need Wicket Link for this. You can do it with
WebMarkupContainer + AttributeModifier("href")
<a target="_blank" wicket:id="webMarkupContainer">

On Wed, Jul 13, 2011 at 5:11 PM, ramlael <[hidden email]> wrote:

> I have requirement like, the 'pdf'/'html url' coming from web services,
> based on condition I need to display pdf/html in new window, if I use normal
> Link, not able to open the html in different window, if its ajax link I can
> add java script for opening in new window.
>
> Regards,
> Rambabu
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Generate-PDF-tp3651354p3665128.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>



--
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Generate PDF

Abigail
In reply to this post by ramlael
Hi there
I am a beginner of PDF processing .And i am looking for a PDF processing program.I know there are many third party program which supports to process PDF files.But i want to get a free trial package before i decided to purchase it.Thanks for any suggestions.
Reply | Threaded
Open this post in threaded view
|

SV: Generate PDF

Tron Walseth
Hi

I use Apache PDFBox for PDF generation on our site, in conjunction with Wicket. This works as a charm, but i haven't tried it with large documents.

Yours,
Tron
________________________________________
Fra: Abigail [[hidden email]]
Sendt: 23. desember 2013 07:38
Til: [hidden email]
Emne: Re: Generate PDF

Hi there
I am a beginner of PDF processing .And i am looking for a  PDF processing
<http://www.rasteredge.com/how-to/csharp-imaging/pdf-processing/>
program.I know there are many third party program which supports to process
PDF files.But i want to get a free trial package before i decided to
purchase it.Thanks for any suggestions.



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Generate-PDF-tp3651354p4663182.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Generate PDF

Niranjan Rao
In reply to this post by Abigail
Do you want to use it in wicket application or java application? The
link is for csharp based tool and will not work in wicket application.
But it looks like they have java API also
http://www.rasteredge.com/java-imaging/.

Personally we use apache pdf box. We don't create PDF, but we do analyze
PDF files using the API. Reasonably happy with PDF box.

On 12/22/2013 10:38 PM, Abigail wrote:

> Hi there
> I am a beginner of PDF processing .And i am looking for a  PDF processing
> <http://www.rasteredge.com/how-to/csharp-imaging/pdf-processing/>
> program.I know there are many third party program which supports to process
> PDF files.But i want to get a free trial package before i decided to
> purchase it.Thanks for any suggestions.
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Generate-PDF-tp3651354p4663182.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Generate PDF

mscoon
In case your requirements for pdf generation are not very complex, you
could use FlyingSaucer (https://xhtmlrenderer.java.net/). It basically
converts html to pdf. So you can create your output in html and then
convert it to pdf using flying saucer.


On Mon, Dec 23, 2013 at 10:45 PM, Niranjan Rao <[hidden email]> wrote:

> Do you want to use it in wicket application or java application? The link
> is for csharp based tool and will not work in wicket application. But it
> looks like they have java API also http://www.rasteredge.com/java-imaging/
> .
>
> Personally we use apache pdf box. We don't create PDF, but we do analyze
> PDF files using the API. Reasonably happy with PDF box.
>
>
> On 12/22/2013 10:38 PM, Abigail wrote:
>
>> Hi there
>> I am a beginner of PDF processing .And i am looking for a  PDF processing
>> <http://www.rasteredge.com/how-to/csharp-imaging/pdf-processing/>
>> program.I know there are many third party program which supports to
>> process
>> PDF files.But i want to get a free trial package before i decided to
>> purchase it.Thanks for any suggestions.
>>
>>
>>
>> --
>> View this message in context: http://apache-wicket.1842946.
>> n4.nabble.com/Generate-PDF-tp3651354p4663182.html
>> Sent from the Users forum mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Generate PDF

Ernesto Reinaldo Barreiro-4
I have also used flying saucer together with wicket: it was very easy to
produce nice looking PDFs using it.


On Mon, Dec 23, 2013 at 10:30 PM, Marios Skounakis <[hidden email]> wrote:

> In case your requirements for pdf generation are not very complex, you
> could use FlyingSaucer (https://xhtmlrenderer.java.net/). It basically
> converts html to pdf. So you can create your output in html and then
> convert it to pdf using flying saucer.
>
>
> On Mon, Dec 23, 2013 at 10:45 PM, Niranjan Rao <[hidden email]> wrote:
>
> > Do you want to use it in wicket application or java application? The link
> > is for csharp based tool and will not work in wicket application. But it
> > looks like they have java API also
> http://www.rasteredge.com/java-imaging/
> > .
> >
> > Personally we use apache pdf box. We don't create PDF, but we do analyze
> > PDF files using the API. Reasonably happy with PDF box.
> >
> >
> > On 12/22/2013 10:38 PM, Abigail wrote:
> >
> >> Hi there
> >> I am a beginner of PDF processing .And i am looking for a  PDF
> processing
> >> <http://www.rasteredge.com/how-to/csharp-imaging/pdf-processing/>
> >> program.I know there are many third party program which supports to
> >> process
> >> PDF files.But i want to get a free trial package before i decided to
> >> purchase it.Thanks for any suggestions.
> >>
> >>
> >>
> >> --
> >> View this message in context: http://apache-wicket.1842946.
> >> n4.nabble.com/Generate-PDF-tp3651354p4663182.html
> >> Sent from the Users forum mailing list archive at Nabble.com.
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [hidden email]
> >> For additional commands, e-mail: [hidden email]
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
> >
>



--
Regards - Ernesto Reinaldo Barreiro
Reply | Threaded
Open this post in threaded view
|

Re: Generate PDF

BenthamLEE
This post has NOT been accepted by the mailing list yet.
When we are about to create and generate new PDF document, we can choose to create pdf with blank new page and with source image, meanwhile, the page of pdf document can be fully defined.
Reply | Threaded
Open this post in threaded view
|

Re: Generate PDF

ouku
This post has NOT been accepted by the mailing list yet.
Any other solutions?