The Code-Bin
Links
Home
Add your code!
All Listings
About
Latest Entry
Featured Scripts
Author's Website
Latest Entries
FFMPEG Thumbnail Scr...
PHP, 0.8KB
Jul. 29, 10:24pm
John
Z80 Assembler, 190 bytes
Feb. 17, 3:36am
John
Z80 Assembler, 176 bytes
Sep. 13, 2:19am
John
Z80 Assembler, 77 bytes
Sep. 13, 2:18am
John
Z80 Assembler, 209 bytes
Sep. 13, 2:17am
Create PDF document
Posted by: PDF_Doc | July 27, 2008 @ 10:59am
PHP Code
[
Download
]
<?php session_start(); // Connection to database include "./includes/config.php"; // Gets data from database $result = mysql_query("SELECT department, name, address, city, phone FROM stores ORDER BY department ASC LIMIT 1"); // Create PDF document $pdf = pdf_new(); // Open the PDF document pdf_open_file($pdf,"C:\PDF_Doc.pdf"); // Set info pdf_set_info($pdf, "Author", "My name"); pdf_set_info($pdf, "Title", "Database"); pdf_set_info($pdf, "Creator", "My name"); pdf_set_info($pdf, "Subject", "Database"); // Create page (A4) pdf_begin_page($pdf, 595, 842); // Set fonts $font1 = PDF_load_font($pdf, "Courier-Bold","iso8859-1", ""); $font2 = PDF_load_font($pdf, "Courier","iso8859-1", ""); // Set position of Y $y = 735; // Line top pdf_setlinewidth($pdf, 1); pdf_moveto($pdf, 20, 780); pdf_lineto($pdf, 575, 780); pdf_stroke($pdf); // Line bottom pdf_setlinewidth($pdf, 1); pdf_moveto($pdf, 20, 50); pdf_lineto($pdf, 575, 50); pdf_stroke($pdf); // Line horizontal (1) pdf_setlinewidth($pdf, 0.1); pdf_moveto($pdf, 48, 760); pdf_lineto($pdf, 557, 760); pdf_stroke($pdf); // Line horizontal (2) pdf_setlinewidth($pdf, 0.1); pdf_moveto($pdf, 48, 745); pdf_lineto($pdf, 557, 745); pdf_stroke($pdf); // Line horizontal (3) pdf_setlinewidth($pdf, 0.1); pdf_moveto($pdf, 48, 70); pdf_lineto($pdf, 557, 70); pdf_stroke($pdf); // Line vertical (1) pdf_setlinewidth($pdf, 0.1); pdf_moveto($pdf, 48, 70); pdf_lineto($pdf, 48, 760); pdf_stroke($pdf); // Line vertical (2) pdf_setlinewidth($pdf, 0.1); pdf_moveto($pdf, 107, 70); pdf_lineto($pdf, 107, 760); pdf_stroke($pdf); // Line vertical (3) pdf_setlinewidth($pdf, 0.1); pdf_moveto($pdf, 233, 70); pdf_lineto($pdf, 233, 760); pdf_stroke($pdf); // Line vertical (4) pdf_setlinewidth($pdf, 0.1); pdf_moveto($pdf, 373, 70); pdf_lineto($pdf, 373, 760); pdf_stroke($pdf); // Line vertical (5) pdf_setlinewidth($pdf, 0.1); pdf_moveto($pdf, 473, 70); pdf_lineto($pdf, 473, 760); pdf_stroke($pdf); // Line vertical (6) pdf_setlinewidth($pdf, 0.1); pdf_moveto($pdf, 557, 70); pdf_lineto($pdf, 557, 760); pdf_stroke($pdf); // Header pdf_setfont($pdf, $font1, 18); pdf_show_xy($pdf, "Company name", 50, 795); // Static text pdf_setfont($pdf, $font1, 9); pdf_show_xy($pdf, "Department", 50, 750); pdf_show_xy($pdf, "Store name", 109, 750); pdf_show_xy($pdf, "Addresse", 235, 750); pdf_show_xy($pdf, "City", 375, 750); pdf_show_xy($pdf, "Phone", 475, 750); // Dynamic text pdf_setfont($pdf, $font2, 8); while ($row = mysql_fetch_array($result )) { pdf_show_xy($pdf, $row['department'], 70, $y); pdf_show_xy($pdf, $row['department'], 70, $y - 15); pdf_show_xy($pdf, $row['department'], 70, $y - 30); pdf_show_xy($pdf, $row['department'], 70, $y - 45); pdf_show_xy($pdf, $row['name'], 109, $y); pdf_show_xy($pdf, $row['name'], 109, $y - 15); pdf_show_xy($pdf, $row['name'], 109, $y - 30); pdf_show_xy($pdf, $row['name'], 109, $y - 45); pdf_show_xy($pdf, $row['address'], 235, $y); pdf_show_xy($pdf, $row['address'], 235, $y - 15); pdf_show_xy($pdf, $row['address'], 235, $y - 30); pdf_show_xy($pdf, $row['address'], 235, $y - 45); pdf_show_xy($pdf, $row['city'], 375, $y); pdf_show_xy($pdf, $row['city'], 375, $y - 15); pdf_show_xy($pdf, $row['city'], 375, $y - 30); pdf_show_xy($pdf, $row['city'], 375, $y - 45); pdf_show_xy($pdf, $row['phone'], 475, $y); pdf_show_xy($pdf, $row['phone'], 475, $y - 15); pdf_show_xy($pdf, $row['phone'], 475, $y - 30); pdf_show_xy($pdf, $row['phone'], 475, $y - 45); } // Save page pdf_end_page($pdf); // Save & exit pdf_close($pdf); pdf_delete($pdf); ?> // Get open/save dialog <?php header ('Content-Description: File Transfer'); header ('Content-Type: application/octet-stream'); header ('Content-Transfer-Encoding: binary'); header ('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header ('Content-Disposition: attachment; filename="' . $filename . '";'); header ('Content-Length: ' . filesize ($filepath)); header ('Content-type: application/pdf'); header ('Content-Disposition: attachment; filename="PDF_Doc.pdf"'); readfile ('c:\PDF_Doc.pdf'); ?>
Syntax Highlighting
[
Open in new window
]
Author Comments
none
Rating
4.39 / 8
190 Votes
http://codebin.yi.org/172
page generated in 0.01 seconds