HEX
Server: Apache/2.4.46 (Win64) OpenSSL/1.1.1j PHP/8.4.25
System: Windows NT DESKTOP-4TAV2RJ 10.0 build 19045 (Windows 10) AMD64
User: fred (0)
PHP: 8.4.25
Disabled: NONE
Upload Files
File: C:/xampp/htdocs/namecard/libTT1.php
<head>
<meta http-equiv="Content-Type" content="text/html; charset=big5" />
<title>sser name card system</title>

<?php



$searchpath = "c:/xampp/htdocs/namecard/data/";
//$tmpt = "nuvoton_non_mobT.pdf";


$data = array(  "name1_ch"				=>"Name1",
		"title1_ch"		=> "title1",
		"section1_ch"	=> "sect1",
		"add1_ch"		=> "add1"
		
	);
$dataE = array( 
		"tel1_ch"		=> "123456",
		"email3_ch"		=> "[email protected]",
	);


	

$infile = "nuvoton_mob.pdf";
	
$p = PDF_new();

PDF_set_option($p, "errorpolicy=legacy");//php54

PDF_set_option($p, "SearchPath=".$searchpath);
/* This line is required to avoid problems on Japanese systems */
//PDF_set_parameter($p, "hypertextencoding", "winansi");//53
PDF_set_option($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));}

//if (PDF_begin_document($p,"", "openmode=layers") == 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_document($p, $infile, "");
if ($blockcontainer == 0) {
    die ("Error: " . PDF_get_errmsg($p));
}
/* 53
$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 */


    $width = PDF_pcos_get_number($p,$blockcontainer, "pages[0]/width");

    $height = PDF_pcos_get_number($p,$blockcontainer, "pages[0]/height");


$hbleed=$width-5.669;
$wbleed=$height-5.669;

PDF_begin_page_ext($p, $width, $height,"bleedbox {0 0 ".$width." ".$height."} cropbox {5.669 5.669 ".$hbleed." ".$wbleed."}");  /* start a new page */

/* This will adjust the page size to the block container's size. */
PDF_fit_pdi_page($p, $page, 0, 0,"");

//$layerVDP = PDF_define_layer($p,"VDP", "");
//PDF_begin_layer($p,$layerVDP);

/* 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_layer($p);	
PDF_end_page_ext($p, "");
PDF_close_pdi_page($p, $page);


PDF_end_document($p, "");
PDF_close_pdi($p, $blockcontainer);

$buf = PDF_get_buffer($p);
$len = strlen($buf);

$fName="ttPDF";
$f = fopen($fName.".pdf", "w");
fwrite($f, $buf);
fclose($f);


echo '<a href="'.$fName.'.pdf">'.$fName.'.pdf</a><br />';
//for $c

   
 

?>