Aspose Demos > Java Components > Aspose.Slides for Java > Java > Northwind
Important: To produce PowerPoint presentations and PDF documents, the machine to run Aspose.Slides and Aspose.PDF doesn't need to have Microsoft PowerPoint or Adobe Acrobat installed. However, to view the contents of PowerPoint presentations and PDF documents produced by demos, the machine to view them does need a Microsoft PowerPoint or Adobe Acrobat Reader.

Northwind Demo
Generates a PPT or PDF file by utilizing user input and the Northwind database

Presenter Name:
Reporting Location:
Reporting Year:
Reporting Month:
Company Website:
Company Name:
Company Address:
Company City:State:Zip:
Company Picnic Date:
JAVA

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198

package com.aspose.slides.demos.jsf;

import java.io.Serializable;

import java.io.*;
import java.util.*;

import javax.servlet.*;
import javax.servlet.http.*;

import com.aspose.slides.*;

import javax.media.jai.JAI;
import javax.media.jai.RenderedOp;
import java.io.*;
import java.net.URL;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.text.SimpleDateFormat;

import javax.faces.context.FacesContext;
import javax.faces.event.*;
import javax.faces.component.UIComponent;

import java.lang.reflect.*;

public class Northwind extends BaseDemo implements Serializable 
{
    String PresenterName, CompanyWebSite, ReportingMonth, ReportingYear,
        ReportingLocation, CompanyName, CompanyAddress, CompanyCity,
        CompanyState, CompanyZip, PicnicDate;
    Connection con = null;

    int daysInMonth[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

    String NameOfMonth[] = {
        "January", "February", "March", "April", "May",
        "June", "July", "August", "September", "October", "November", "December"};

    // Default Constructor
    public Northwind() {
        initLicense(new License());
    }
   
    private String _presenter = "John Doe";
    public String getPresenter() {
        return _presenter;
    }
    public void setPresenter(String v) {
        _presenter = v;
    }

    private String _companyweb = "www.aspose.com";
    public String getCompanyweb() {
        return _companyweb;
    }
    public void setCompanyweb(String v) {
        _companyweb = v;
    }

    private Boolean _chart3d = false;
    public Boolean getChart3d() {
        return _chart3d;
    }
    public void setChart3d(Boolean v) {
        _chart3d = v;
    }

    private String _employeeloc = "Kirkland";
    public String getEmployeeloc() {
        return _employeeloc;
    }
    public void setEmployeeloc(String v) {
        _employeeloc = v;
    }

    private String _companyname = "Aspose Pty.";
    public String getCompanyname() {
        return _companyname;
    }
    public void setCompanyname(String v) {
        _companyname = v;
    }

    private String _companyaddr = "126 First st.";
    public String getCompanyaddr() {
        return _companyaddr;
    }
    public void setCompanyaddr(String v) {
        _companyaddr = v;
    }

    private String _companycity = "Tyler";
    public String getCompanycity() {
        return _companycity;
    }
    public void setCompanycity(String v) {
        _companycity = v;
    }

    private String _companystate = "TX";
    public String getCompanystate() {
        return _companystate;
    }
    public void setCompanystate(String v) {
        _companystate = v;
    }

    private String _companyzip = "75704";
    public String getCompanyzip() {
        return _companyzip;
    }
    public void setCompanyzip(String v) {
        _companyzip = v;
    }

    private String _reportingyear = "1997";
    public String getReportingyear() {
        return _reportingyear;
    }
    public void setReportingyear(String v) {
        _reportingyear = v;
    }

    private String _reportingmonth = "1";
    public String getReportingmonth() {
        return _reportingmonth;
    }
    public void setReportingmonth(String v) {
        _reportingmonth = v;
    }

    /*
    private String _picknickdate = "mm/dd/yyyy";
    public String getPicknickdate() {
        return _picknickdate;
    }
    public void setPicknickdate(String d) {
        _picknickdate = d;
    }
    */
    private Date _picknickdate = new Date(2008, 1, 2);
    public Date getPicknickdate() {
        return _picknickdate;
    }
    public void setPicknickdate(Date d) {
        _picknickdate = d;
    }

    /*
    public void validateUsername(FacesContext facesContext, UIComponent uiComponent,
        Object value) throws ValidatorException 
    {
        // perform
        if (the validation fails) 
        {
            throw new ValidatorException(new FacesMessage("Invalid Picknick date"));
        }
    }
    */


    /**
     * Execute request
     *
     * @return success
     */
    public Boolean execute() {

        try
        {
            String path = "/resources/";

            context = FacesContext.getCurrentInstance();
            request = (HttpServletRequest) context.getExternalContext().getRequest();
            response = (HttpServletResponse) context.getExternalContext().getResponse();

            if (null==request) {
                System.err.println("REQUEST NULL??!");
            }

            // Get Path to save to updated file to
            Presentation pres = new Presentation(getFile(request, path + "demo_new.ppt"));

            // Open the database connection
            openDBConnection(getFileName(request, path + "Northwind.mdb"));

            // Declare Post Varaibles
            PresenterName = getPresenter();
            CompanyWebSite = getCompanyweb();
            ReportingMonth = getReportingmonth();
            ReportingYear = getReportingyear();
            ReportingLocation = getEmployeeloc();
            CompanyName = getCompanyname();
            CompanyAddress = getCompanyaddr();
            CompanyCity = getCompanycity();
            CompanyState = getCompanystate();
            CompanyZip = getCompanyzip();
            //PicnicDate = getPicknickdate();

            // Set SlideMaster Properties
            pres = setupSlideMaster(pres);

            // Get references to slides in presentation by position
            Slide slide1 = pres.getSlideByPosition(1);
            Slide slide2 = pres.getSlideByPosition(2);

            // Create a clone of slide2 and place it into position 3
            pres.cloneSlide(slide2, 3);
            Slide slide3 = pres.getSlideByPosition(3);
            Slide slide4 = pres.getSlideByPosition(4);
            Slide slide5 = pres.getSlideByPosition(5);
            Slide slide6 = pres.getSlideByPosition(6);
            Slide slide7 = pres.getSlideByPosition(7);
            Slide slide8 = pres.getSlideByPosition(8);

            // I have created methods for each slide to help seprate out the code

            slide1 = Slide1(slide1);
            slide2 = Slide2(slide2);
            slide3 = Slide3(slide3);
            slide4 = Slide4(slide4);
            slide5 = Slide5(slide5);
            slide6 = Slide6(slide6, pres);
            slide7 = Slide7(slide7);
            slide8 = Slide8(slide8, pres);
            pres.cloneSlide(slide1, 9);
            Slide slide9 = pres.getSlideByPosition(9);
            slide9 = Slide9(slide9);

            // Slide 7 is removed because it contains featues from the .NET version that the Java version does not support.
            pres.getSlides().remove(slide7);

            // Close the database connection
            closeDBConnection();

            // Save Presentation to a file
            //pres.write(destination);

            //destination.close();
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            //response.addHeader("Content-Disposition", "attachment; filename=demo_new.ppt");
            //pres.write(response.getOutputStream());
            pres.write(out);
            //context.responseComplete();
            setResponse("demo_new.ppt", out);
            return true;
        }catch(Exception ex)
        {
            ex.printStackTrace();
        }

        return false;
    }

    public void openDBConnection(String fileName) throws Exception {
        try {
            // Connect to the database
            //Class.forName("net.sourceforge.jtds.jdbc.Driver");
            //con = DriverManager.getConnection("jdbc:jtds:sqlserver://localhost:1433/northwind", "northwind", "northwind");

            //Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
            //con = DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433/northwind;Integrated Security=SSPI");
            //con = DriverManager.getConnection("jdbc:mysql://localhost:3306/northwind", "root", "");

            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            con = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=" + fileName.replace("\\", "/") + ";", "", "");
        } catch (Exception e) {
            e.printStackTrace();
            throw e;
        }
    }
/*
    public void openDBConnection() throws Exception {
        try {
            // Connect to the database
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            con = DriverManager.getConnection("jdbc:odbc:NorthWind", "", "");
        } catch (Exception e) {
            throw e;
        }
    }
*/
    public void closeDBConnection() throws Exception {
        try {
            // Close datebase connection
            con.close();
            con = null;
        } catch (Exception e) {
            throw e;
        }
    }

    public Presentation setupSlideMaster(Presentation pres) throws Exception {
        try {
            // Get slide master
            Slides slides = pres.getMasters();
            Slide slide = slides.get(0);
            // Set slide master propertires
            slide.getBackground().getFillFormat().setType(FillType.GRADIENT);
            slide.getBackground().getFillFormat().setGradientColorType(GradientColorType.TWO_COLORS);
            slide.getBackground().getFillFormat().setForeColor(java.awt.Color.decode("#f5f5dc"));
            slide.getBackground().getFillFormat().setBackColor(java.awt.Color.decode("#1E90FF"));
        } catch (Exception e) {
            throw e;
        }
        return pres;
    }

    public Slide Slide1(Slide slide1) throws Exception {
        // Introduction
        try {
            for (int j = 0; j < slide1.getShapes().size(); j++) {
                Shape shape = slide1.getShapes().get(j);
                if (shape.getTextFrame() != null) {
                    TextFrame tf = shape.getTextFrame();
                    Paragraph para = tf.getParagraphs().get(0);
                    if (para.getText().toString().startsWith("Presenter")) {
                        para.setAlignment(TextAlignment.CENTER);
                        Portion port = para.getPortions().get(0);
                        port.setFontBold(false);
                        port.setFontColor(java.awt.Color.BLACK);
                        port.setFontHeight((short) 30);
                        port.setText("Presented By: " + PresenterName);
                    } else if (para.getText().equals("HyperLink")) {
                        para.setAlignment(TextAlignment.LEFT);
                        Portion port = para.getPortions().get(0);
                        port.setFontHeight((short) 20);
                        port.setText(CompanyWebSite);
                        tf.getLinks().clear();
                        Link link = tf.getLinks().addLink();
                        link.setInternalHyperlink(slide1);
                        link.setBegin(0);
                        link.setEnd(tf.getText().length());
                    }
                }
            }

            // Create Shape to Hold Business Info
            Shape shape1 = slide1.getShapes().addRectangle(1550, 300, 2700, 1200);

            // Set Shape Properties
            shape1.getLineFormat().setWidth(3);
            shape1.getFillFormat().setType(FillType.TEXTURE);
            shape1.getFillFormat().setTextureStyle(TextureStyle.NEWSPRINT);

            // Add Transition Effects
            shape1.getAnimationSettings().setEntryEffect(ShapeEntryEffect.STRETCH_ACROSS);

            // Add A TextFrame to the Shape
            shape1.addTextFrame("Shape1");

            if (shape1.getTextFrame() != null) {
                // Add first paragraph to the shape
                TextFrame tfsh1 = shape1.getTextFrame();
                Paragraph parash1 = tfsh1.getParagraphs().get(0);
                parash1.setAlignment(TextAlignment.CENTER);
                Portion port = parash1.getPortions().get(0);
                port.setFontBold(false);
                port.setFontColor(java.awt.Color.decode("#1E90FF"));
                port.setFontHeight((short) 30);
                port.setText(CompanyName);

                // Add second paragraph to the shape
                int phnum = tfsh1.getParagraphs().add(new Paragraph(tfsh1.getParagraphs().
                        get(0)));
                Paragraph para2sh1 = tfsh1.getParagraphs().get(phnum);
                Portion port2 = para2sh1.getPortions().get(0);
                port2.setFontBold(false);
                port2.setFontColor(java.awt.Color.decode("#1E90FF"));
                port2.setFontHeight((short) 30);
                port2.setText(CompanyAddress);

                // Add third paragraph to the shape
                phnum = tfsh1.getParagraphs().add(new Paragraph(tfsh1.getParagraphs().get(1)));
                Paragraph para3sh1 = tfsh1.getParagraphs().get(2);
                Portion port3 = para3sh1.getPortions().get(0);
                port3.setFontBold(false);
                port3.setFontColor(java.awt.Color.decode("#1E90FF"));
                port3.setFontHeight((short) 30);
                port3.setText(CompanyCity + ", " + CompanyState + "  " + CompanyZip);
            }

            // Add Slide Transition Effect
            slide1.getSlideShowTransition().setEntryEffect(SlideTransitionEffect.FADE_SMOOTHLY);
        } catch (Exception e) {
            throw e;
        }
        return slide1;
    }

    public Slide Slide2(Slide slide2) throws Exception {
        // Employee Directory
        for (int j = 0; j < slide2.getShapes().size(); j++) {
            Shape shape = slide2.getShapes().get(j);
            if (shape.getTextFrame() != null) {
                TextFrame tf = shape.getTextFrame();
                if (tf.getParagraphs().size() != 0) {
                    Paragraph para = tf.getParagraphs().get(0);
                    if (para.getText().equals("Subtitle")) {
                        para.setAlignment(TextAlignment.CENTER);
                        Portion port = para.getPortions().get(0);
                        port.setFontBold(false);
                        port.setFontColor(java.awt.Color.BLACK);
                        port.setFontHeight((short) 30);
                        port.setText("Location: " + ReportingLocation);
                    } else if (para.getText().equals("CH1")) {
                        para.setAlignment(TextAlignment.CENTER);
                        Portion port = para.getPortions().get(0);
                        port.setFontBold(true);
                        port.setFontColor(java.awt.Color.BLACK);
                        port.setFontHeight((short) 20);
                        port.setText("Name");
                    } else if (para.getText().equals("CH2")) {
                        para.setAlignment(TextAlignment.CENTER);
                        Portion port = para.getPortions().get(0);
                        port.setFontBold(true);
                        port.setFontColor(java.awt.Color.BLACK);
                        port.setFontHeight((short) 20);
                        port.setText("Phone Number");
                    }
                }
            }
        }

        // Find table
        com.aspose.slides.Table table = null;
        for (int i = 0; i < slide2.getShapes().size(); i++) {
            if (slide2.getShapes().get(i) instanceof com.aspose.slides.Table) {
                table = (com.aspose.slides.Table) slide2.getShapes().get(i);
                break;
            }
        }
        if (table != null) {
            // Query Database
            String selectString =
                    "SELECT count(*) as NumberOfRows FROM Employees where City='" +
                    ReportingLocation + "'";
            // Create a new SQL statement object using the Conection Object
            Statement s = con.createStatement();
            // Create a Result Set using the Statement object and the select string defined above.

            ResultSet rs = s.executeQuery(selectString);

            int recordCount = 0;
            while (rs.next()) {
                recordCount = rs.getInt("NumberOfRows");
            }
            rs.close();

            /**/
            selectString =
                    //"SELECT top 7 LastName, FirstName,HomePhone FROM Employees where " +
                    //  LIMIT 0,7 for MySQL
                    "SELECT TOP 7 LastName, FirstName,HomePhone FROM Employees where " +
                    "City='" + ReportingLocation + "' order by LastName";

            // Create a new SQL statement object using the Conection Object
            s = con.createStatement();
            // Create a Result Set using the Statement object and the select string defined above.
            rs = s.executeQuery(selectString);

            // Make table contain correct number of rows
            if (recordCount == 1) {
                table.deleteRow(1);
            } else {
                for (int i = 2; i < recordCount; i++) {
                    table.addRow();
                }
            }
            int count = 0;

            while (rs.next()) {
                TextFrame tfName = table.getCell(0, count).getTextFrame();
                TextFrame tfPhoneNumber = table.getCell(1, count).getTextFrame();
                if (tfName != null) {
                    tfName.getParagraphs().get(0).getPortions().get(0).setText(rs.
                            getString("LastName") + ", " + rs.getString("FirstName"));
                    tfPhoneNumber.getParagraphs().get(0).getPortions().get(0).setText(rs.
                            getString("HomePhone"));
                    // Left justify first column
                    tfName.getParagraphs().get(0).setAlignment(TextAlignment.LEFT);
                    // Center justify second column
                    tfPhoneNumber.getParagraphs().get(0).setAlignment(TextAlignment.
                            CENTER);
                    // Disable default bullets
                    tfName.getParagraphs().get(0).setHasBullet(false);
                    tfPhoneNumber.getParagraphs().get(0).setHasBullet(false);
                    // Set Font Color
                    tfName.getParagraphs().get(0).getPortions().get(0).setFontColor(java.
                            awt.Color.decode("#DC143C"));
                    tfPhoneNumber.getParagraphs().get(0).getPortions().get(0).
                            setFontColor(java.awt.Color.decode("#3CB371"));
                }
                count++;
            }
            rs.close();
        }
        // Add entry effect to the table
        table.getAnimationSettings().setEntryEffect(ShapeEntryEffect.SPIRAL);
        // Add Slide Transition Effect
        slide2.getSlideShowTransition().setEntryEffect(SlideTransitionEffect.CIRCLE_OUT);
        return slide2;
    }

    protected String getYearSQL(int Year) {
        //return "'" + Year + "0101' ";
        return "#" + Year + "-01-01# ";
    }

    protected String getDateSQL(Integer Year, Integer Month, Integer Day, boolean to) {
        java.text.DecimalFormat nft = new java.text.DecimalFormat("00");
        //return "'" + Year.toString() + nft.format(Integer.parseInt(ReportingMonth)) + nft.format(Day) + "'";
        return "#" + Year.toString() 
            + "-" + nft.format(Integer.parseInt(ReportingMonth)) 
            + "-" + nft.format(Day) 
            + "#";
    }

    public Slide Slide3(Slide slide3) throws Exception {
        // Top 5 Employees for the year
        for (int j = 0; j < slide3.getShapes().size(); j++) {
            Placeholder holder = slide3.getPlaceholders().get(j);
            if (holder instanceof TextHolder) {
                Paragraph para = ((TextHolder) holder).getParagraphs().get(0);
                if (para.getText().equals("Employee Directory")) {
                    para.setAlignment(TextAlignment.DEFAULT);
                    para.setHasBullet(true); // -1 is a default value for a bullet
                    Portion port = para.getPortions().get(0);
                    port.setFontColor(java.awt.Color.BLACK);
                    port.setText("Top 5 Employees for " + ReportingYear);
                }
            }
            Shape shape = slide3.getShapes().get(j);
            if (shape.getTextFrame() != null) {
                TextFrame tf = shape.getTextFrame();
                if (tf.getParagraphs().size() != 0) {
                    Paragraph para = tf.getParagraphs().get(0);
                    if (para.getText().equals("Subtitle")) {
                        para.setAlignment(TextAlignment.CENTER);
                        Portion port = para.getPortions().get(0);
                        port.setFontColor(java.awt.Color.BLACK);
                        port.setFontHeight((short) 30);
                        port.setText("Ranked by Order Volume");

                    } else if (para.getText().equals("CH1")) {
                        para.setAlignment(TextAlignment.CENTER);
                        Portion port = para.getPortions().get(0);
                        port.setFontBold(true);
                        port.setFontColor(java.awt.Color.BLACK);
                        port.setFontHeight((short) 20);
                        port.setText("Name");
                    } else if (para.getText().equals("CH2")) {
                        para.setAlignment(TextAlignment.CENTER);
                        Portion port = para.getPortions().get(0);
                        port.setFontBold(true);
                        port.setFontColor(java.awt.Color.BLACK);
                        port.setFontHeight((short) 20);
                        port.setText("Order Volume");
                    }
                }
            }
        }

        // Find table
        com.aspose.slides.Table table = null;

        for (int i = 0; i < slide3.getShapes().size(); i++) {
            if (slide3.getShapes().get(i) instanceof com.aspose.slides.Table) {
                table = (com.aspose.slides.Table) slide3.getShapes().get(i);
                break;
            }
        }
        if (table != null) {
            try {
                // Quary Database
                Integer NextYear = 1 + Integer.parseInt(ReportingYear);
                String selectString =
                        "SELECT TOP 5 LastName, FirstName, count(Orders.OrderID) as numOrders " +
                        "FROM Employees INNER JOIN Orders ON Employees.EmployeeID = Orders.EmployeeID " +
                        "WHERE  Orders.OrderDate >" + getYearSQL(Integer.parseInt(ReportingYear)) +
                        "and Orders.OrderDate <" + getYearSQL(NextYear) +
                        "Group by LastName, FirstName " +
                        "order by count(Orders.OrderID) desc" 
                        // + " limit 0,5"
                        ;

                // Create a new SQL statement object using the Conection Object
                Statement s = con.createStatement();
                // Create a Result Set using the Statement object and the select string defined above.
                ResultSet rs = s.executeQuery(selectString);

                // Make table contain correct number of rows
                for (int i = 2; i < 5; i++) {
                    table.addRow();
                }

                int count = 0;
                while (rs.next()) {
                    TextFrame tfName = table.getCell(0, count).getTextFrame();
                    TextFrame tfPhoneNumber = table.getCell(1, count).getTextFrame();
                    if (tfName != null) {
                        tfName.getParagraphs().get(0).getPortions().get(0).setText(rs.
                                getString("LastName") + ", " + rs.getString("FirstName"));
                        tfPhoneNumber.getParagraphs().get(0).getPortions().get(0).setText(rs.getString("numOrders"));
                        // Left justify first column
                        tfName.getParagraphs().get(0).setAlignment(TextAlignment.LEFT);
                        // Center justify second column
                        tfPhoneNumber.getParagraphs().get(0).setAlignment(TextAlignment.
                                CENTER);
                        // Disable default bullets
                        tfName.getParagraphs().get(0).setHasBullet(false);
                        tfPhoneNumber.getParagraphs().get(0).setHasBullet(false);
                        // Set Font Color
                        tfName.getParagraphs().get(0).getPortions().get(0).setFontColor(java.awt.Color.decode("#DC143C"));
                        tfPhoneNumber.getParagraphs().get(0).getPortions().get(0).
                                setFontColor(java.awt.Color.decode("#3CB371"));
                    }
                    count++;
                }
                rs.close();

                // Add entry effect to the table
                table.getAnimationSettings().setEntryEffect(ShapeEntryEffect.SPIRAL);
            } catch (Exception e) {
                throw e;
            }
        }
        // Add Slide Transition Effect
        slide3.getSlideShowTransition().setEntryEffect(SlideTransitionEffect.WIPE_RIGHT);
        return slide3;
    }

    public Slide Slide4(Slide slide4) throws Exception {
        // Employee of the Year
        try {
            // Quary Database
            String selectString = "SELECT count(*) as NumberOfRows FROM Employees";
            // Create a new SQL statement object using the Conection Object
            Statement s = con.createStatement();
            // Create a Result Set using the Statement object and the select string defined above.
            ResultSet rs = s.executeQuery(selectString);

            int recordCount = 0;
            while (rs.next()) {
                recordCount = rs.getInt("NumberOfRows");
            }
            rs.close();
            // Quary Database
            selectString = "SELECT LastName, FirstName, Title, City FROM Employees";

            // Create a new SQL statement object using the Conection Object
            s = con.createStatement();
            // Create a Result Set using the Statement object and the select string defined above.
            rs = s.executeQuery(selectString);

            String LastName = "", FirstName = "", Title = "", City = "";
            Random objRand = new Random();

            // Get a random employee
            while (City == "") {
                int intRand = (int) objRand.nextInt(recordCount);
                for (int i = 0; i < intRand; i++) {
                    rs.next();
                    LastName = rs.getString("LastName");
                    FirstName = rs.getString("FirstName");
                    Title = rs.getString("Title");
                    City = rs.getString("City");
                }
            }
            rs.close();

            for (int j = 0; j < slide4.getShapes().size(); j++) {
                Shape shape = slide4.getShapes().get(j);
                if (shape.getTextFrame() != null) {
                    TextFrame tf = shape.getTextFrame();
                    if (tf.getParagraphs().size() != 0) {
                        Paragraph para = tf.getParagraphs().get(0);
                        if (para.getText().equals("Name")) {
                            para.setAlignment(TextAlignment.CENTER);
                            Portion port = para.getPortions().get(0);
                            port.setFontBold(true);
                            port.setFontColor(java.awt.Color.BLACK);
                            port.setFontHeight((short) 40);
                            port.setText(FirstName + " " + LastName);

                            // Add Entry Effect for the Shape
                            shape.getAnimationSettings().setEntryEffect(ShapeEntryEffect.FLY_FROM_LEFT);
                        } else if (para.getText().equals("Title")) {
                            para.setAlignment(TextAlignment.CENTER);
                            Portion port = para.getPortions().get(0);
                            port.setFontBold(false);
                            port.setFontColor(java.awt.Color.BLACK);
                            port.setFontHeight((short) 30);
                            port.setText(Title);

                            // Add Entry Effect for the Shape
                            shape.getAnimationSettings().setEntryEffect(ShapeEntryEffect.FLY_FROM_BOTTOM_RIGHT);
                        } else if (para.getText().equals("Location")) {
                            para.setAlignment(TextAlignment.CENTER);
                            Portion port = para.getPortions().get(0);
                            port.setFontBold(false);
                            port.setFontColor(java.awt.Color.BLACK);
                            port.setFontHeight((short) 30);
                            port.setText(City);

                            // Add Entry Effect for the Shape
                            shape.getAnimationSettings().setEntryEffect(ShapeEntryEffect.FLY_FROM_BOTTOM_LEFT);
                        }
                    }
                }
            }
            // Add Slide Transition Effect
            slide4.getSlideShowTransition().setEntryEffect(SlideTransitionEffect.DISSOLVE);
        } catch (Exception e) {
            throw e;
        }
        return slide4;
    }

    public Slide Slide5(Slide slide5) throws Exception {
        // Item of the month

        // Quary Database
        String selectString =
                "SELECT TOP 1 ProductName, count([Order Details].ProductID) as numOrders " +
                "FROM " +
                "Products INNER JOIN (Orders INNER JOIN [Order Details] " +
                "ON Orders.OrderID = [Order Details].OrderID) ON Products.ProductID = [Order Details].ProductID " +
                "WHERE " +
                "Orders.OrderDate >" + 
                    getDateSQL(Integer.parseInt(ReportingYear), 
                        Integer.parseInt(ReportingMonth), 1, false)
                    + " AND Orders.OrderDate<" + 
                    getDateSQL(Integer.parseInt(ReportingYear), 
                        Integer.parseInt(ReportingMonth),
                        daysInMonth[java.lang.Integer.parseInt(ReportingMonth) - 1], true) +
                " and [Order Details].OrderID = Orders.OrderID " +
                "Group by " +
                "ProductName " +
                "order by count([Order Details].ProductID) desc" 
                // +" limit 0,1"
                ;

        // Create a new SQL statement object using the Conection Object
        Statement s = con.createStatement();
        // Create a Result Set using the Statement object and the select string defined above.
        ResultSet rs = s.executeQuery(selectString);

        String ProductName = "", NumberOfOrders = "";

        while (rs.next()) {
            ProductName = rs.getString("ProductName");
            NumberOfOrders = rs.getString("numOrders");
        }
        rs.close();

        for (int j = 0; j < slide5.getShapes().size(); j++) {
            Shape shape = slide5.getShapes().get(j);
            if (shape.getTextFrame() != null) {
                TextFrame tf = shape.getTextFrame();
                if (tf.getParagraphs().size() != 0) {
                    Paragraph para = tf.getParagraphs().get(0);
                    if (para.getText().equals("Subtitle")) {
                        para.setAlignment(TextAlignment.CENTER);
                        Portion port = para.getPortions().get(0);
                        port.setFontBold(true);
                        port.setFontColor(java.awt.Color.BLACK);
                        port.setFontHeight((short) 30);
                        port.setText("Top Selling Item by Volume for " +
                                NameOfMonth[java.lang.Integer.parseInt(ReportingMonth) -
                                1] + " " + ReportingYear);
                    } else if (para.getText().equals("Body1")) {
                        para.setAlignment(TextAlignment.LEFT);
                        Portion port = para.getPortions().get(0);
                        port.setFontBold(false);
                        port.setFontColor(java.awt.Color.BLACK);
                        port.setFontHeight((short) 25);

                        if (ProductName != "") {
                            port.setText("Item Name: " + ProductName);
                        } else {
                            port.setFontColor(java.awt.Color.RED);
                            port.setText("No Sales Reported for this Time Period.");
                            para.setAlignment(TextAlignment.CENTER);
                        }
                        // Add Entry Effect for the Shape
                        shape.getAnimationSettings().setEntryEffect(ShapeEntryEffect.SPLIT_HORIZONTAL_OUT);
                    } else if (para.getText().equals("Body2")) {
                        para.setAlignment(TextAlignment.LEFT);
                        Portion port = para.getPortions().get(0);
                        port.setFontBold(false);
                        port.setFontColor(java.awt.Color.BLACK);
                        port.setFontHeight((short) 25);

                        if (NumberOfOrders != "") {
                            port.setText("Number of Sales for the Month: " + NumberOfOrders);
                        } else {
                            port.setText("");
                        }
                        // Add Entry Effect for the Shape
                        shape.getAnimationSettings().setEntryEffect(ShapeEntryEffect.SPLIT_HORIZONTAL_IN);
                    }
                }
            }
        }
        // Add Slide Transition Effect
        slide5.getSlideShowTransition().setEntryEffect(SlideTransitionEffect.DIAMOND_OUT);
        return slide5;
    }

    public Slide Slide6(Slide slide6, Presentation pres) throws Exception {
        // Item of the Year
        try {
            // Quary Database
            Integer NextYear = 1 + Integer.parseInt(ReportingYear);
            String selectString =
                    "SELECT TOP 1 ProductName, count([Order Details].ProductID) as numOrders " +
                    "FROM " +
                    "Products INNER JOIN (Orders INNER JOIN [Order Details] " +
                    "ON Orders.OrderID = [Order Details].OrderID) ON Products.ProductID = [Order Details].ProductID " +
                    "WHERE " +
                    "Orders.OrderDate >" 
                        + getYearSQL(Integer.parseInt(ReportingYear))
                        + " and Orders.OrderDate < " + getYearSQL(NextYear) +
                    "and [Order Details].OrderID = Orders.OrderID " +
                    "Group by " +
                    "ProductName " +
                    "order by count([Order Details].ProductID) desc" 
                    //+ " limit 0,1"
                    ;

            // Create a new SQL statement object using the Conection Object
            Statement s = con.createStatement();
            // Create a Result Set using the Statement object and the select string defined above.
            ResultSet rs = s.executeQuery(selectString);

            String ProductName = "", NumberOfOrders = "";

            while (rs.next()) {
                ProductName = rs.getString("ProductName");
                NumberOfOrders = rs.getString("numOrders");
            }
            rs.close();

            for (int j = 0; j < slide6.getShapes().size(); j++) {
                Shape shape = slide6.getShapes().get(j);
                if (shape.getTextFrame() != null) {
                    TextFrame tf = shape.getTextFrame();
                    if (tf.getParagraphs().size() != 0) {
                        Paragraph para = tf.getParagraphs().get(0);
                        if (para.getText().equals("Subtitle")) {
                            para.setAlignment(TextAlignment.CENTER);
                            Portion port = para.getPortions().get(0);
                            port.setFontBold(true);
                            port.setFontColor(java.awt.Color.BLACK);
                            port.setFontHeight((short) 30);
                            port.setText("Top Selling Item by Volume for " +
                                    ReportingYear);
                        } else if (para.getText().equals("Body1")) {
                            para.setAlignment(TextAlignment.LEFT);
                            Portion port = para.getPortions().get(0);
                            port.setFontBold(false);
                            port.setFontColor(java.awt.Color.BLACK);
                            port.setFontHeight((short) 25);

                            if (ProductName != "") {
                                port.setText("Item Name: " + ProductName);
                            }

                            // Add Entry Effect for the Shape
                            shape.getAnimationSettings().setEntryEffect(ShapeEntryEffect.SWIVEL);
                        } else if (para.getText().equals("Body2")) {
                            para.setAlignment(TextAlignment.LEFT);
                            Portion port = para.getPortions().get(0);
                            port.setFontBold(false);
                            port.setFontColor(java.awt.Color.BLACK);
                            port.setFontHeight((short) 25);

                            if (NumberOfOrders != "") {
                                port.setText("Number of Sales for the Year: " + NumberOfOrders);
                            }
                            // Add Entry Effect for the Shape
                            shape.getAnimationSettings().setEntryEffect(ShapeEntryEffect.WIPE_UP);
                        }
                    }
                }
            }

            // Add picture of item
            com.aspose.slides.Picture pic1 = null;
            String imgFileName = "";
            if ("Gnocchi di nonna Alice".equals(ProductName)) {
                InputStream is = getFile(request, "/resources/Gnocchi.jpg");
                if (null!=is) {
                    pic1 = new com.aspose.slides.Picture(pres, is);
                    imgFileName = getFileName(request, "/resources/Gnocchi.jpg");
                }else {
                    System.err.println("Could not load /resources/Gnocchi.jpg from " + request);
                }
            } else if ("Konbu".equals(ProductName)) {
                InputStream is = getFile(request, "/resources/konbu.jpg");
                if (null!=is) {
                    pic1 = new com.aspose.slides.Picture(pres, is);
                    imgFileName = getFileName(request, "/resources/konbu.jpg");
                }else {
                    System.err.println("Could not load /resources/konbu.jpg from " + request);
                }
            } else if ("Gorgonzola Telino".equals(ProductName)) {
                InputStream is = getFile(request, "/resources/Gorgonzola.gif");
                if (null!=is) {
                    pic1 = new com.aspose.slides.Picture(pres, is);
                    imgFileName = getFileName(request, "/resources/Gorgonzola.jpg");
                }else {
                    System.err.println("Could not load /resources/Gorgonzola.jpg from " + request);
                }
            }

            if (null!=pic1)
            {
                int picid1 = pres.getPictures().add(pic1);
                RenderedOp img = JAI.create("fileload", imgFileName);
                int pictureWidth = img.getWidth() * 5;
                int pictureHeight = img.getHeight() * 5;
                int slideWidth = slide6.getBackground().getWidth();
                int slideHeight = slide6.getBackground().getHeight();
                int pictureFrameWidth = (slideWidth / 2 - pictureWidth / 2);
                int pictureFrameHeight = (slideHeight / 2 - pictureHeight / 2) + 1000;
                PictureFrame pf = slide6.getShapes().addPictureFrame(picid1, pictureFrameWidth, pictureFrameHeight,
                    pictureWidth, pictureHeight);

                //PictureFrame pf = slide6.getShapes().addPictureFrame(picid1, 1, 1, 1000, 1000);
                pf.getAnimationSettings().setEntryEffect(ShapeEntryEffect.ZOOM_IN);
            }

            // Add Slide Transition Effect
            slide6.getSlideShowTransition().setEntryEffect(SlideTransitionEffect.CIRCLE_OUT);
        } catch (Exception e) {
            throw e;
        }
        return slide6;
    }

    public Slide Slide7(Slide slide7) {
        // Not used in Java Demo
        return slide7;
    }

    public Slide Slide8(Slide slide8, Presentation pres) throws Exception {
        // Company Picnic Promotion
        try {
            slide8.setFollowMasterBackground(false);
            slide8.getBackground().getFillFormat().setType(FillType.PICTURE);

            InputStream is = getFile(request, "/resources/picnic.jpg");
            if (null!=is) {
                com.aspose.slides.Picture pic1 = new com.aspose.slides.Picture(pres, is);
                int picid1 = pres.getPictures().add(pic1);
                slide8.getBackground().getFillFormat().setPictureId(picid1);
            }

            // Set Picnic Date
/*
            String month = "", day = "", year = "";

            if (!PicnicDate.equals("mm/dd/yyyy")) {
                try {
                    String[] pdate = PicnicDate.split("/");
                    if (Integer.parseInt(pdate[0]) < 13 && Integer.parseInt(pdate[0]) > 0) {
                        month = NameOfMonth[Integer.parseInt(pdate[0]) - 1];
                    }
                    if (Integer.parseInt(pdate[1]) < 32 && Integer.parseInt(pdate[1]) > 0) {
                        day = pdate[1];
                    }
                    if (Integer.parseInt(pdate[2]) < 2100 &&
                            Integer.parseInt(pdate[2]) > 1900) {
                        year = pdate[2];
                    }
                } catch (Exception e) {
                    month = day = year = "";
                }
            }
*/
            Calendar calendar = new GregorianCalendar();
            calendar.setTime(getPicknickdate());
            String month = NameOfMonth[calendar.get(Calendar.MONTH)-1];
            String day = new Integer(calendar.get(Calendar.DAY_OF_MONTH)).toString();
            String year = new Integer(calendar.get(Calendar.YEAR)).toString();
            //Date calendar = getPicknickdate();
            //String month = NameOfMonth[calendar.getMonth()-1];
            //String day = new Integer(calendar.getDate()).toString();
            //String year = new Integer(calendar.getYear()).toString();

            String date_text;
            if (month.equals("") || day.equals("") || year.equals("")) {
                date_text = new SimpleDateFormat("MMMM dd, yyyy").format(new Date());
            } else {
                date_text = month + " " + day + ", " + year;
            }
            for (int k = 0; k < slide8.getPlaceholders().size(); k++) {
                Placeholder holder = slide8.getPlaceholders().get(k);
                if (holder instanceof TextHolder) {
                    Paragraph para = ((TextHolder) holder).getParagraphs().get(0);
                    if (para.getText().equals("Company Picnic Announcement")) {
                        Portion port = para.getPortions().get(0);
                        port.setFontColor(java.awt.Color.RED);
                    }
                }
            }

            for (int j = 0; j < slide8.getShapes().size(); j++) {
                Shape shape = slide8.getShapes().get(j);
                if (shape.getTextFrame() != null) {
                    TextFrame tf = shape.getTextFrame();
                    if (tf.getParagraphs().size() != 0) {
                        Paragraph para = tf.getParagraphs().get(0);
                        if (para.getText().equals("Subtitle")) {
                            // Add first paragraph to the shape
                            para.setAlignment(TextAlignment.CENTER);
                            Portion port = para.getPortions().get(0);
                            port.setFontBold(true);
                            port.setFontColor(java.awt.Color.RED);
                            port.setFontHeight((short) 25);
                            port.setText("The Company Picnic will be held ");

                            // Add second paragraph to the shape
                            tf.getParagraphs().add(new Paragraph(tf.getParagraphs().get(0)));
                            Paragraph para2 = tf.getParagraphs().get(1);
                            Portion port2 = para2.getPortions().get(0);
                            port2.setFontBold(true);
                            port2.setFontColor(java.awt.Color.RED);
                            port2.setFontHeight((short) 25);
                            port2.setText(date_text + " at South Lake Shore Park");
                        }
                    }
                }
            }

            // Create 3 Shapes to hold text
            Shape shape1 = slide8.getShapes().addRectangle(400, 1400, 2300, 800);
            shape1.getFillFormat().setType(FillType.TEXTURE);
            shape1.getFillFormat().setTextureStyle(TextureStyle.PURPLE_MESH);

            Shape shape2 = slide8.getShapes().addRectangle(3100, 2200, 2300, 800);
            shape2.getFillFormat().setType(FillType.GRADIENT);
            shape2.getFillFormat().setGradientColorType(GradientColorType.TWO_COLORS);
            shape2.getFillFormat().setGradientFillAngle(40);
            shape2.getFillFormat().setForeColor(java.awt.Color.decode("#b0c4de"));
            shape2.getFillFormat().setBackColor(java.awt.Color.decode("#90ee90"));

            Shape shape3 = slide8.getShapes().addRectangle(400, 3000, 2300, 800);
            shape3.getFillFormat().setType(FillType.SOLID);
            shape3.getFillFormat().setForeColor(java.awt.Color.yellow);

            // Add a picture of a hotdog
            InputStream isHD = getFile(request, "/resources/hotdog.gif");
            String fileHD = getFileName(request, "/resources/hotdog.gif");
            if (null!=isHD) {
                Picture pic1HD = new com.aspose.slides.Picture(pres, isHD);
                int picid1HD = pres.getPictures().add(pic1HD);
                RenderedOp img2 = JAI.create("fileload", fileHD);
                int pictureWidth = img2.getWidth() * 12;
                int pictureHeight = img2.getHeight() * 12;
                int slideWidth = slide8.getBackground().getWidth();
                int slideHeight = slide8.getBackground().getHeight();
                PictureFrame pf1 = slide8.getShapes().addPictureFrame(picid1HD, 3400, 3200, pictureWidth, pictureHeight);
                pf1.getAnimationSettings().setEntryEffect(ShapeEntryEffect.SPIRAL);
                pf1.getAnimationSettings().setAnimationOrder(5);
            }

            shape1.addTextFrame("Shape1");

            // Add text to the shapes
            if (shape1.getTextFrame() != null) {
                TextFrame tf = shape1.getTextFrame();
                Paragraph para = tf.getParagraphs().get(0);
                para.setAlignment(TextAlignment.CENTER);
                Portion port = para.getPortions().get(0);
                port.setFontBold(false);
                port.setFontColor(java.awt.Color.green);
                port.setFontHeight((short) 20);
                port.setText("Fun for the Whole Family!");
            }

            shape2.addTextFrame("Shape2");

            if (shape2.getTextFrame() != null) {
                TextFrame tf = shape2.getTextFrame();
                Paragraph para = tf.getParagraphs().get(0);
                para.setAlignment(TextAlignment.CENTER);
                Portion port = para.getPortions().get(0);
                port.setFontBold(false);
                port.setFontColor(java.awt.Color.decode("#1E90FF"));
                port.setFontHeight((short) 20);
                port.setFontShadow(true);
                port.setText("Live Entertainment!");
            }

            shape3.addTextFrame("Shape3");

            if (shape3.getTextFrame() != null) {
                TextFrame tf = shape3.getTextFrame();
                Paragraph para = tf.getParagraphs().get(0);
                para.setAlignment(TextAlignment.CENTER);
                Portion port = para.getPortions().get(0);
                port.setFontBold(false);
                port.setFontColor(java.awt.Color.decode("#800080"));
                port.setFontHeight((short) 20);
                port.setFontShadow(true);
                port.setText("Catered");

                // Add second paragraph to the shape
                tf.getParagraphs().add(new Paragraph(tf.getParagraphs().get(0)));
                Paragraph para2 = tf.getParagraphs().get(1);
                port = para2.getPortions().get(0);
                port.setFontBold(false);
                port.setFontColor(java.awt.Color.decode("#800080"));
                port.setFontHeight((short) 20);
                port.setFontShadow(true);
                port.setText("by");

                // Add third paragraph to the shape
                tf.getParagraphs().add(new Paragraph(tf.getParagraphs().get(0)));
                Paragraph para3 = tf.getParagraphs().get(2);
                port = para3.getPortions().get(0);
                port.setFontBold(false);
                port.setFontColor(java.awt.Color.decode("#800080"));
                port.setFontHeight((short) 20);
                port.setFontShadow(true);
                port.setText("Ed's Catfish Saloon!");
            }

            // Set Entry Effects
            slide8.getBackground().getAnimationSettings().setEntryEffect(ShapeEntryEffect.STRETCH_ACROSS);
            slide8.getBackground().getAnimationSettings().setAnimationOrder(1);
            shape1.getAnimationSettings().setEntryEffect(ShapeEntryEffect.SWIVEL);
            shape1.getAnimationSettings().setAnimationOrder(2);
            shape2.getAnimationSettings().setEntryEffect(ShapeEntryEffect.WEDGE);
            shape2.getAnimationSettings().setAnimationOrder(3);
            shape3.getAnimationSettings().setEntryEffect(ShapeEntryEffect.DISSOLVE);
            shape3.getAnimationSettings().setAnimationOrder(4);
            // Add Slide Transition Effect
            slide8.getSlideShowTransition().setEntryEffect(SlideTransitionEffect.WEDGE);
        } catch (Exception e) {
            throw e;
        }
        return slide8;
    }

    public Slide Slide9(Slide slide9) {
        // Closeing Slide
        // Clone of first slide
        return slide9;
    }

    /**
     *
     * Initializes license (if demo license is available).
     * you may insert your licensing code here that would use obj's
     * setLicense based on InputStream rather than passing it on
     * to 3rd-party class.
     *
     */
    public static void initLicense(Object obj) {
        try {

            Class myclass = Class.forName("com.aspose.demos.Common");
            if (null==myclass) {
                System.out.println("initLicense not found");
                return ;
            }

            //Use reflection to list methods and invoke them
            Method[] methods = myclass.getMethods();
            Object object = myclass.newInstance();

            Class partypes[] = new Class[1];
            partypes[0] = Object.class;
           
            Method meth = myclass.getMethod("initLicense", partypes);
            if (null!=meth) {

                    System.out.println("Calling " + meth.getName());
                    Object arglist[] = new Object[1];
                    arglist[0] = obj;

                    meth.invoke(object, arglist);
            }
        } catch (ClassNotFoundException cnfe) {
            // Ignore
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}

JAVA

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144

package com.aspose.slides.demos.jsf;

import java.io.Serializable;

import java.io.*;
import java.util.*;
import java.net.URL;

import javax.servlet.*;
import javax.servlet.http.*;

import javax.faces.context.FacesContext;

///////////////////////
import java.text.SimpleDateFormat;
import com.icesoft.faces.context.ByteArrayResource;
import com.icesoft.faces.context.Resource;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Date;
import java.util.Locale;

import java.lang.reflection.*;

public abstract class BaseDemo
{
    protected FacesContext context;
    protected HttpServletRequest request;
    protected HttpServletResponse response;

    // Default Constructor
    public BaseDemo() {
    }
   
    public abstract Boolean execute();

    protected String getFileName(HttpServletRequest request, String absoluteName) 
        throws java.io.FileNotFoundException
    {
        URL url = getClass().getClassLoader().getResource(absoluteName);
        if (null==url && null!=request)
        {
            String path = 
                request.getRealPath(absoluteName).replace("\\", "/");

            System.err.println("Failed to load " + absoluteName);
            System.err.println("Loading file from " + path);

            return path;
        }

        String path = new File(url.getPath()).getAbsolutePath();
        //return url.toString();
        return path;
    }

    protected InputStream getFile(HttpServletRequest request, String absoluteName) 
        throws java.io.FileNotFoundException
    {
        InputStream is = getClass().getClassLoader().getResourceAsStream(absoluteName);
        if (null==is && null!=request)
        {
            String path = 
                request.getRealPath(absoluteName).replace("\\", "/");

            //System.err.println("Failed to load " + absoluteName);
            //System.err.println("Loading file from " + path);
            is = new FileInputStream(path);

            if (null==is) {
                System.err.println("getFile NULL: " + path);
            }
        }

        return is;
    }

    public String generate() {

        context = FacesContext.getCurrentInstance();
        request = (HttpServletRequest) context.getExternalContext().getRequest();
        response = (HttpServletResponse) context.getExternalContext().getResponse();

        try
        {
            if (execute())
            {
                // we should NOT use it for ICEFaces
                //context.responseComplete();
            }
        }catch(Exception ex)
        {
            ex.printStackTrace();
        }

        return "stay";
    }

    //////////////////////////////////////////////////////////
    protected final String FILE_NAME = "result.ppt";

    public Resource getGeneratedfile() {
        byte[] res = getResult();
        if (null==res || res.length<1) {
            return null;
        }
        return new ByteArrayResource(res);
    }

    private String fileName = FILE_NAME;
    public String getFilename() {
        return fileName;
    }

    private String respType = "application/powerpoint";
    public String getResptype() {
        return respType;
    }
    public void setResptype(String v) {
        respType = v;
    }

    public void setFilename(String v) {

        SimpleDateFormat formatter = new SimpleDateFormat ("yyyy-MMM-dd_hh_mm_ss-", Locale.US);
        String curDate = formatter.format(new Date());

        this.fileName = curDate + v;
    }

    public  byte[] getResult()
    {
        return resp;
    }

    protected void setResponse(String fName, ByteArrayOutputStream out) throws IOException {
        setFilename(fName);
        resp = out.toByteArray();
        out.close();
        // outputStream.write(this.response);
    }
    protected byte[] resp;
}

XHTML

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ice="http://www.icesoft.com/icefaces/component"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:c="http://java.sun.com/jstl/core">

<ui:composition template="/WEB-INF/includes/templates/page-template.xhtml">
                        
    <ui:define name="pageTitle">
        Aspose.Slides Demos
    </ui:define>

    <ui:define name="page-content">
        <ui:decorate template="/WEB-INF/includes/templates/tabbed_container.xhtml">
            <ui:define name="example">

            <div class="componentDescriptionTxt">
                <b>Important:</b> To produce PowerPoint presentations and PDF documents, the machine to run Aspose.Slides
                and Aspose.PDF doesn't need to have Microsoft PowerPoint or Adobe Acrobat installed. However, to view the
                contents of PowerPoint presentations and PDF documents produced by demos, the machine to view them does
                need a Microsoft PowerPoint or Adobe Acrobat Reader.
                <p class="componentDescriptionTxt">
                    <b>Northwind Demo</b><br/>Generates a PPT or PDF file by utilizing user input and the Northwind database
                </p>
           </div>

        <div class="componentDescriptionTxt">
            <table class="genericTable" cellspacing="0" cellpadding="2">
            <tbody>

            <tr><td><b>Presenter Name:</b></td>
            <td>
                <h:message for="presenter" />
                <h:inputText id="presenter" value="#{northwind.presenter}" /><br/>
            </td>
            </tr>
        
            <tr><td><b>Reporting Location:</b></td>
            <td>
                <h:message for="location" />
                <h:selectOneMenu 
                    id="location" 
                    title="Location"
                    value="#{northwind.employeeloc}"
                    style="width:100%"
                    >
                    <f:selectItem itemValue="Kirkland" itemLabel="Kirkland" />
                    <f:selectItem itemValue="London" itemLabel="London" />
                    <f:selectItem itemValue="Redmond" itemLabel="Redmond" />
                    <f:selectItem itemValue="Seattle" itemLabel="Seattle" />
                    <f:selectItem itemValue="Tacoma" itemLabel="Tacoma" />
                </h:selectOneMenu >
            </td></tr>

            <tr><td><b>Reporting Year:</b>
            </td><td>
                <h:message for="rptyear" />
                <h:selectOneMenu 
                    id="rptyear" 
                    value="#{northwind.reportingyear}"
                    style="width:100%"
                    >
                    <f:selectItem itemValue="1996" itemLabel="1996" />
                    <f:selectItem itemValue="1997" itemLabel="1997" />
                    <f:selectItem itemValue="1998" itemLabel="1998" />
                </h:selectOneMenu>
            </td></tr>

            <tr><td><b>Reporting Month:</b>
            </td><td>
                <h:message for="rptmonth" />
                <h:selectOneMenu 
                    id="rptmonth" 
                    value="#{northwind.reportingmonth}"
                    style="width:100%"
                    >
                    <f:selectItem itemValue="1" itemLabel="January" />
                    <f:selectItem itemValue="2" itemLabel="February" />
                    <f:selectItem itemValue="3" itemLabel="March" />
                    <f:selectItem itemValue="4" itemLabel="April" />
                    <f:selectItem itemValue="5" itemLabel="May" />
                    <f:selectItem itemValue="6" itemLabel="June" />
                    <f:selectItem itemValue="7" itemLabel="July" />
                    <f:selectItem itemValue="8" itemLabel="August" />
                    <f:selectItem itemValue="9" itemLabel="September" />
                    <f:selectItem itemValue="10" itemLabel="October" />
                    <f:selectItem itemValue="11" itemLabel="November" />
                    <f:selectItem itemValue="12" itemLabel="December" />
                </h:selectOneMenu>
            </td></tr>
            
            <tr><td><b>Company Website:</b>
            </td><td>
                <h:message for="companysite" />
                <h:inputText id="companysite" value="#{northwind.companyweb}" />
            </td></tr>

            <tr><td><b>Company Name:</b>
            </td><td>
                <h:message for="companyname" />
                <h:inputText id="companyname" value="#{northwind.companyname}" />
            </td></tr>

            <tr><td><b>Company Address:</b>
            </td><td>
                <h:message for="companyadr" />
                <h:inputText id="companyadr" value="#{northwind.companyaddr}" />
            </td></tr>

            <tr><td><b>Company City:</b></td>
            <td>
                <h:message for="companycity" />
                <h:inputText id="companycity" value="#{northwind.companycity}" />
            </td>

            <td>State:</td>
            <td>
                <h:message for="companystate" />
                <h:inputText id="companystate" value="#{northwind.companystate}" />
            </td>
            
            <td>Zip:</td>
            <td>
                <h:message for="companyzip" />
                <h:inputText id="companyzip" value="#{northwind.companyzip}" />
            </td></tr>
            <tr>
            <td><b>Company Picnic Date:</b></td>
            <td>
                <h:message for="picknickdate" />
                <h:inputText id="picknickdate" value="#{northwind.picknickdate}" >
                    <f:convertDateTime pattern="MM/dd/yyyy"/>
                </h:inputText>
            </td>
            </tr>

            </tbody></table>
        </div>
            <h:commandButton id="generate" 
                action="#{northwind.generate}"
                value="Generate Presentation"> 
            </h:commandButton>
            <h:message for="generate" />

            <ice:outputResource id="outResource"
                mimeType="application/powerpoint"
                resource="#{northwind.generatedfile}"
                fileName="#{northwind.filename}"
                shared="false" />

            </ui:define>
        </ui:decorate>
    </ui:define>
        </ui:composition>
</html>