File: C:/xampp/htdocs/namecard/TVI-parsing11c.php
<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5" />
<title>sser name card system</title>
<?php
$dStr=rand(1,100);
///1025
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{ ///1204
//echo "Upload: " . $_FILES["file"]["name"] . "<br />";
$filename=$dStr.$_FILES["file"]["name"];
//echo "Type: " . $_FILES["file"]["type"] . "<br />";
// echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />";
// echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />";
if (file_exists("upload/" .$dStr. $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ". "<br />";
}
else
{ ////1023
move_uploaded_file($_FILES["file"]["tmp_name"],
"upload/" .$dStr. $_FILES["file"]["name"]);
// echo "upload sucess! " . "<br />";
$contents = file("upload/".$dStr.$_FILES["file"]["name"]);
$string = implode($contents);
//echo $contents[20];
//echo $string;
$p = ereg_replace("\r\n?", "\n", $string);
$dotPT = explode(",", $string);
$csvname = substr($_FILES["file"]["name"], 0, -4);
echo $csvname."<br />";
for($x=0;$x<=110;$x++){
//echo $x."--".$dotPT[$x]."<br />";
if ( preg_match('/\r\n?/',$dotPT[$x]) ){
$chunk=$x+1;
echo "chunk: ".$chunk." is it<br />";
break;
}}
//echo "<br>$pt=".$pt;
$p = str_replace("\n", ',', $p);
//echo $p;
$dot = explode(",", $p);
echo "array size=".(sizeof($dot)-1)."<br />";
//echo "dot-19=".$dot[19];
$copy=(((sizeof($dot)-1)/$chunk)-2);
echo "copy of namecard=".$copy."<br />";
$key_company_na = array_search('company_na', $dot); // $key = 2;
echo "company name is here:".$key_company_na."<br />";
$key_send_date = array_search('send_date', $dot); // $key = 2;
echo "send_date is here:".$key_send_date."<br />";
$key_delive_date = array_search('delive_date', $dot); // $key = 2;
echo "delive_date is here:".$key_delive_date."<br />";
$key_receive_date = array_search('receive_date', $dot); // $key = 2;
echo "receive_date is here:".$key_receive_date."<br />";
$key_template_na = array_search('template_na', $dot); // $key = 2;
echo "template_na is here:".$key_template_na."<br />";
$key_box_num = array_search('box_num', $dot); // $key = 2;
echo "box_num is here:".$key_box_num."<br />";
$key_fast_yn = array_search('fast_yn', $dot); // $key = 2;
echo "fast_yn is here:".$key_fast_yn."<br />";
$key_name1_ch = array_search('name1_ch', $dot); // $key = 2;
echo "ch name1 is here:".$key_name1_ch."<br />";
$key_name2_ch = array_search('name2_ch', $dot); // $key = 2;
echo "ch name2 is here:".$key_name2_ch."<br />";
$key_section1_ch = array_search('section1_ch', $dot); // $key = 2;
echo "section1_ch is here:".$key_section1_ch."<br />";
$key_section2_ch = array_search('section2_ch', $dot); // $key = 2;
echo "section2_ch is here:".$key_section2_ch."<br />";
$key_section3_ch = array_search('section3_ch', $dot); // $key = 2;
echo "section3_ch is here:".$key_section3_ch."<br />";
$key_section4_ch = array_search('section4_ch', $dot); // $key = 2;
echo "section4_ch is here:".$key_section4_ch."<br />";
$key_title1_ch = array_search('title1_ch', $dot); // $key = 2;
echo "ch title is here:".$key_title1_ch."<br />";
$key_title2_ch = array_search('title2_ch', $dot); // $key = 2;
echo "ch title2 is here:".$key_title2_ch."<br />";
$key_title3_ch = array_search('title3_ch', $dot); // $key = 2;
echo "ch title3 is here:".$key_title3_ch."<br />";
$key_title4_ch = array_search('title4_ch', $dot); // $key = 2;
echo "ch title4 is here:".$key_title4_ch."<br />";
$key_tel1_ch = array_search('tel1_ch', $dot); // $key = 2;
echo "ch tel1 is here:".$key_tel1_ch."<br />";
$key_ext1_ch = array_search('ext1_ch', $dot); // $key = 2;
echo "ch exi1 is here:".$key_ext1_ch."<br />";
$key_tel2_ch = array_search('tel2_ch', $dot); // $key = 2;
echo "ch tel2 is here:".$key_tel2_ch."<br />";
$key_ext2_ch = array_search('ext2_ch', $dot); // $key = 2;
echo "ch exi2 is here:".$key_ext2_ch."<br />";
$key_fax1_ch = array_search('fax1_ch', $dot); // $key = 2;
echo "ch fax1 is here:".$key_fax1_ch."<br />";
$key_fax2_ch = array_search('fax2_ch', $dot); // $key = 2;
echo "ch fax2 is here:".$key_fax2_ch."<br />";
$key_mob1_ch = array_search('mob1_ch', $dot); // $key = 2;
echo "ch mob1 is here:".$key_mob1_ch."<br />";
$key_mob2_ch = array_search('mob_ch', $dot); // $key = 2;
echo "ch mob is here:".$key_mob2_ch."<br />";
$key_mob3_ch = array_search('mob3_ch', $dot); // $key = 2;
echo "ch mob3 is here:".$key_mob3_ch."<br />";
$key_email1_ch = array_search('email1_ch', $dot); // $key = 2;
echo "ch email1 is here:".$key_email1_ch."<br />";
$key_email2_ch = array_search('email2_ch', $dot); // $key = 2;
echo "ch email2 is here:".$key_email2_ch."<br />";
$key_email3_ch = array_search('email3_ch', $dot); // $key = 2;
echo "ch email3 is here:".$key_email3_ch."<br />";
$key_add1_ch = array_search('add1_ch', $dot); // $key = 2;
echo "ch add1 is here:".$key_add1_ch."<br />";
$key_add2_ch = array_search('add2_ch', $dot); // $key = 2;
echo "ch add2 is here:".$key_add2_ch."<br />";
$key_add3_ch = array_search('add3_ch', $dot); // $key = 2;
echo "ch add3 is here:".$key_add3_ch."<br />";
$key_add4_ch = array_search('add4_ch', $dot); // $key = 2;
echo "ch add4 is here:".$key_add4_ch."<br />";
$key_unif_no1 = array_search('unif_no1', $dot); // $key = 2;
echo "unif_no1 is here:".$key_unif_no1."<br />";
$key_unif_no2 = array_search('unif_no2', $dot); // $key = 2;
echo "unif_no2 is here:".$key_unif_no2."<br />";
$key_unif_no3 = array_search('unif_no3', $dot); // $key = 2;
echo "unif_no3 is here:".$key_unif_no3."<br />";
$key_name1_en = array_search('name1_en', $dot); // $key = 2;
echo "name1_en is here:".$key_name1_en."<br />";
$key_name2_en = array_search('name2_en', $dot); // $key = 2;
echo "name2_en is here:".$key_name2_en."<br />";
$key_section1_en = array_search('section1_en', $dot); // $key = 2;
echo "section1_en is here:".$key_section1_en."<br />";
$key_section2_en = array_search('section2_en', $dot); // $key = 2;
echo "section2_en is here:".$key_section2_en."<br />";
$key_section3_en = array_search('section3_en', $dot); // $key = 2;
echo "section3_en is here:".$key_section3_en."<br />";
$key_section4_en = array_search('section4_en', $dot); // $key = 2;
echo "section4_en is here:".$key_section4_en."<br />";
$key_title1_en = array_search('title1_en', $dot); // $key = 2;
echo "title1_en is here:".$key_title1_en."<br />";
$key_title2_en = array_search('title2_en', $dot); // $key = 2;
echo "title2_en is here:".$key_title2_en."<br />";
$key_title3_en = array_search('title3_en', $dot); // $key = 2;
echo "title3_en is here:".$key_title3_en."<br />";
$key_title4_en = array_search('title4_en', $dot); // $key = 2;
echo "title4_en is here:".$key_title4_en."<br />";
$key_tel1_en = array_search('tel1_en', $dot); // $key = 2;
echo "tel1_en is here:".$key_tel1_en."<br />";
$key_ext1_en = array_search('ext1_en', $dot); // $key = 2;
echo "ext1_en is here:".$key_ext1_en."<br />";
$key_tel2_en = array_search('tel2_en', $dot); // $key = 2;
echo "tel2_en is here:".$key_tel2_en."<br />";
$key_ext2_en = array_search('ext2_en', $dot); // $key = 2;
echo "ext2_en is here:".$key_ext2_en."<br />";
$key_fax1_en = array_search('fax1_en', $dot); // $key = 2;
echo "fax1_en is here:".$key_fax1_en."<br />";
$key_fax2_en = array_search('fax2_en', $dot); // $key = 2;
echo "fax2_en is here:".$key_fax2_en."<br />";
$key_mob1_en = array_search('mob1_en', $dot); // $key = 2;
echo "mob1_en is here:".$key_mob1_en."<br />";
$key_mob2_en = array_search('mob2_en', $dot); // $key = 2;
echo "mob2_en is here:".$key_mob2_en."<br />";
$key_mob3_en = array_search('mob3_en', $dot); // $key = 2;
echo "mob3_en is here:".$key_mob3_en."<br />";
$key_email1_en = array_search('email1_en', $dot); // $key = 2;
echo "email1_en is here:".$key_email1_en."<br />";
$key_email2_en = array_search('email2_en', $dot); // $key = 2;
echo "email2_en is here:".$key_email2_en."<br />";
$key_add1_en = array_search('add1_en', $dot); // $key = 2;
echo "add1_en is here:".$key_add1_en."<br />";
$key_add2_en = array_search('add2_en', $dot); // $key = 2;
echo "add2_en is here:".$key_add2_en."<br />";
$key_add3_en = array_search('add3_en', $dot); // $key = 2;
echo "add3_en is here:".$key_add3_en."<br />";
$key_add4_en = array_search('add4_en', $dot); // $key = 2;
echo "add4_en is here:".$key_add4_en."<br />";
$key_add5_en = array_search('add5_en', $dot); // $key = 2;
echo "add5_en is here:".$key_add5_en."<br />";
$key_add6_en = array_search('add6_en', $dot); // $key = 2;
echo "add6_en is here:".$key_add6_en."<br />";
$key_add7_en = array_search('add7_en', $dot); // $key = 2;
echo "add7_en is here:".$key_add7_en."<br />";
$key_add8_en = array_search('add8_en', $dot); // $key = 2;
echo "add8_en is here:".$key_add8_en."<br />";
$key_add9_en = array_search('add9_en', $dot); // $key = 2;
echo "add9_en is here:".$key_add9_en."<br />";
$key_msn_account = array_search('msn_account', $dot); // $key = 2;
echo "msn_account is here:".$key_msn_account."<br />";
$key_facebook_account = array_search('facebook_account', $dot); // $key = 2;
echo "facebook_account is here:".$key_facebook_account."<br />";
$key_skype_account = array_search('skype_account', $dot); // $key = 2;
echo "skype_account is here:".$key_skype_account."<br />";
$key_sns_1 = array_search('sns_1', $dot); // $key = 2;
echo "sns_1 is here:".$key_sns_1."<br />";
$key_sns_2 = array_search('sns_2', $dot); // $key = 2;
echo "sns_2 is here:".$key_sns_2."<br />";
$key_sns_3 = array_search('sns_3', $dot); // $key = 2;
echo "sns_3 is here:".$key_sns_3."<br />";
$key_sns_4 = array_search('sns_4', $dot); // $key = 2;
echo "sns_4 is here:".$key_sns_4."<br />";
$key_sns_5 = array_search('sns_5', $dot); // $key = 2;
echo "sns_5 is here:".$key_sns_5."<br />";
$key_sns_6 = array_search('sns_6', $dot); // $key = 2;
echo "sns_6 is here:".$key_sns_6."<br />";
$key_sns_7 = array_search('sns_7', $dot); // $key = 2;
echo "sns_7 is here:".$key_sns_7."<br />";
$key_url_1 = array_search('url_1', $dot); // $key = 2;
echo "url_1 is here:".$key_url_1."<br />";
$key_url_2 = array_search('url_2', $dot); // $key = 2;
echo "url_2 is here:".$key_url_2."<br />";
$key_url_3 = array_search('url_3', $dot); // $key = 2;
echo "url_3 is here:".$key_url_3."<br />";
$key_special1_ch = array_search('special1_ch', $dot); // $key = 2;
echo "special1_ch is here:".$key_special1_ch."<br />";
$key_special2_ch = array_search('special2_ch', $dot); // $key = 2;
echo "special2_ch is here:".$key_special2_ch."<br />";
$key_special3_ch = array_search('special3_ch', $dot); // $key = 2;
echo "special3_ch is here:".$key_special3_ch."<br />";
$key_special4_ch = array_search('special4_ch', $dot); // $key = 2;
echo "special4_ch is here:".$key_special4_ch."<br />";
$key_special5_ch = array_search('special5_ch', $dot); // $key = 2;
echo "special5_ch is here:".$key_special5_ch."<br />";
$key_special6_ch = array_search('special6_ch', $dot); // $key = 2;
echo "special6_ch is here:".$key_special6_ch."<br />";
$key_special7_ch = array_search('special7_ch', $dot); // $key = 2;
echo "special7_ch is here:".$key_special7_ch."<br />";
$key_special8_ch = array_search('special8_ch', $dot); // $key = 2;
echo "special8_ch is here:".$key_special8_ch."<br />";
$key_special9_ch = array_search('special9_ch', $dot); // $key = 2;
echo "special9_ch is here:".$key_special9_ch."<br />";
$key_special10_ch = array_search('special10_ch', $dot); // $key = 2;
echo "special10_ch is here:".$key_special10_ch."<br />";
$key_special1_en = array_search('special1_en', $dot); // $key = 2;
echo "special1_en is here:".$key_special1_en."<br />";
$key_special2_en = array_search('special2_en', $dot); // $key = 2;
echo "special2_en is here:".$key_special2_en."<br />";
$key_special3_en = array_search('special3_en', $dot); // $key = 2;
echo "special3_en is here:".$key_special3_en."<br />";
$key_special4_en = array_search('special4_en', $dot); // $key = 2;
echo "special4_en is here:".$key_special4_en."<br />";
$key_special5_en = array_search('special5_en', $dot); // $key = 2;
echo "special5_en is here:".$key_special5_en."<br />";
$key_special6_en = array_search('special6_en', $dot); // $key = 2;
echo "special6_en is here:".$key_special6_en."<br />";
$key_special7_en = array_search('special7_en', $dot); // $key = 2;
echo "special7_en is here:".$key_special7_en."<br />";
$key_special8_en = array_search('special8_en', $dot); // $key = 2;
echo "special8_en is here:".$key_special8_en."<br />";
$key_special9_en = array_search('special9_en', $dot); // $key = 2;
echo "special9_en is here:".$key_special9_en."<br />";
$key_special10_en = array_search('special10_en', $dot); // $key = 2;
echo "special10_en is here:".$key_special10_en."<br />";
$key_link1_path = array_search('link1_path', $dot); // $key = 2;
echo "link1_path is here:".$key_link1_path."<br />";
$key_link2_path = array_search('link2_path', $dot); // $key = 2;
echo "link2_path is here:".$key_link2_path."<br />";
$key_link3_path = array_search('link3_path', $dot); // $key = 2;
echo "link3_path is here:".$key_link3_path."<br />";
$key_link4_path = array_search('link4_path', $dot); // $key = 2;
echo "link4_path is here:".$key_link4_path."<br />";
$key_link5_path = array_search('link5_path', $dot); // $key = 2;
echo "link5_path is here:".$key_link5_path."<br />";
$key_link6_path = array_search('link6_path', $dot); // $key = 2;
echo "link6_path is here:".$key_link6_path."<br />";
$key_link7_path = array_search('link7_path', $dot); // $key = 2;
echo "link7_path is here:".$key_link7_path."<br />";
$key_link8_path = array_search('link8_path', $dot); // $key = 2;
echo "link8_path is here:".$key_link8_path."<br />";
$key_link9_path = array_search('link9_path', $dot); // $key = 2;
echo "link9_path is here:".$key_link9_path."<br />";
$key_link10_path = array_search('link10_path', $dot); // $key = 2;
echo "link10_path is here:".$key_link10_path."<br />";
/* This is where font/image/PDF input files live. Adjust as necessary.
*
* Note that this directory must also contain the LuciduxSans font outline
* and metrics files.
*/
$searchpath = "c:/xampp/htdocs/namecard/data/";
for($c=1;$c<=$copy;$c++){
$company_na=$dot[($key_company_na+($chunk*$c))];
$yn=$dot[($key_fast_yn+($chunk*$c))];
$name_ch=$dot[($key_name1_ch+($chunk*$c))];
//$name_ch="chName";
$rDate=$dot[($key_delive_date+($chunk*$c))];
date_default_timezone_set('UTC+8');
$nDate=date('Y-m-d_His', time());
$fName=$company_na."_".$name_ch."_".$yn."_".$rDate."_".$nDate;
$data = array( "name1_ch" => $dot[($key_name1_ch+($chunk*$c))],
"title1_ch" => $dot[($key_title1_ch+($chunk*$c))],
"section1_ch" => $dot[($key_section1_ch+($chunk*$c))],
"add1_ch" => $dot[($key_add1_ch+($chunk*$c))],
"unif_no1" => $dot[($key_unif_no1+($chunk*$c))],
"unif_no2" => $dot[($key_unif_no2+($chunk*$c))]
);
$dataE = array(
"tel1_ch" => $dot[($key_tel1_ch+($chunk*$c))],
"ext1_ch" => $dot[($key_ext1_ch+($chunk*$c))],
"fax1_ch" => $dot[($key_fax1_ch+($chunk*$c))],
"mob1_ch" => $dot[($key_mob1_ch+($chunk*$c))],
"unif_no1" => $dot[($key_unif_no1+($chunk*$c))],
"email1_ch" => $dot[($key_email1_ch+($chunk*$c))]
);
$tmpstr=$dot[($key_template_na+($chunk*$c))].".pdf";
echo $tmpstr."_:;_";
//$str=mb_convert_encoding($tmpstr, "big5");
$str = iconv('utf-8', 'big5', $tmpstr);
echo $str."_::_";
$infile = $tmpstr;
$p = PDF_new();
// $p->set_parameter("SearchPath", "c:/cmap");
// $Cfont = $p->load_font("DFHeiStd-W5", 'B5pc-H', "");
# This means we must check return values of load_font() etc.
PDF_set_parameter($p, "errorpolicy", "return");
/* Set the search path for fonts and PDF files */
PDF_set_parameter($p, "SearchPath", $searchpath);
/* This line is required to avoid problems on Japanese systems */
PDF_set_parameter($p, "hypertextencoding", "winansi");
/* open new PDF file; insert a file name to create the PDF on disk */
if (PDF_begin_document($p, "", "") == 0) {
die("Error: " . PDF_get_errmsg($p));
}
PDF_set_info($p, "Creator", "businesscard.php");
PDF_set_info($p, "Author", "Fred Kuo");
PDF_set_info($p, "Title", "PDFlib block processing sample (PHP)");
$blockcontainer = PDF_open_pdi($p, $infile, "", 0);
if ($blockcontainer == 0) {
die ("Error: " . PDF_get_errmsg($p));
}
$page = PDF_open_pdi_page($p, $blockcontainer, 1, "");
if ($page == 0) {
die ("Error: " . PDF_get_errmsg($p));
}
PDF_begin_page_ext($p, 20, 20, ""); /* dummy page size */
/* This will adjust the page size to the block container's size. */
PDF_fit_pdi_page($p, $page, 0, 0, "adjustpage");
/* Fill all text blocks with dynamic data */
foreach ($data as $key => $value) {
if (PDF_fill_textblock($p, $page, $key, $value,
"embedding encoding=ETen-B5-H") == 0) {
printf("Warning: %s\n ", PDF_get_errmsg($p));
}}
foreach ($dataE as $key => $value) {
if (PDF_fill_textblock($p, $page, $key, $value,"encoding unicode textformat utf8") == 0) {
printf("Warning: %s\n ", PDF_get_errmsg($p));
}}
PDF_end_page_ext($p, "");
PDF_close_pdi_page($p, $page);
/////////////////////////////////// try page 2
$data2 = array( "name1_en" => $dot[($key_name1_en+($chunk*$c))],
"title1_en" => $dot[($key_title1_en+($chunk*$c))],
"section1_en" => $dot[($key_section1_en+($chunk*$c))],
"add1_en" => $dot[($key_add1_en+($chunk*$c))],
"tel1_en" => $dot[($key_tel1_en+($chunk*$c))],
"mob1_en" => $dot[($key_mob1_en+($chunk*$c))],
"fax1_en" => $dot[($key_fax1_en+($chunk*$c))],
"email1_en" => $dot[($key_email1_ch+($chunk*$c))]
);
$page2 = PDF_open_pdi_page($p, $blockcontainer, 2, "");
PDF_begin_page_ext($p, 20, 20, ""); /* dummy page size */
/* This will adjust the page size to the block container's size. */
PDF_fit_pdi_page($p, $page2, 0, 0, "adjustpage");
foreach ($data2 as $key => $value) {
if (PDF_fill_textblock($p, $page2, $key, $value,
"encoding unicode textformat utf8") == 0) {
printf("Warning: %s\n ", PDF_get_errmsg($p));
}
}
PDF_end_page_ext($p, "");
PDF_close_pdi_page($p, $page2);
PDF_end_document($p, "");
PDF_close_pdi($p, $blockcontainer);
$buf = PDF_get_buffer($p);
$len = strlen($buf);
$f = fopen($fName.".pdf", "w");
fwrite($f, $buf);
fclose($f);
echo '<a href="'.$fName.'.pdf">'.$fName.'.pdf</a><br />';
}///for $c
//header("Content-type: application/pdf");
//header("Content-Length: $len");
//header("Content-Disposition: inline; filename=businesscard.pdf");
//print $buf;
//pdf_save($p);
//PDF_delete($p);
////////////////////data base sector/////////////////
}//satrt parsing
}//upload sucess
//upload check ok
echo "find pdf here<br />";
?>