2013年9月30日 星期一

ubuntu-fixed-ip linux-ip linux ip

ubuntu - ip setting
ubuntu-tcp-ip
ubundu tcpip
inf : http://www.cyberciti.biz/tips/howto-ubuntu-linux-convert-dhcp-network-configuration-to-static-ip-configuration.html


vi /etc/network/interfaces

iface eth0 inet dhcp
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.254




$ sudo vi /etc/resolv.conf

search myisp.com
nameserver 192.168.1.254
nameserver 202.54.1.20
nameserver 202.54.1.30


$ host cyberciti.biz

java-read-one-record mysql

java-read-one-record mysql


ResultSet rs = null;
Connection con = null;
Statement stmt = null;
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost/hr?useUnicode=true&characterEncoding=UTF8","root", "root");
stmt = con.createStatement();
String sqlString=" select mpfceiling, mpffloor, mpfpercent from companyProfile;";
rs = stmt.executeQuery(sqlString);
int mMPFCeiling=0;
int mMPFFloor=0;
int mMPFPercent=0;
while (rs.next()){
mMPFCeiling=rs.getInt(1);
mMPFFloor=rs.getInt(2);
mMPFPercent=rs.getInt(3);
}

2013年9月29日 星期日

MPF

供款

僱員及僱主*


受強積金制度涵蓋的僱員和僱主均須定期向強積金計劃作出供款,雙方的供款額均為僱員有關入息的5%,並受限於最低及最高有關入息水平。就月薪僱員而言,最低及最高有關入息水平分別為$6,500及$25,000。
每月有關入息強制性供款
僱主部分僱員部分
低於$6,500有關入息 x 5%無須供款
$6,500至$25,000有關入息 x 5%有關入息 x 5%
高於$25,000$1,250$1,250

目前的最低有關入息水平為每月$6,500,適用於2011年11月1日或之後開始的供款期,而目前的最高有關入息水平則為每月$25,000,適用於2012年6月1日或之後開始的供款期。僱員及僱主如需查詢之前的最低及最高有關入息水平,
以及需繳付的強制性供款款額, 可聯絡受託人或積金局索取資料詳情。

「有關入息」是指僱主以金錢形式已支付或須支付予僱員的任何工資、薪金、假期津貼、費用、佣金、花紅、獎金、合約酬金、(香港不包括《僱傭條例》賞錢或津貼(包括房屋津貼或其他房屋利益),法例第57章)下的遣散費或長期服務金。

僱員和僱主均可選擇在強制性供款以外,作出額外的自願性供款。

自僱人士*


受強積金制度涵蓋的自僱人士須定期向強積金計劃作出供款,供款額為其有關入息的5%,並受限於最低及最高有關入息水平。自僱人士可選擇按月或按年作出強制性供款,其最低及最高有關入息水平分別為每月$6,500(或每年$78,000)及每月$25,000(或每年$300,000)。
有關入息強制性供款
低於每月$6,500
(或每年$78,000)
無須供款
每月$6,500至$25,000
(或每年$78,000至$300,000)
有關入息x 5%
高於每月$25,000
(或每年$300,000)
每月$1,250 (或每年$15,000)

目前的最低有關入息水平為每月$6,500(或每年$78,000),適用於2011年11月1日或之後開始的供款期,而目前的最高有關入息水平則為每月$25,000(或每年$300,000),適用於2012年6月1日或之後開始的供款期。自僱人士如需查詢之前的最低及最高有關入息水平,以及需繳付的強制性供款款額,可聯絡受託人或積金局索取資料詳情。

就自僱人士而言的「有關入息」的定義,請參閱以下的「自僱人士須知」。

自僱人士可選擇在強制性供款以外,作出額外的自願性供款。

*註:立法會已於2013年7月17日通過修訂最低有關入息水平及最高有關入息水平。最低有關入息水平已由每月$6,500提升至$7,100(或由每年$78,000提升至$85,200)(新水平適用於2013年11月1日或其後開始的供款期);最高有關入息水平則由每月$25,000提升至$30,000(或由每年$300,000提升至$360,000)(新水平適用於2014年6月1日或其後開始的供款期)。就此,最高的強制性供款額亦由每月$1,250提升至$1,500(或由每年$15,000提升至$18,000)。

僱主須知

計算、扣除及作出供款

僱主須就每段供款期(通常是指工資期)計算僱員的有關入息和強制性供款款額,並從僱員的入息中扣除該款額作為僱員的強制性供款,以及撥出自己的資金作為僱主供款。僱主須於供款日或之前向強積金受託人繳付整筆強制性供款。

供款日

僱主須於供款日或之前,繳付上一個供款期的強制性供款。一般而言,按月支薪的一般僱員的供款日為每月的第10日。如供款日是星期六、公眾假日、烈風警告日或黑色暴雨警告日,則供款日是指該日之後第一個並非星期六、公眾假日、烈風警告日或黑色暴雨警告日的任何日子。

從事建造業或飲食業的僱主如已安排臨時僱員參加行業計劃,可選擇在緊接相關發薪日的下一個工作日(即並非星期六、公眾假日、烈風警告日或黑色暴雨警告日的日子),或每個供款期結束後的10日內作出強制性供款。

免供款期

就一般僱員而言,僱主須從僱用期首日開始作出僱主部分的強制性供款,但僱員則享有免供款期,無須為僱用期首30日作出僱員部分的強制性供款,亦無須:
(i) 為在緊接該30日免供款期後的首個不完整工資期作出供款(如僱員的工資期是一個月或短於一個月);或
(ii) 為受僱第30日所在的公曆月作出供款(如僱員的工資期長於一個月)。

就臨時僱員而言,僱主及僱員的強制性供款均須從僱用期首日開始繳付。在此情況下,僱主及僱員均沒有免供款期。

付款結算書及供款紀錄

僱主每次向強積金受託人支付供款時,均須向受託人提供一份付款結算書,列明每名僱員的有關入息,以及為每名僱員支付的僱主及僱員部分的供款款額。

僱主亦須在作出強制性供款後的七個工作日內,向每名僱員提供一份每月供款紀錄,當中須按規定列載多項資料,包括僱員的有關入息,以及僱主及僱員部分的供款款額。

參加行業計劃的僱主,如選擇在臨時僱員的相關發薪日後的下一個工作日(即並非星期六、公眾假日、烈風警告日或黑色暴雨警告日的任何日子)為該僱員作出強制性供款,便無須遵守此項提供付款結算書及供款紀錄的規定。請按此參閱行業計劃的詳情。

終止僱用

屬強積金計劃成員的一般僱員離職時,其僱主須安排在下一個供款日或之前,為該名離職僱員支付最後一期的強制性供款,並透過下一份付款結算書或另外發出書面通知,把僱員離職日期通知強積金受託人。

屬僱主營辦計劃或集成信託計劃成員的臨時僱員離職時,其僱主須安排在下一個供款日或之前,支付最後一期的強制性供款。僱主亦須在僱員離職後的30日內,透過下一份付款結算書或另外發出書面通知,把僱員的離職日期通知強積金受託人。

屬行業計劃成員的臨時僱員離職時,其僱主須安排在下一個供款日或之前,支付最後一期的強制性供款,但無須將僱員的離職日期通知強積金受託人。

僱員須知

成員證明書

當僱主安排僱員參加強積金計劃後,強積金受託人會在僱員參加計劃後60日內,向僱員發出成員證明書。

投資選擇

僱員有權從僱主所選的強積金計劃所提供的成分基金(即投資選擇)中作出選擇,以就僱員及僱主支付的強制性供款進行投資。

供款紀錄

僱主須在作出強制性供款後的七個工作日內,向僱員提供一份每月供款紀錄,當中須按規定列載多項資料,包括僱員的有關入息,以及僱主及僱員部分的供款款額。

周年權益報表

強積金計劃的受託人須在計劃每個財政期終結後三個月內,向每名計劃成員提供一份周年權益報表,當中須按規定列載多項資料,包括該年度支付的供款總額,以及於該年度開始及終結時的累算權益價值。

自僱人士須知

自僱人士可選擇按月或按年作出強制性供款,供款額為有關入息的5%,並受限於最低及最高有關入息水平。
自僱人士可採用下列其中一種方法確定自己的有關入息:
  • 參考稅務局發出的最近期評稅通知書上列明的「應評稅利潤」,作為有關入息;
  • 參考《稅務條例》(香港法例第112章)第28條所界定的基本免稅額,作為有關入息;
  • 向強積金受託人作出入息聲明;或
  • 直接繳付每月或每年的最高強制性供款款額。

如自僱人士的業務錄得虧損,有關的自僱人士可向強積金受託人提交一份結算表,展示虧損的數額及計算方法,並中止作出強制性供款,直至其有關入息再次達到最低有關入息水平為止。

強積金計劃的受託人須在計劃的每個財政期終結後三個月內,向自僱人士提供一份周年權益報表,當中須按規定列載多項資料,包括該年度所支付的供款總額,以及於該年度開始及終結時的累算權益價值。

asp-while read-table

<table cellspacing = "0" cellpadding = "3" class = "horiz">
    <tr>
        <th width = "20%">Acronym</th>
        <th width = "50%">Meaning</th>
        <th width = "30%">Source</th>
    </tr>
    <%
    mainletter = ""

    While (NOT con.EOF)
        letter = Left(con("acronym")
        If mainletter <> letter Then
            %>
            <tr>
                <td colspan = "3" ><h2><a name="<%=letter%>"><%=letter%></a></h2></td>
            </tr>
            <%
            mainletter = Left(con("acronym"),1)
        End If
        <tr>
            <td><%=con("acronym")%></td>
            <td><%=con("meaning")%></td>
            <td><%=con("source")%></td>
        </tr>
        <%
        con.MoveNext()
    Wend
    %>
</table>

asp-while asp-loop


inf: http://www.w3schools.com/asp/asp_ajax_database.asp

<%
response.expires=-1
sql="SELECT * FROM CUSTOMERS WHERE CUSTOMERID="
sql=sql & "'" & request.querystring("q") & "'"

set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open(Server.Mappath("/db/northwind.mdb"))
set rs=Server.CreateObject("ADODB.recordset")
rs.Open sql,conn

response.write("<table>")
do until rs.EOF
  for each x in rs.Fields
    response.write("<tr><td><b>" & x.name & "</b></td>")
    response.write("<td>" & x.value & "</td></tr>")
  next
  rs.MoveNext
loop
response.write("</table>")
%>

javascript-for



var str = "How are you doing today?";
var res = str.split(" ");

for (var i=0;i<cars.length;i++)

document.write(cars[i] + "<br>");
}

2013年9月27日 星期五

javascript-source and target

javascript source and target


http://friedcell.si/js/SortedTable/examples.html



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<link href="css/payroll.css" rel="stylesheet" type="text/css" />

<title>SortedTable example</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="css/sortTable.css" type="text/css" />
<style type="text/css">
body {
background: url(images/bg.png) repeat;
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
font-weight:200;
text-align: left;
text-decoration: none;
}
</style>
<script type="text/javascript" src="js/sortTableEvent.js"></script>
<script type="text/javascript" src="js/sortTable.js"></script>
<script type="text/javascript">//<![CDATA[
var sourceTable, destTable,s2,d2;
onload = function() {
sourceTable = new SortedTable('s');
destTable = new SortedTable('d');
sourceTable2 = new SortedTable('s2');
destTable2 = new SortedTable('d2')
mySorted = new SortedTable();
mySorted.colorize = function() {
for (var i=0;i<this.elements.length;i++) {
if (i%2){
this.changeClass(this.elements[i],'even','odd');
} else {
this.changeClass(this.elements[i],'odd','even');
}
}
}
mySorted.onsort = mySorted.colorize;
mySorted.onmove = mySorted.colorize;
mySorted.colorize();
secondTable = SortedTable.getSortedTable(document.getElementById('id'));
secondTable.allowDeselect = false;
//////////////////////////////////////////////////


}
function moveRows(s,d) {
var a = new Array();
for (var o in s.selectedElements) {
a.push(s.selectedElements[o]);
}
for (var o in a) {
var elm = a[o];
var tds = elm.getElementsByTagName('td');
for (var i in tds) {
if (tds[i].headers) tds[i].headers = d.table.id+''+tds[i].headers.substr(d.table.id.length);
}
d.body.appendChild(a[o]);
d.deselect(a[o]);
d.init(d.table);
d.sort();
s.deselect(a[o]);
s.init(s.table);
d2.body.appendChild(a[o]);
d2.deselect(a[o]);
d2.init(d.table);
d2.sort();
s2.deselect(a[o]);
s2.init(s.table);
}
}
//]]></script>
<style type="text/css">
input [type="button"] {font-size:20px;}

/* document styles */
.disclaimer {border-top:1px solid #ccc;color:#879AB7;padding-top:.5em;font-size:.9em;}
dl {margin:0 1em;padding:0;}
dl, form {float:left;}
li {padding:.1em 0;}
hr {clear:both;width:100%;background:#fff;height:0;border:0;border-bottom:1px solid #fff;margin:0 0 1em;padding:0;}

/* table styles */
table {border:0;padding:0;margin:0 0 1em;border-left:1px solid #336;border-top:1px solid #336;float:left;clear:left;}
tr {border:0;padding:0;margin:0;}
td, th {border:0;padding:2px 6px;margin:0;border-right:1px solid #336;border-bottom:1px solid #336;background-color:#EAEEF3;}
td[axis='number'], td[axis='date'] {text-align:right;}
th {white-space:no-wrap;background-color:#B4C4D1;padding:2px 20px;}
tfoot td {border-top:1px solid #003;}
thead th {border-bottom:2px solid #003;}
.odd td {background-color:#E8ECF1;}
.even td {background-color:#DDE5EB;}
.hover td {background-color:#A5B3C9;}
.sortedminus {background-color:#ecc;}
.sortedplus {background-color:#cec;}
.selrow td {background-color:#879AB7;}

/* source-dest example styles */
#s {float:left;}
#d {float:left;clear:none;}
#s2{float:left;}
#d2 {float:left;clear:none;}
form#tabletool {margin:0;padding:0.5em;}
form#tabletool fieldset {width:8em;text-align:center;}
form#tabletool legend {margin:0 auto;}
form#tabletool input {margin:0.5em;}
</style>
</head>
<body>
<div style="height:20px; color:white; background-color:rgb(67,120,182); border: 1px white solid; margin-bottom:0;">
<span>Access Control</span>

<INPUT style="float:right;" Type="button" VALUE="X" onClick="history.go(-1);return true;">
</div>

<input type="Button" value="Save" class="saveButton" onclick="alert('saved')"></input>

<div style="margin-left:150px;">
<div class="content" style="font-size:20px;">
<span>Administrator</span></div>
<div class="content" style="font-size:17x; height:200px; width:78%; border:1px solid black;">
<table class="sorted" id="s" cellspacing="0" cellpadding="0">
<thead>
<tr>
<th id="sid"><span>ID</span></th>
<th id="sname"><span>Name</span></th>
<th id="sbirth"><span>Department</span></th>
</tr>
</thead>
<tbody>
<tr>
<td axis="number" headers="sid">1</td>
<td axis="string" headers="sname">John</td>
<td axis="date" headers="sbirth" title="IT">IT</td>
</tr>
<tr>
<td axis="number" headers="sid">2</td>
<td axis="string" headers="sname">David</td>
<td axis="date" headers="sbirth" title="AC">AC</td>
</tr>
<tr>
<td axis="number" headers="sid">3</td>
<td axis="string" headers="sname">Peter</td>
<td axis="date" headers="sbirth" title="Personnel">Personnel</td>
</tr>
</tbody>
</table>
<form id="tabletool" action="#" method="get">
<fieldset>
<legend>Move rows</legend>
<input type="button" value=" &laquo; " onclick="moveRows(destTable,sourceTable)" />
<input type="button" value=" &raquo; " onclick="moveRows(sourceTable,destTable)" />
</fieldset>
</form>
<table class="sorted" id="d" cellspacing="0" cellpadding="0" style="margin-right:0px">
<thead>
<tr>
<th id="did"><span>ID</span></th>
<th id="dname"><span>Name</span></th>
<th id="dbirth"><span>Administrator</span></th>
</tr>
</thead>
<tbody>
<tr>
<td axis="number" headers="did">4</td>
<td axis="string" headers="dname">title 2</td>
<td axis="date" headers="dbirth" title="Sales">Sales</td>
</tr>
</tbody>
</table>
</div>

<!--


group 2




---------------------------------------------------------------------------------------------  -->
<div class="content" style="clear:both;font-size:20px;">
<br><br>
<span>Manager </span></div>
<div class="content" style="font-size:17px; height:200px; width:78%; border:1px solid black;">
<table class="sorted" id="s2" cellspacing="0" cellpadding="0">
<thead>
<tr>
<th id="sid"><span>ID</span></th>
<th id="sname"><span>Name</span></th>
<th id="sbirth"><span>Department</span></th>
</tr>
</thead>
<tbody>
<tr>
<td axis="number" headers="sid">1</td>
<td axis="string" headers="sname">John</td>
<td axis="date" headers="sbirth" title="IT">IT</td>
</tr>
<tr>
<td axis="number" headers="sid">2</td>
<td axis="string" headers="sname">David</td>
<td axis="date" headers="sbirth" title="AC">AC</td>
</tr>
<tr>
<td axis="number" headers="sid">3</td>
<td axis="string" headers="sname">Peter</td>
<td axis="date" headers="sbirth" title="Personnel">Personnel</td>
</tr>
</tbody>
</table>


<form id="tabletool" action="#" method="get">
<fieldset>
<legend>Move rows</legend>
<input type="button" value=" &laquo; " onclick="moveRows(destTable2,sourceTable2)" />
<input type="button" value=" &raquo; " onclick="moveRows(sourceTable2,destTable2)" />
</fieldset>
</form>
<table class="sorted" id="d2" cellspacing="0" cellpadding="0">
<thead>
<tr>
<th id="did"><span>ID</span></th>
<th id="dname"><span>Name</span></th>
<th id="dbirth"><span>Manager</span></th>
</tr>
</thead>
<tbody>
<tr>
<td axis="number" headers="did">4</td>
<td axis="string" headers="dname">title 2</td>
<td axis="date" headers="dbirth" title="Sales">Sales</td>
</tr>
</tbody>
</table>
</div>
</div>


</body>
</html>

java-hex java-binary



<int to Binary / Hex / Octal>
public class DataConversion{
  public static void main(String[] args) {
  System.out.println("Data types conversion example!");
  int in = 50;
  System.out.println("Integer: " + in);
  //integer to binary
  String by = Integer.toBinaryString(in);
  System.out.println("Byte: " + by);
  //integer to hexadecimal
  String hex = Integer.toHexString(in);
  System.out.println("Hexa decimal: " + hex);
  //integer to octal
  String oct = Integer.toOctalString(in);
  System.out.println("Octal: " + oct);
  }
}

java-collection java-hashset hash memory

<collection>

Collection collection   = new HashSet();
boolean containsElement = collection.contains("an element");

Collection elements     = new HashSet();
boolean containsAll     = collection.containsAll(elements);


Collection colA = [A,B,C]
Collection colB = [1,2,3]

Collection target = [];

target.addAll(colA);     //target now contains [A,B,C]
target.addAll(colB);     //target now contains [A,B,C,1,2,3]

target.retainAll(colB);  //target now contains [1,2,3]

target.removeAll(colA);  //nothing happens - already removed
target.removeAll(colB);  //target is now empty.

java-notes

Java
when : public class, it need to save as the file name as the class name.

javac -encoding UTF8 interfaceDemo.java
java 0Dfile.encoding=UTF8 interfaceDemo

/home/edward/workspace/FileIO2Demo/src java FileIO2Demo ./binary/MC01_All_20121011 test


<method notes>
1. before the method {} define variable should static  before the method define and need not in main define

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        new Main().convertByteArrayToString();
    }



problem :
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
solution :
export CLASSPATH=/usr/local/mysql-connector-java-5.1.23/mysql-connector-SPATH5.1.23-bin.jar:$CLASS

java-ascii

System.out.println((char)65);  ## foxpro asc(65)
int i = 65;
char c = (char)i;

char c = 'A';
int i = (int)c;

java byte2string



    public void convertByteArrayToString() {
       
        byte[] byteArray = new byte[] {87, 79, 87, 46, 46, 46};
       
        String value = new String(byteArray);
       
        System.out.println(value);
    }
   

java-file file-delete


java-file-delete



< File >

try {}
catch (FileNotFoundException fnfex) {System.out.println("FileNotFoundException Err:"+ fnfex.getMessage());}
catch (IOException ioex) {System.out.println("IOException Err:" + ioex.getMessage());}

<File.Delete>
File f = new File(fileName);
boolean success = f.delete();
try {}
catch (FileNotFoundException fnfex) {System.out.println("FileNotFoundException Err:"+ fnfex.getMessage());}
catch (IOException ioex) {System.out.println("IOException Err:" + ioex.getMessage());}

java-wait java-sleep

<wait>
try{Thread.sleep(1000);} catch (InterruptedException e) {}

java-main

 public static void main(String[] args) throws Exception {
Run ();}
 public static void Run()throws Exception {

java-readfile from harddisk

<read file from harddisk to array>
import java.util.Scanner;
.
.
Scanner scanner = null;

scanner = new Scanner (new BufferedReader(new FileReader("file")));
    while (scanner.hasNext()){
        System.out.println(scanner.next());
    }


java-harddisk java-file java-file-write



<write array to harddisk>
    PrintWriter pr = new PrintWriter("file");       
    for (int i0221 = 0; i0221 < bufferData.length; i0221++) {
    for (int j0221 = 1; j0221 < bufferData[i0221].length; j0221++) {
    pr.println("" + bufferData[i0221][j0221]);       
    } // end for i0221
    } // end for j0221
    pr.close();

jquery-event jquery-mouseup jquery-mouse-up

$(function(){
  $('#elementId').mouseup(function(e){
    var isCtrlPressed = e.ctrlKey;
    // true or false whether ctrl is pressed or not
  });
});

tableRead.java 20140508

import java.net.*;
import java.io.*;
import java.util.HashMap;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
/*
http://192.168.20.14:8080/erp/tableRead?db=BR201312111529&order=name&limit=10000&table=MANUFACTURER&fields=RECORDID,name&where=where%20status:`A`%20or%20status:`D`%20&format=S,S&callback=?
*/
//http://192.168.10.8:8080/erp/tableRead?db=BR201312111529&table=PRODUCT&fields=if(isnull(EOL),STR_TO_DATE(`01/01/1753`,%20`^m/^d/^Y`),eol),NO,DESCRIPTION,MARKET,CATEGORY,SUB_CATEGORY,MANUFACTURER,MODEL,DESCRIPTION,LIST_PRICE,MOQ,PRODUCT_STATUS,comment,UNSPSC_CODE,MAXIMUM_UNIT_PRICE,ANNUAL_MAINTENANCE_M1,ANNUAL_MAINTENANCE_M2,ANNUAL_MAINTENANCE_M3,WARRANTY_PERIOD_OFFERED_MONTHS,CV_STATUS,ACCOUNT_CODE,recordID&key=recordID&value=%271390296450593%27&format=S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S&where=&callback=?

// hr/tableRead?table=employee&fields=surname,terminationDate&where=where%20status:%60A%60&format=S,S&callback=1331
// e.g. hr/tableRead?table=employee&fields=surname&key=status&value=%27i%27&format=S&callback=1331
//e.g.hr/tableRead?table=payroll&fields=surname,bankstatus,bankerno,netpay&format=S,S,S,D&where=where%20bankstatus:%27B%27

public class tableRead extends HttpServlet {
static String constrain = ""; // 20130923
static String db = "";
static String key = "";
static String value = "";
static String result = "";
static String table = "";
static String fields = "";
static String order = "recordID";
static String limit = "";
static String offset = "";
static Connection con = null;
static Statement stmt = null;
static ResultSet rs = null;
static double[][] dResults = null;
static String _r = "";
static String format = "";
static void getSQLData() {
result = null;
String sqlString = "";
try {
String formats[] = format.split(",");
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager
.getConnection(
"jdbc:mysql://localhost/"+db+"?useUnicode=true&characterEncoding=UTF8",
"root", "root");
stmt = con.createStatement();
if((!limit.trim().equals("")) && (!offset.trim().equals("")))
{
sqlString = "Select " + fields + " from " + table + constrain + " order by "+order +
" limit "+limit +" offset "+offset ;
} else {
sqlString = "Select " + fields + " from " + table + constrain + " order by "+order ;
}
rs = stmt.executeQuery(sqlString);
int iRecno = 0;
String rD = ""; // RowDelimiter
result = "";
while (rs.next()) {
result = result + rD + "[";
String fD = ""; // fD=fieldDelimiter
for (int j = 1; j <= formats.length; j++) {
if (formats[j - 1].equals("I")) {
result = result + fD + Integer.toString(rs.getInt(j));
}
if (formats[j - 1].equals("D")) {
result = result + fD + Double.toString(rs.getDouble(j));
}
if (formats[j - 1].equals("L")) {
result = result + fD + Long.toString(rs.getLong(j));
}
if (formats[j - 1].equals("S")) {
String s3;
s3=rs.getString(j);

if (s3.equals("null")) {
s3="";
} else {
s3=s3.replaceAll("\r", "<z>").replaceAll("\n", "<z>");
}
s3=s3.replaceAll("'", "<SinglEQuoT>");
result = result + fD + "'" + s3+ "'";
}
fD = ",";
}
result = result + "]";
rD = ",\n";
++iRecno;
}
con.close();
} catch (Exception e) {
e.printStackTrace();
result = result + "\n" + sqlString + "\n" + e;
}
}

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

protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
HttpSession session = request.getSession();
if (session.isNew() || session.getAttribute("Login") == null ){
//response.sendRedirect("index.jsp");
}
response.setContentType("text/javascript");
response.setCharacterEncoding("UTF-8");
if (request.getParameter("db") != null
&& !request.getParameter("db").equals("")) {
db=request.getParameter("db");
}  //20131203
table = request.getParameter("table");

String s0 = "";
s0 = request.getParameter("fields").replace(":", "=");
String s2 = s0.replace("`", "'");
s2 = s2.replace("^", "%");
fields = s2;
format = request.getParameter("format"); // format="D,L,D,D,D,D,D"
String callback = request.getParameter("callback");
String value_2 = "0", value_3 = "0", value_4 = "0", value_5 = "0";
if (request.getParameter("order") != null
&& !request.getParameter("order").equals("")) {
order = request.getParameter("order");
}
if (request.getParameter("where") != null
&& !request.getParameter("where").equals("")) {
String s = request.getParameter("where").replace(":", "=");
String s1 = s.replace("`", "'");
s1 = s1.replace("^", "%");
constrain = " " + s1;
} else {
if (request.getParameter("key") != null
&& !request.getParameter("key").equals("")) {
key = request.getParameter("key");
}
if (request.getParameter("value") != null
&& !request.getParameter("value").equals("")) {
value = request.getParameter("value");
}
if (request.getParameter("value") != null
&& !request.getParameter("value").equals("")) {
constrain = " where " + key + " = " + value;
}
}
if (request.getParameter("limit") != null) {
limit=request.getParameter("limit");
}
if (request.getParameter("offset") != null) {
offset=request.getParameter("offset");
}

int iValue = 0, iValue2 = 0, iValue3 = 0, iValue4 = 0, iValue5 = 0;
int iSignificant = 4; // 4 is default
String _return = "", newString = "";
_r = callback + "([\n";
getSQLData();
// makeJSon(iSignificant);
//result=result.replaceAll("\r", "<z>");
//result=result.replaceAll("\n", "<z>");
_r = _r + result + "\n";
_r = _r + "]);";
StringBuilder sb = new StringBuilder();
sb.append(_r);
_r = "";
PrintWriter out = response.getWriter();
out.print(sb.toString());
out.flush();
order = null;
dResults = null;
format = null;
result = "";
result = null;
table = null;
fields = null;
key = null;
value = null;
_r = null;
}
}

2013年9月26日 星期四

html-mth-template

<select id="mth" name="mth">
<option value=""></option>
<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>

mysql-zap



truncate table payroll;

javascript-window

html-window-size


            $(window).resize(function () {
                if (isOpen) {
                    var winW = $(window).width();
                    var winH = $(window).height();
                    var objW = $('.modalPopLite-child-' + thisPopID).outerWidth();
                    var objH = $('.modalPopLite-child-' + thisPopID).outerHeight();
                    var left = (winW / 2) - (objW / 2);
                    var top = (winH / 2) - (objH / 2);
                    $('#modalPopLite-wrapper' + thisPopID).css({ 'left': left + "px", 'top': top });
                }
            });


window.onbeforeunload = function() {
    return 'You have unsaved changes!';
}

java-mthend



String mDateStart=mYear+"-"+mMth+"-"+"01";
String mDateEnd="";
String Mth31="01,03,05,07,08,10,12";
String Mth30="04,06,09,11";
if (Mth31.indexOf(mMth)>0){
mDateEnd=mYear+"-"+mMth+"-"+"31";
} else if (Mth30.indexOf(mMth)>0){
mDateEnd=mYear+"-"+mMth+"-"+"30";
} else if ((Integer.parseInt(mYear) % 4)==0){
mDateEnd=mYear+"-"+mMth+"-"+"29";
} else {
mDateEnd=mYear+"-"+mMth+"-"+"28";
}

java-mod



if ( (a % 2) == 0)
{
    isEven = true
}
else
{
    isEven = false
}

mssql-show view

SELECT SCHEMA_NAME(schema_id) AS schema_name
,name AS view_name
,OBJECTPROPERTYEX(OBJECT_ID,'IsIndexed') AS IsIndexed
,OBJECTPROPERTYEX(OBJECT_ID,'IsIndexable') AS IsIndexable
FROM sys.views

2013年9月25日 星期三

java-itext-example

// generate payroll pdf file
import java.io.FileOutputStream;
import java.io.IOException;
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.pdf.PdfWriter;
import java.net.*;import java.io.*;import java.util.HashMap;
import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;
import java.sql.SQLException;import java.sql.Statement;

import java.util.Date;

import com.itextpdf.text.Anchor;
import com.itextpdf.text.BadElementException;
import com.itextpdf.text.BaseColor;
import com.itextpdf.text.Chapter;
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.Element;
import com.itextpdf.text.Font;
import com.itextpdf.text.List;
import com.itextpdf.text.ListItem;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.Phrase;
import com.itextpdf.text.Section;
import com.itextpdf.text.pdf.PdfPCell;
import com.itextpdf.text.pdf.PdfPTable;
import com.itextpdf.text.pdf.PdfWriter;
import java.util.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;

/**
 * First iText example: Hello World.
 */
public class genPLPDF {
static String[][] dRaws=null;
static String[][] dResults=null;
    /** Path to the resulting PDF file. */
    public static final String RESULT
        = "/hr/payrollSlip.pdf";

    /**
     * Creates a PDF file: hello.pdf
     * @param    args    no arguments needed
     */
    public static void main(String[] args)
        throws DocumentException, IOException {
createPdf();
        new genPLPDF().createPdf(RESULT);
    }

public static void run() throws DocumentException, IOException {
createPdf();
new genPLPDF().createPdf(RESULT);
}

static public void createPdf(){

try{
String result="";
ResultSet rs = null;
Connection con = null;
Statement stmt = null;
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost/hr?useUnicode=true&characterEncoding=UTF8","root", "root");
stmt = con.createStatement();
String format="S,S,S,D,S,I,S,S"; // add column 1/5 step
String sqlString="select banker,bankerno,surname, salary,contracttype, employeenumber, departmentName,mpfnumber from employee ;"; // add column 2/5 step
result=sqlString;
String formats[]=format.split(",");
rs = stmt.executeQuery(sqlString);
while (rs.next()){String id=rs.getString(1);}rs.last(); //go bottom
int rowCount=rs.getRow(); //go recno
dRaws = new String[rowCount][];
rs.beforeFirst(); //go top
int iRecno=0;
String rD=""; // RowDelimiter
while (rs.next()){
dRaws[iRecno] = new String [20];  //insert column
result=result+rD+"[";
String fD="";  // fD=fieldDelimiter
for (int j=1; j<=formats.length; j++){
if (formats[j-1].equals("I")){
result=result+fD+Integer.toString(rs.getInt(j));
if (rs.getString(j).equals("No Value") || rs.getString(j).equals("null")){dRaws[iRecno][j-1]="0";}
else {dRaws[iRecno][j-1]=Integer.toString(rs.getInt(j));}}
if (formats[j-1].equals("D")){
result=result+fD+Double.toString(rs.getDouble(j));
dRaws[iRecno][j-1]=Double.toString(rs.getDouble(j));
}
if (formats[j-1].equals("L")){
result=result+fD+Long.toString(rs.getLong(j));
dRaws[iRecno][j-1]=Long.toString(rs.getLong(j));
}
if (formats[j-1].equals("S")){
result=result+fD+rs.getString(j);
dRaws[iRecno][j-1]=rs.getString(j);
}
fD=",";
}
result=result+"]";
rD=",\n";
++iRecno;
}


} catch (Exception e) {e.printStackTrace();}
}
    /**
     * Creates a PDF document.
     * @param filename the path to the new PDF document
     * @throws    DocumentException
     * @throws    IOException
     */

///////////////////////////////////////
   private static void addEmptyLine(Paragraph paragraph, int number) {
    for (int i = 0; i < number; i++) {
      paragraph.add(new Paragraph(" "));
    }
}
  private static Font catFont = new Font(Font.FontFamily.TIMES_ROMAN, 18,
      Font.BOLD);
  private static Font redFont = new Font(Font.FontFamily.TIMES_ROMAN, 12,
      Font.NORMAL, BaseColor.RED);
  private static Font subFont = new Font(Font.FontFamily.TIMES_ROMAN, 13,
      Font.BOLD);
  private static Font smallBold = new Font(Font.FontFamily.TIMES_ROMAN, 12,
      Font.BOLD);

  private static Font Font12 = new Font(Font.FontFamily.TIMES_ROMAN, 12,
      Font.NORMAL);

 private static Font font1 = new Font(Font.FontFamily.HELVETICA  , 25, Font.BOLD);
      private static Font font2 = new Font(Font.FontFamily.COURIER    , 18,
    Font.ITALIC | Font.UNDERLINE);
      private static Font font3 = new Font(Font.FontFamily.TIMES_ROMAN, 27);


////////////////////////////////////////////
    public void createPdf(String filename)
    throws DocumentException, IOException {

DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
Date date = new Date();

        // step 1
        Document document = new Document();
        // step 2
        PdfWriter.getInstance(document, new FileOutputStream(filename));
        // step 3
        document.open();
        // step 4
dResults = new String[dRaws.length][];
int fieldCount=20;
for(int i=0;i<dRaws.length; i++){
Anchor anchor = new Anchor("First Chapter", catFont);
anchor.setName("First Chapter");
Chapter catPart = new Chapter(new Paragraph(anchor), 1);
Paragraph subPara = new Paragraph("Subcategory 1", subFont);
Section subCatPart = catPart.addSection(subPara);
Paragraph paragraph = new Paragraph(); // new line newline

paragraph = new Paragraph("Payroll Slip", catFont);
paragraph.setAlignment(Element.ALIGN_CENTER);
document.add(paragraph);

Paragraph preface = new Paragraph();
addEmptyLine(preface, 3);


document.add(new Paragraph(" "));
document.add(new Paragraph(" "));


//-------------------------
PdfPTable table = new PdfPTable(4);  // number of column
table.setWidths(new int[]{560,300,600,300}); // column widths
table.setWidthPercentage(100); // tables width 100%
    // t.setBorderColor(BaseColor.GRAY);
    // t.setPadding(4);
    // t.setSpacing(4);
    // t.setBorderWidth(1);

table.getDefaultCell().setBorder(0); // set itext-table-border-width to 0

/*
    PdfPCell c1 = new PdfPCell(new Phrase("Table Header 1"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);
    c1 = new PdfPCell(new Phrase("Table Header 2"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);
    c1 = new PdfPCell(new Phrase("Table Header 3"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);
    table.setHeaderRows(1);
*/
PdfPCell c1 = new PdfPCell(new Phrase(""));

    c1 = new PdfPCell(new Phrase("Staff Name"));
c1.setBorder(0);
    c1.setHorizontalAlignment(Element.ALIGN_LEFT);
    table.addCell(c1);


//SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");



    table.addCell(dRaws[i][2]);
 

c1 = new PdfPCell(new Phrase("Date"));
c1.setBorder(0);
c1.setPaddingRight(18);
    c1.setHorizontalAlignment(Element.ALIGN_RIGHT);
    table.addCell(c1);
c1 = new PdfPCell(new Phrase(""+dateFormat.format(date)));
c1.setBorder(0);
c1.setPaddingRight(18);
    c1.setHorizontalAlignment(Element.ALIGN_RIGHT);
    table.addCell(c1);
 


    table.addCell("Offical name");
    table.addCell("Lee s l");
c1 = new PdfPCell(new Phrase("Period (From)"));
c1.setBorder(0);
c1.setPaddingRight(18);
    c1.setHorizontalAlignment(Element.ALIGN_RIGHT);
    table.addCell(c1);
 
  c1 = new PdfPCell(new Phrase("17/7/2013"));
c1.setBorder(0);
c1.setPaddingRight(18);
    c1.setHorizontalAlignment(Element.ALIGN_RIGHT);
    table.addCell(c1);
 

    table.addCell("Position");
    table.addCell("IT Engineer");
c1 = new PdfPCell(new Phrase("Period (to)"));
c1.setBorder(0);
c1.setPaddingRight(18);
    c1.setHorizontalAlignment(Element.ALIGN_RIGHT);
    table.addCell(c1);
  c1 = new PdfPCell(new Phrase("31/7/2013"));
c1.setBorder(0);
c1.setPaddingRight(18);
    c1.setHorizontalAlignment(Element.ALIGN_RIGHT);
    table.addCell(c1);
 

    table.addCell("");
    table.addCell("");
c1 = new PdfPCell(new Phrase("Total Working Hour"));
c1.setBorder(0);
c1.setPaddingRight(18);
    c1.setHorizontalAlignment(Element.ALIGN_RIGHT);
    table.addCell(c1);
c1 = new PdfPCell(new Phrase("90"));
c1.setBorder(0);
c1.setPaddingRight(18);
    c1.setHorizontalAlignment(Element.ALIGN_RIGHT);
    table.addCell(c1);
 

    table.addCell("");
    table.addCell("");
    table.addCell("");
    table.addCell("");

    table.addCell("");
    table.addCell("");
    table.addCell("");
    table.addCell("");

    table.addCell("Earnings");
c1 = new PdfPCell(new Phrase("Amount (HK$)"));
c1.setBorder(0);
c1.setPaddingRight(18);
    c1.setHorizontalAlignment(Element.ALIGN_RIGHT);
    table.addCell(c1);
    table.addCell("Deducations");
c1 = new PdfPCell(new Phrase("Amount (HK$)"));
c1.setBorder(0);
c1.setPaddingRight(18);
    c1.setHorizontalAlignment(Element.ALIGN_RIGHT);
    table.addCell(c1);
 
    table.addCell("");
    table.addCell("");
    table.addCell("");
    table.addCell("");

    table.addCell("");
    table.addCell("");
    table.addCell("");
    table.addCell("");

    table.addCell("Basic Monthly Salary");
c1 = new PdfPCell(new Phrase("3500.00"));
c1.setBorder(0);
c1.setPaddingRight(18);
    c1.setHorizontalAlignment(Element.ALIGN_RIGHT);
    table.addCell(c1);
    table.addCell("Late Penalty");
c1 = new PdfPCell(new Phrase("0.00"));
c1.setBorder(0);
c1.setPaddingRight(18);
    c1.setHorizontalAlignment(Element.ALIGN_RIGHT);
    table.addCell(c1);
 

    table.addCell("Salary pay back / Adjustment");
c1 = new PdfPCell(new Phrase("0.00"));
c1.setBorder(0);
c1.setPaddingRight(18);
    c1.setHorizontalAlignment(Element.ALIGN_RIGHT);
    table.addCell(c1);
    table.addCell("Salary Adjustment");
c1 = new PdfPCell(new Phrase("0.00"));
c1.setBorder(0);
c1.setPaddingRight(18);
    c1.setHorizontalAlignment(Element.ALIGN_RIGHT);
    table.addCell(c1);

    table.addCell("Bonus/Incentive");
c1 = new PdfPCell(new Phrase("0.00"));
c1.setBorder(0);
c1.setPaddingRight(18);
    c1.setHorizontalAlignment(Element.ALIGN_RIGHT);
    table.addCell(c1);
    table.addCell("Absent / Sick Leave");
  c1 = new PdfPCell(new Phrase("0.00"));
c1.setBorder(0);
c1.setPaddingRight(18);
    c1.setHorizontalAlignment(Element.ALIGN_RIGHT);
    table.addCell(c1);

    table.addCell("Others");
c1 = new PdfPCell(new Phrase("0.00"));
c1.setBorder(0);
c1.setPaddingRight(18);
    c1.setHorizontalAlignment(Element.ALIGN_RIGHT);
    table.addCell(c1);
    table.addCell("Others");
c1 = new PdfPCell(new Phrase("0.00"));
c1.setBorder(0);
c1.setPaddingRight(18);
    c1.setHorizontalAlignment(Element.ALIGN_RIGHT);
    table.addCell(c1);


    table.addCell("");
    table.addCell("");
    table.addCell("");
    table.addCell("");

    table.addCell("");
    table.addCell("");
    table.addCell("");
    table.addCell("");


c1 = new PdfPCell(new Phrase("Gross Income <a>",subFont));
c1.setBorder(0);
c1.setPaddingRight(18);
    c1.setHorizontalAlignment(Element.ALIGN_LEFT);
    table.addCell(c1);
c1 = new PdfPCell(new Phrase("0.00",subFont));
c1.setBorder(0);
c1.setPaddingRight(18);
    c1.setHorizontalAlignment(Element.ALIGN_RIGHT);
    table.addCell(c1);
c1 = new PdfPCell(new Phrase("Total Deductions <b>",subFont));
c1.setBorder(0);
c1.setPaddingRight(18);
    c1.setHorizontalAlignment(Element.ALIGN_LEFT);
    table.addCell(c1);
c1 = new PdfPCell(new Phrase("0.00",subFont));
c1.setBorder(0);
c1.setPaddingRight(18);
    c1.setHorizontalAlignment(Element.ALIGN_RIGHT);
    table.addCell(c1);

    table.addCell("");
    table.addCell("");
    table.addCell("");
    table.addCell("");

    table.addCell("");
    table.addCell("");
    table.addCell("");
    table.addCell("");



c1 = new PdfPCell(new Phrase("Relevant Income <c=a-b>",subFont));
c1.setBorder(0);
c1.setPaddingRight(18);
    c1.setHorizontalAlignment(Element.ALIGN_LEFT);
    table.addCell(c1);
 
c1 = new PdfPCell(new Phrase("0.00",subFont));
c1.setBorder(0);
c1.setPaddingRight(18);
    c1.setHorizontalAlignment(Element.ALIGN_RIGHT);
    table.addCell(c1);

c1 = new PdfPCell(new Phrase("Already Paid <d>",subFont));
c1.setBorder(0);
c1.setPaddingRight(18);
    c1.setHorizontalAlignment(Element.ALIGN_LEFT);
    table.addCell(c1);
 
c1 = new PdfPCell(new Phrase("0.00",subFont));
c1.setBorder(0);
c1.setPaddingRight(18);
    c1.setHorizontalAlignment(Element.ALIGN_RIGHT);
    table.addCell(c1);


c1 = new PdfPCell(new Phrase("Net pay <e=c-d-f>",subFont));
c1.setBorder(0);
c1.setPaddingRight(18);
    c1.setHorizontalAlignment(Element.ALIGN_LEFT);
    table.addCell(c1);
 
c1 = new PdfPCell(new Phrase("0.00",subFont));
c1.setBorder(0);
c1.setPaddingRight(18);
    c1.setHorizontalAlignment(Element.ALIGN_RIGHT);
    table.addCell(c1);
    table.addCell("Employee MPF Contribution < 1");
  c1 = new PdfPCell(new Phrase("0.00"));
c1.setBorder(0);
c1.setPaddingRight(18);
    c1.setHorizontalAlignment(Element.ALIGN_RIGHT);
    table.addCell(c1);

    table.addCell("");
    table.addCell("");
    table.addCell("");
    table.addCell("");

    table.addCell("");
    table.addCell("");
    table.addCell("");
    table.addCell("");


table.addCell("Employer MPF Contribution");
  c1 = new PdfPCell(new Phrase("0.00"));
c1.setBorder(0);
c1.setPaddingRight(18);
    c1.setHorizontalAlignment(Element.ALIGN_RIGHT);
    table.addCell(c1);
    table.addCell("Commerence Date :");
    table.addCell("17 July 2013");

    table.addCell("Bank A/C#");
    table.addCell("BOC 12345678902");
    table.addCell("");
    table.addCell("");

    table.addCell("");
    table.addCell("");
    table.addCell("");
    table.addCell("");

    //subCatPart.add(table);
document.add(table);
preface.add(new Paragraph("This is an offical payroll slip. Neither signature nor acknowledgement is required.", smallBold));
preface.add(new Paragraph("***Please check this payroll slip carefully and refer any quiery to Admin Dept***", smallBold));
document.add(preface);
//-------------------------

//preface.add(new Paragraph("Payroll Slip", catFont));
//addEmptyLine(preface, 1);

// Will create: Report generated by: _name, _date

/*
preface.add(new Paragraph("Report generated by: " + System.getProperty("user.name") + ", " + new Date(), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
smallBold));
addEmptyLine(preface, 3);
preface.add(new Paragraph("This document describes something which is very important ",
smallBold));
addEmptyLine(preface, 8);
// RED Color   preface.add(new Paragraph("This document is a preliminary version and not subject to your license agreement or any other agreement with vogella.com ;-).",redFont));
document.add(preface);
*/
// Start a new page


/* left
paragraph.setAlignment(Element.ALIGN_RIGHT);
document.add(paragraph);
*/

// Centered
paragraph = new Paragraph("");
paragraph.setAlignment(Element.ALIGN_CENTER);
document.add(paragraph);
// Left
paragraph = new Paragraph("");
paragraph.setAlignment(Element.ALIGN_LEFT);
document.add(paragraph);
// Left with indentation
paragraph = new Paragraph("");
paragraph.setAlignment(Element.ALIGN_LEFT);
paragraph.setIndentationLeft(50);
document.add(paragraph);
document.newPage();
//////////////////////
}
        // step 5
        document.close();
    }
}