1 2 Previous Next 27 Replies Latest reply: Apr 4, 2007 6:28 PM by 807575 RSS

    I Did it!, I did it! Itext integratioon with creator to generate PDF files

    807575
      With the help of some friends in this forum, i used itext library to create pdf files succesful in java studio creator using servlets, if someone is interested in, send me an email and maybe i can be help you to tell u how, tnks a lot foes!

      jgutierrez@intecnia.com.mx
        • 1. Re: I Did it!, I did it! Itext integratioon with creator to generate PDF fi
          807575
          Some foes, asked me to use IText with creator soo, i will tell you how:

          First, download the java jar itext1.4 file from the site, then add a new library to Creator using library manager in the proyects navigator. Once you have added the jar file, create a new java class file WITH THE NAME OF THE SERVLET U WILL USE, you can do this in project navigator and new > java class. Then delete all the code that creator puts in it, paste all the code of your servlet here, and you must configure the web.xml file to call the servlet.

          In projects navigator change to view files, an search in web > WEB-INF the web.xml file and open it with double click. Click on servlets, and add servlet element. Give a name for your servlet, and in servlet class > browse> source packages, and select the .java file u added as ur servlet. In URL Patterns, give the way of u want to call ur servlet for example:

          to call a servlet named servletname and the URL pattern is /servletname use this in the navigator:

          http://localhost/proyect1/servletname?presentationtype=pdf

          and its ready!, you can copy the servlets u want from the site > tutorials , just remember to left the headers of the authors. If u have a question, ill try to make it big! or help.

          I hope it helps!
          • 2. Re: I Did it!, I did it! Itext integratioon with creator to generate PDF fi
            807575
            Congratulations! Did you do something like this?

            1. Download itext-1.4.5.jar from the iText site http://www.lowagie.com/iText/download.html

            2. You adapted a servlet example from the iText tutorial. Maybe the "Hello World JSP" from http://itextdocs.lowagie.com/tutorial/general/webapp/index.html

            3. You used the servlet in a Creator application, following the instructions in your 2nd post in this forum thread.

            Let me know if this is right, and if any more details are needed.
            • 3. Re: I Did it!, I did it! Itext integratioon with creator to generate PDF fi
              807575
              Hello, this is right, that's the way i followed to make it work, with this u only need to copy any servlet from itext tutorial into creator, and MAGIC!. No more details than i posted here, if u have any problem, let me know to help u.
              • 4. Re: I Did it!, I did it! Itext integratioon with creator to generate PDF fi
                807575
                I want to apologize about my mistake about using "FOE", what i meant was folks, my keyboard is not so accurate, tnks.
                • 5. Re: I Did it!, I did it! Itext integratioon with creator to generate PDF fi
                  807575
                  For more discussion see the related topic "Help generating pdf file in Creator" at http://forum.sun.com/jive/thread.jspa?threadID=106715
                  • 6. Re: I Did it!, I did it! Itext integratioon with creator to generate PDF files
                    807575
                    hi beltazor,

                    The solution you gave for generating pdf from sjsc is great.Now i would like some help .I had some reports which contains data in a table.Now i am able to call the servlet from the button click.What i need is to display the values of the web page in the generated pdf files in a tabular format.Can u please give some idea to how to achieve this.

                    thanks and regards,
                    prasant
                    • 7. Re: I Did it!, I did it! Itext integratioon with creator to generate PDF fi
                      807575
                      Hi, i'm a little confused, first, where is ur data stored, in the database or only in table component of creator?, sec, if u data is in the database u can do something like this:

                      float[] widths = {7f, 12f, 45f,15f,15f};
                      PdfPTable table = new PdfPTable(5);
                      table.setHorizontalAlignment(Element.ALIGN_LEFT);
                      table.setWidthPercentage(100);
                      PdfPCell cell =
                      new PdfPCell(new Paragraph("Products"));
                      cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                      cell.setColspan(5);
                      table.addCell(cell);
                      table.addCell("Qty");
                      cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                      table.addCell("Key");
                      cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                      table.addCell("Description");
                      cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                      table.addCell("Price");
                      cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                      table.addCell("Total");
                      cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                      table.setWidths(widths);

                      int tam =0;
                      try {
                      pkRowSet.setDataSourceName("java:comp/env/jdbc/database");
                      pkRowSet.setCommand("select * from database_table where id=" + value);
                      pkRowSet.setTableName("segusino.database_table");
                      pkRowSet.execute();
                      tam = pkRowSet.size();
                      pkRowSet.first();

                      for(int x = 0; x < tam; x++){
                      table.addCell(pkRowSet.getString("nom"));
                      table.addCell(pkRowSet.getString("value1"));*/
                      table.addCell(pkRowSet.getString("value2"));
                      table.addCell(pkRowSet.getString("key"));
                      table.addCell(pkRowSet.getString("precio"));


                      pkRowSet.next();

                      } } catch (Exception ex) {
                      log("Error Description", ex);
                      }
                      document.add(table);

                      with this u can generate a pdf adding this code to ur servlet from database in mysql, anyway if u want more info, take a look at the tutorials of itext, u can find more commands and very useful examples, but if still u want something else, just post again.

                      http://itextdocs.lowagie.com/tutorial/

                      Beltazor
                      • 8. Re: I Did it!, I did it! Itext integratioon with creator to generate PDF fi
                        807575
                        Hi,

                        I made a small tutorial for iText which you can view at: http://www.ici-indonesia.com/tutorials/itext1/
                        • 9. Re: I Did it!, I did it! Itext integratioon with creator to generate PDF fi
                          807575
                          Hello friends, im working in a complete tutorial of iText integration with java studio creator using all capabilities, (or most of them) of this utility, adding, images, tables, font formats, alignments, and so on, just a cuple of days, anyway if u have more questions about this subject, post again!.

                          Beltazor
                          • 10. Re: I Did it!, I did it! Itext integratioon with creator to generate PDF fi
                            807575
                            hi Beltazor ,

                            Thanks for the reply.Actually i had done some reports which is nothing but simple web page which contains data from the database.I have used table component to display the data.I have a button in my web page.so when i click the button the pdf should be open with the same data as in my web page.Now my problem is how can i open the pdf with the same content of my web page(i.e. the table component with the same data and others) so that i can save the data in a pdf format.

                            thanks and regards,
                            prasant
                            • 11. Re: I Did it!, I did it! Itext integratioon with creator to generate PDF fi
                              807575
                              Ok, i understand, as u can see, above of this post i pasted a code, u can use it, add it into your servlet, and all u have to do is change the name of the database and ur tables, and the values u want, and that's all, play a while with the code and you'll find that is quite simple to make it work as u want, anyway if u cant, post again, ill be around!

                              Beltazor
                              • 12. Re: I Did it!, I did it! Itext integratioon with creator to generate PDF fi
                                807575
                                hi beltazor,

                                thanks for the solution u gave.Its' working fine now.Bye the way when will u post the tutorial for using Itext with SJSC. It will help lots' of people.waiting eagerly for it.

                                once again thanks and regards,
                                prasant
                                • 13. Re: I Did it!, I did it! Itext integratioon with creator to generate PDF fi
                                  807575
                                  I'm still working in Itext Tutorial with Studio Creator to show all interested people, how to use this great library with Creator, i need more time to finish it, due my schedule, but i would like to hear some suggestions about what u want to see in the Tutorial, tnks in advance.

                                  Belthazor
                                  • 14. Re: I Did it!, I did it! Itext integratioon with creator to generate PDF fi
                                    807575
                                    hi beltazor,
                                    I just want to know how u were able to open the pdf file in a separate window.I am facing a problem regarding this.Could u please provide necessary code for opening the servlet in a new window.

                                    thanks in advance,
                                    rpk
                                    1 2 Previous Next