Jump to content

MatBoy

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Everything posted by MatBoy

  1. Hi Guys, I'm trying to accomplish using the following script to make the products array larger and add a new page when the page is filled. This does not work, it seems that I have to do something with my $currY that I need to recalculate, but I can't figure out how. At the moment the script gives with about 40 lines of items also 40 pages where everything is everywhere on all pages and I can't have a clue for this. Is anyone willing to help me out here ? require_once('tcpdf/config/lang/eng.php'); require_once('tcpdf/tcpdf.php'); class MYPDF extends TCPDF { public function Header() { $this->setJPEGQuality(90); $this->Image('logo.png', 120, 10, 75, 0, 'PNG', 'http://www.finalwebsites.com'); } public function Footer() { $this->SetY(-15); $this->SetFont(PDF_FONT_NAME_MAIN, 'I', ; $this->Cell(0, 10, 'finalwebsites.com - PHP Script Resource, PHP classes and code for web developer', 0, false, 'C'); } public function CreateTextBox($textval, $x = 0, $y, $width = 0, $height = 10, $fontsize = 10, $fontstyle = '', $align = 'L') { $this->SetXY($x+20, $y); // 20 = margin left $this->SetFont(PDF_FONT_NAME_MAIN, $fontstyle, $fontsize); $this->Cell($width, $height, $textval, 0, false, $align); } } // create a PDF object $pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // set document (meta) information $pdf->SetCreator(PDF_CREATOR); $pdf->SetAuthor('Olaf Lederer'); $pdf->SetTitle('TCPDF Example'); $pdf->SetSubject('TCPDF Tutorial'); $pdf->SetKeywords('TCPDF, PDF, example, tutorial'); // add a page $pdf->AddPage(); // create address box $pdf->CreateTextBox('Customer name Inc.', 0, 55, 80, 10, 10, 'B'); $pdf->CreateTextBox('Mr. Tom Cat', 0, 60, 80, 10, 10); $pdf->CreateTextBox('Street address', 0, 65, 80, 10, 10); $pdf->CreateTextBox('Zip, city name', 0, 70, 80, 10, 10); // invoice title / number $pdf->CreateTextBox('Invoice #201012345', 0, 90, 120, 20, 16); // date, order ref $pdf->CreateTextBox('Date: '.date('Y-m-d'), 0, 100, 0, 10, 10, '', 'R'); $pdf->CreateTextBox('Order ref.: #6765765', 0, 105, 0, 10, 10, '', 'R'); // list headers $pdf->CreateTextBox('Quantity', 0, 120, 20, 10, 10, 'B', 'C'); $pdf->CreateTextBox('Product or service', 20, 120, 90, 10, 10, 'B'); $pdf->CreateTextBox('Price', 110, 120, 30, 10, 10, 'B', 'R'); $pdf->CreateTextBox('Amount', 140, 120, 30, 10, 10, 'B', 'R'); $pdf->Line(20, 129, 195, 129); // some example data $orders[] = array('quant' => 5, 'descr' => '.com domain registration', 'price' => 9.95); $orders[] = array('quant' => 3, 'descr' => '.net domain name renewal', 'price' => 11.95); $orders[] = array('quant' => 1, 'descr' => 'SSL certificate 256-Byte encryption', 'price' => 99.95); $orders[] = array('quant' => 1, 'descr' => '25GB VPS Hosting, 200GB Bandwidth', 'price' => 19.95); $orders[] = array('quant' => 5, 'descr' => '.com domain registration', 'price' => 9.95); $orders[] = array('quant' => 3, 'descr' => '.net domain name renewal', 'price' => 11.95); $orders[] = array('quant' => 1, 'descr' => 'SSL certificate 256-Byte encryption', 'price' => 99.95); $orders[] = array('quant' => 1, 'descr' => '25GB VPS Hosting, 200GB Bandwidth', 'price' => 19.95); $orders[] = array('quant' => 5, 'descr' => '.com domain registration', 'price' => 9.95); $orders[] = array('quant' => 3, 'descr' => '.net domain name renewal', 'price' => 11.95); $orders[] = array('quant' => 1, 'descr' => 'SSL certificate 256-Byte encryption', 'price' => 99.95); $orders[] = array('quant' => 1, 'descr' => '25GB VPS Hosting, 200GB Bandwidth', 'price' => 19.95); $orders[] = array('quant' => 5, 'descr' => '.com domain registration', 'price' => 9.95); $orders[] = array('quant' => 3, 'descr' => '.net domain name renewal', 'price' => 11.95); $orders[] = array('quant' => 1, 'descr' => 'SSL certificate 256-Byte encryption', 'price' => 99.95); $orders[] = array('quant' => 1, 'descr' => '25GB VPS Hosting, 200GB Bandwidth', 'price' => 19.95); $orders[] = array('quant' => 5, 'descr' => '.com domain registration', 'price' => 9.95); $orders[] = array('quant' => 3, 'descr' => '.net domain name renewal', 'price' => 11.95); $orders[] = array('quant' => 1, 'descr' => 'SSL certificate 256-Byte encryption', 'price' => 99.95); $orders[] = array('quant' => 1, 'descr' => '25GB VPS Hosting, 200GB Bandwidth', 'price' => 19.95); $orders[] = array('quant' => 5, 'descr' => '.com domain registration', 'price' => 9.95); $orders[] = array('quant' => 3, 'descr' => '.net domain name renewal', 'price' => 11.95); $orders[] = array('quant' => 1, 'descr' => 'SSL certificate 256-Byte encryption', 'price' => 99.95); $orders[] = array('quant' => 1, 'descr' => '25GB VPS Hosting, 200GB Bandwidth', 'price' => 19.95); $orders[] = array('quant' => 5, 'descr' => '.com domain registration', 'price' => 9.95); $orders[] = array('quant' => 3, 'descr' => '.net domain name renewal', 'price' => 11.95); $orders[] = array('quant' => 1, 'descr' => 'SSL certificate 256-Byte encryption', 'price' => 99.95); $orders[] = array('quant' => 1, 'descr' => '25GB VPS Hosting, 200GB Bandwidth', 'price' => 19.95); $currY = 128; $total = 0; foreach ($orders as $row) { $pdf->CreateTextBox($row['quant'], 0, $currY, 20, 10, 10, '', 'C'); $pdf->CreateTextBox($row['descr'], 20, $currY, 90, 10, 10, ''); $pdf->CreateTextBox('$'.$row['price'], 110, $currY, 30, 10, 10, '', 'R'); $amount = $row['quant']*$row['price']; $pdf->CreateTextBox('$'.$amount, 140, $currY, 30, 10, 10, '', 'R'); $currY = $currY+5; $total = $total+$amount; } $pdf->Line(20, $currY+4, 195, $currY+4); // output the total row $pdf->CreateTextBox('Total', 20, $currY+5, 135, 10, 10, 'B', 'R'); $pdf->CreateTextBox('$'.number_format($total, 2, '.', ''), 140, $currY+5, 30, 10, 10, 'B', 'R'); // some payment instructions or information $pdf->setXY(20, $currY+30); $pdf->SetFont(PDF_FONT_NAME_MAIN, '', 10); $pdf->MultiCell(175, 10, '<em>Lorem ipsum dolor sit amet, consectetur adipiscing elit</em>. <br /> Vestibulum sagittis venenatis urna, in pellentesque ipsum pulvinar eu. In nec <a href="http://www.google.com/">nulla libero</a>, eu sagittis diam. Aenean egestas pharetra urna, et tristique metus egestas nec. Aliquam erat volutpat. Fusce pretium dapibus tellus.', 0, 'L', 0, 1, '', '', true, null, true); //Close and output PDF document $pdf->Output('test.pdf', 'F');
  2. Hi, I found a very nice script for saving my TwitPic images in full size. I have tested this script for a couple of times yesterday and it seems that this way of saving images is now blocked by amazon or TwitPic. Using the API it's not possible to download the images as fas I can see, does anyone has an idea ? http://forrst.com/posts/TwitPic_Hack_Get_Full_TwitPic_Image_using_PHP-mFQ <?php function imgResize($width, $height, $target) { if ($width > $height) { $percentage = ($target / $width); } else { $percentage = ($target / $height); } $width = round($width * $percentage); $height = round($height * $percentage); return "width=\"$width\" height=\"$height\""; } // full url of the TwitPic photo $url = "http://twitpic.com/1pfhfd"; // make the cURL request to TwitPic URL $curl2 = curl_init(); curl_setopt($curl2, CURLOPT_URL, $url); curl_setopt($curl2, CURLOPT_AUTOREFERER, true); curl_setopt($curl2, CURLOPT_RETURNTRANSFER,true); curl_setopt($curl2, CURLOPT_TIMEOUT, 10); $html = curl_exec($curl2); $HttpCode = curl_getinfo($curl2, CURLINFO_HTTP_CODE); $totalTime = curl_getinfo($curl2, CURLINFO_TOTAL_TIME); // if the HTTPCode is not 200 - you got issues if ($HttpCode != 200) { ?><p>Unable to connect to TwitPic. Please try again later.</p><? } else { // if you are not getting any HTML returned, you got another issue. if ($html == "") { ?><p>Yikes! TwitPic is experiencing heavy load. Please close this window and try again.</p><? } else { $dom = new DOMDocument(); @$dom->loadHTML($html); // grab all the on the page $xpath = new DOMXPath($dom); $hrefs = $xpath->evaluate("/html/body//img"); foreach( $hrefs as $href ) { $url = $href->getAttribute('id'); // for all the images on the page find the one with the ID of photo-display if ($url == "photo-display") { // get the SRC attribute of the element with the ID of photo-display $image = $href->getAttribute('src'); // get the image size $imagesize = getimagesize($image); ?> <a href="<? echo $url; ?>" target="_blank"><img class="twitpic" src="<? echo $image; ?>" "<? echo imgResize($imagesize[0], $imagesize[1], 450); ?>"></a> <? break; } } } } ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.