1. #1
    Sencha User
    Join Date
    Jun 2011
    Posts
    9
    Vote Rating
    0
    info++ is on a distinguished road

      0  

    Default Gwt+pdf

    Gwt+pdf


    how print data in a pdf file with gwt

  2. #2
    Ext GWT Premium Member
    Join Date
    Aug 2010
    Location
    Germany, Solingen
    Posts
    239
    Vote Rating
    2
    gishmo is on a distinguished road

      0  

    Default


    With pure GWT it won't work.

    you have two opporunities:
    1. Send your request to your server, generate the pdf and send it back to the client
    2. Use something like GWT4Air

  3. #3
    Sencha User
    Join Date
    Jun 2011
    Posts
    9
    Vote Rating
    0
    info++ is on a distinguished road

      0  

    Default


    Can u please give me an example with gwt4air but with the calling service solution didn't work

  4. #4
    Ext GWT Premium Member
    Join Date
    Jan 2009
    Location
    Colorado Springs, CO
    Posts
    365
    Vote Rating
    5
    DavidHoffer is on a distinguished road

      0  

    Default


    I've did this with the following client code (server generated the pdf):

    String url = URL.encode(GWT.getModuleBaseURL() + "pdf?id=" + result + "&presentationtype=pdf");
    Frame frame = new Frame(url);
    frame.setWidth("95%");
    frame.setHeight(height);
    setResult(frame);

    Where setResult sets the frame in the current page. Users can print/save from the displayed pdf.

  5. #5
    Sencha User
    Join Date
    Jun 2011
    Posts
    9
    Vote Rating
    0
    info++ is on a distinguished road

      0  

    Default


    it dosent work for me and i dont know why maybe a reboot will fixe it but i create a pdf file with itext it s easy and free

  6. #6
    Ext GWT Premium Member
    Join Date
    Jan 2009
    Location
    Colorado Springs, CO
    Posts
    365
    Vote Rating
    5
    DavidHoffer is on a distinguished road

      0  

    Default


    You will need the backend servlet that server the requested pdf to the client. E.g.

    <servlet>
    <servlet-name>pdf</servlet-name>
    <servlet-class>com.qsd.server.servlet.PdfServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>pdf</servlet-name>
    <url-pattern>/com.qsd.Calc/pdf</url-pattern>
    </servlet-mapping>

    public class PdfServlet extends HttpServlet {

    private static final long serialVersionUID = 1936378722615937262L;
    private static final IFileUtility fileUtility = new FileUtility();
    private final Logger log;
    public static final String PDF_FOLDER = System.getProperty("java.io.tmpdir") + "/" + "0CF6E3F7-DD81-634E-D119-8CD6564E1013";

    public PdfServlet(Logger log) {
    this.log = log;
    }

    public PdfServlet() {
    this(Logger.getLogger(PdfServlet.class));
    }

    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException {

    final String presentationtype = request.getParameter("presentationtype");
    final String guid = request.getParameter("id");

    InputStream is = null;
    ServletOutputStream outputStream = null;
    try {
    if ("pdf".equals(presentationtype)) {
    response.setContentType("application/pdf");
    final String filename = String.format("%s/%s.pdf", PDF_FOLDER, guid);
    is = fileUtility.getInputStream(filename);
    byte[] buffer = new byte[4096];
    int len;
    outputStream = response.getOutputStream();
    while ((len = is.read(buffer)) != -1) {
    outputStream.write(buffer, 0, len);
    }
    outputStream.flush();
    }
    } catch (Exception e) {
    log.error(format("Failed to serve PDF document in servlet [%s]", guid), e);
    } finally {
    if (is != null) {
    is.close();
    }
    if (outputStream != null) {
    outputStream.close();
    }
    }
    }
    }

  7. #7
    Sencha User
    Join Date
    Jun 2011
    Posts
    9
    Vote Rating
    0
    info++ is on a distinguished road

      0  

    Default


    Thank u it s workin now &nbsp;<br>my mistake was a&nbsp;mistyping the servlet declaration in web.xml

  8. #8
    Ext GWT Premium Member
    Join Date
    Jan 2009
    Location
    Colorado Springs, CO
    Posts
    365
    Vote Rating
    5
    DavidHoffer is on a distinguished road

      0  

    Default


    Good to hear!

    Thanks,
    -Dave

Thread Participants: 2

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi