PHP - Advice Needed On Printing High Quality Graphics In Pdfs Generated By Php
I'm having a mini application developed to create A4 PDF's using PHP
A key part of the project needs to be able to insert high quality graphics into the document that when printed out look really sharp Some of the graphics are variable and don't always have to be printed I just wanted to know if there was a general guide on what graphics and quality to use? The graphics I need printed print really well when put into a Word document at 300 resolution - so I can't see why there should be any problems inserting into a PDF - these graphics are PNG ones Unfortunately, if I insert the same PNG format into the PDF via the PHP code, the graphic turns out to be REALLY big Just looking for advice Thanks OM Similar TutorialsHello everyone. I have been told that PHP, javascript and html would be needed for this. So I am here to explain and ask your advice. Since being severely disabled in a car accident, I am trying to make use of what I have left. I would like to use my knowledge and try to help those who want to get back to work. I will give my time for free but the cost of using council premises must be paid for, albeit heavily subsedised by the benefits department. I will need a single page. It will need a datepicker (so I am told) where students can see what days are available and then select their chosen dates and complete their details. Then, the system will make some calculations and send me an email with the details that I can add to official paperwork and email on, to the student, the benefits department and the local council. I would also like to be able to "log in" to the page, to put the details in myself and still to send me the email with the details, as before. Should I explain everything I am trying to achieve, in one post, or can someone advise me as to which parts need which code and make separate posts in the corresponding threads? I am trying to study as much as possible and am finding this forum a great help. But, a little help or guidance in the right direction would be great. Thank you, in advance, for your help Chapter 2 homework is coded. It works and that is the main thing, but I dont just want the grade, I want want to learn php and be proficent at it. Is there anything that looks wrong, Variable names, lack off comments, things out of place. All advice is welcome.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "html://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Temperature Conversion</title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> </head> <body> <h1>Fahrenheit to Celsius Conversions</h1> <article> <?php $degFahrenheit = 0; function degreeConverter ($degFahrenheit) { //Function converts F* to C* $degCelsius = (($degFahrenheit - 32) * 5/9); $returnCelsius = round ($degCelsius, 1); return $returnCelsius; } do {//begining of loop $convertCelsius = degreeConverter($degFahrenheit); echo "<p>$degFahrenheit degrees Fahrenheit = $convertCelsius degrees Celsius.</p>"; ++degFahrenheit; } while ($degFahrenheit <= 100);//end of loop ?> </article> </body> </html> Hello Everyone, I want to create my own Mafia game such as, "Infamous Gangsters" have i come to the right place Basically im new to PHP coding and i want to know a list of things before i start to learn 1.) Does it cost to create a website such as: Infamousgangsters.com? 2.) How long does it take to learn PHP coding before i have enough experience to create one? 3) Does anyone have any useful documents on PHP coding which i can read to learn basic knowledge? Many Thanks, Providence I am relatively new to PHP, trying to learn more every day. I have been enjoying using Server Side Includes in my sidebars, footer etc with good results, much handier and more efficient! I would like to do the same for the header and main site navigation. However, the main problem that I am not sure how to deal with comes from having 'active' links (differently coloured menu tab for the page the user is on) in my menu. Here is a small menu example: Code: [Select] <div class="menu"> <ul> <li><a href="nav.php" class="active">Home</a></li> <li><a href="nav2.php">About</a></li> <li><a href="products1.php">Products</a></li> <li><a href="products2.php">Products 2</a></li> <li><a href="products3.php">Products 3</a></li> </ul> </div> When the user is on the Home page, the class is set to active - i.e. a different colour. If I do a simple server side include with my navigation this will of course be across all the pages. Can anyone please advise on what I need to do to make the menu work correctly across all the pages? (have different tabs selected for each respective page). Any help / insight is much appreciated. I am after some advice about doing some rather basic things that wouldnt really be done in OOP and see if there's a better way of doing this. As I just said though I know this is not the required system just one displaying of a form but I think its really cool for just simplying OOP ( ), and I actually understand it, I always need to start off small, understand it all, before I start waffling will show you my code (in no way finished yet, as you can tell from some of the html elements but its principle works: <?php ini_set('display_errors',1); class Form{ public $to; public $user; public $email; public $subject; public $comment; function showForm(){ // displaying of form to the user: echo <<<userform <html> <head> <title>Jez's Contact Form</title> </head> <body> <form id="contact" name="contact" method="post" action="{$_SERVER['PHP_SELF']}"> <label for="">Enter something:</label><input type="text" id="user" </form> </body> </html> userform; } } if(!array_key_exists('submit',$_POST)) { $myForm = new Form; // now we construct the form: $myForm->showForm(); // print_r($myForm); } ?> If a submit button in the form hasnt been hit, then show form, later on going to do and try out some validation, just wanted some advice before I get too big for my boots as such. Any advice on improving it (obviously finishing my form off of course which is what I will do), but any further advice is greatly appreciated, Jez. I am creating a site to display some products. For ease of updating I want it to run off a MySQL database. I have created the database and php scripts to output and input data etc. I know want to show that data in my web pages. My question is.... Is it best to insert HTML into the php output script to display the information and make the site look how I want....OR ....... should I create a template of the site in HTML and then somehow call the php output script (and the particular row of the database...) Basically... should I put the html code into the php - OR - put the php into the HTML?? I hope this make sense...... thanks Hello. I was wondering if there is any way to remove the white pixels from around a transparent png image? When I use imageimagecopymerge to place a transparent PNG on top of another image with a dark background, the top image has a few white pixels around the border. Is there any way to remove these white pixels? I attached an example of the image with the white pixels. Thanks I have 64 rows of players and want each User to be able to choose to bookmark an player, as well as unbookmark it too. I have a bookmark table set up, and each time a User decides to bookmark(+) or unbookmark(-) an player a row is created in the data table. (Matching the player ID and User ID) That's working fine. A query reads the most recent row for each player to determine if there is a + or - button next to each player. Testing the query and adding some dummy data, that part of it works too. However, the issue is the initial state, which I want to be a +. Once I go live, the table will be empty, nothing for the query to return/produce. How do I create an initial state of a + with no rows and have it not used or swapped out when Users start clicking + or -?
$query = "SELECT b.id, bookmark,playerID,userID,p.id FROM a_player_bookmark b LEFT JOIN a_players p ON '". $id ."' = playerID WHERE userID = '". $userID ."'&&'". $id ."' = playerID ORDER BY b.id desc LIMIT 1 "; $results = mysqli_query($con,$query); echo mysqli_error($con); while($row = mysqli_fetch_assoc($results)) { echo $row['bookmark']; if($row['bookmark'] == 0) { echo '-'; // this is where a form goes to remove a bookmark } else { echo '+'; // this is where a form goes to add a bookmark } } I tried to get it with CASE, but I don't think that's the right path. I also looked at UNION. I was able to get it to produce an initial state of +, but it still printed the already made up sample data too (so I have three instances of ++ or +-). (Players 2, 4 and 4)
Here is the what the UNION query looked like: $query = "(SELECT b.id, bookmark,playerID,userID,p.id FROM a_player_bookmark b LEFT JOIN a_players p ON '". $id ."' = playerID WHERE userID = '". $userID ."'&&'". $id ."' = playerID ORDER BY b.id desc LIMIT 1) UNION (SELECT b.id, bookmark,playerID,userID,p.id FROM a_player_bookmark b LEFT JOIN a_players p ON '". $id ."' = playerID WHERE userID = '". $userID ."' ORDER BY p.id desc LIMIT 1) ";
So. I'm using this code right he <?php $imagepath = "css/images/statspage.jpg"; $image = imagecreatefromjpeg($imagepath); $imgheight = imagesy($image); $color = imagecolorallocate($image, 255, 255, 255); imagestring($image, 5, 70, $imgheight-50, "This is a test", $color); header('Content-Type: image/jpeg'); imagejpeg($image); ?> It works like it should. Now my problem is, is that the image is being displayed at a very low quality! Here's the original image: Here's the image with the code above: RIGHT away you can tell the HUGE difference. I'm not sure what I'm doing wrong. Maybe i need a higher res image? If y'all guys know a different method THAT also achieves the same thing I'm trying to do. Please let me know ASAP! I haven't worked with TCPDF yet (PHP class for creating PDFs) but if anyone has, I'm just curious if you can reference an external CSS file to format the HTML that gets created in the PDF? Or can you only use inline CSS? Basically, I have a nicely formatted HTML table using a somewhat complicated external CSS file and I want to output that same table to a PDF and have it look essentially the same. If TCPDF cannot do this, do you know of any other PDF PHP libraries that can? Thanks, Greg
Hi, I have a table of content in my page. For each row it has a check box. How do i achieve the function of when i click on submit button, those rows which are checked will be downloaded as a single pdf file. For example, for each checked row is a PDF file here. Suppose if i checked for 5 rows , 5 PDFs will be downloaded. This topic has been moved to Other Libraries and Frameworks. http://www.phpfreaks.com/forums/index.php?topic=321311.0 Hi, I am tryng to use the gd functions in php to output an image of a lower quality and save it as another image: Code: [Select] header('Content-Type: image/jpeg'); $im = @imagecreatefromjpeg('SDC10424.JPG'); imagejpeg($im, null, 50);// this line lowers the image quality imagedestroy($im); but the problem is how to save it? I tried file_put_contents, but it didnt work, like fileputcontents("test.jpg", $im); Hi all, I am creating a thumbnail from an uploaded image (in this case a company logo). The problem is that the thumbnail image is poor quality and not fit to display on the website! I have attached the uploaded image and then then generated thumbnail, so you can see how much it is degrading. I always want the thumb to be the same size, which is 129pxx44px. I have included the thumb generation part of my script below: // This is declared at the start of the script $tdir = "images/agencylogos/thumbs/"; $twidth = "129"; $theight = "44"; // This is the actual part of the script that does the resizing $simg = imagecreatefromjpeg($newname); $currwidth = imagesx($simg); $currheight = imagesy($simg); if ($currheight > $currwidth) { $zoom = $twidth / $currheight; $newheight = $theight; $newwidth = $currwidth * $zoom; } else { $zoom = $twidth / $currwidth; $newwidth = $twidth; $newheight = $currheight * $zoom; } $dimg = imagecreate($newwidth, $newheight); imagetruecolortopalette($simg, false, 256); $palsize = ImageColorsTotal($simg); imagecopyresized($dimg, $simg, 0, 0, 0, 0, $newwidth, $newheight, $currwidth, $currheight); // Copy Resized Image To The New Image (So We Can Save It) imagejpeg($dimg, "$tdir" . $image_name, 100); imagedestroy($simg); imagedestroy($dimg); Can anyone see any ways of improving this script so that it would make the thumb image better quality? Many thanks, Greens85 Hello, I hope you guys can help me out (at least point me in the write direction) - I am very green and am trying to work my way thru this as best I can - I am not a programmer, But am trying to learn a few things to make this task easier I run an fantasy soccer site - And right now all the stats are stored in excel files (manually updated) and then exported to csv files - I have a php file that turns them into a table and shows the results.. http://tonyarmer.net...GA/Valencia.php (as you see it outputs the page with the csv information. Now this is all fine (but a lot of work) as every week the numbers change and they have to be added in the excel file and updated and re-exported - My question is in 2 parts... First part - The rows that show up in the link above are constant and unchanging - the numbers in those rows will update and change all the time, as a game is played the associated numbers will have to be added to to update the player statistics. I have thought about putting all this in mySQL and updating it that way and trying to pull from the database - I see what I could use as the tables (from what is listed in the csv file) but not sure the direction to take there (any thoughts) Second Part (I have posted the code below) - This is a very poorly written piece of code but it does work - What I am trying to figure out is, How can I re-write (or add) to the code to make the player name as a clickable link that will take you to another page that shows more detail, City of birth, height, weight and I would move the stats to this page as well - Now I know doing this in mySQL would help (If I had any idea of what to do, which would include adding the weekly stats together to get totals).... But how could this be handled in just php with a csv file - ANY HELP would be greatly appreciated <body> <body style="background-color: transparent;"> <table border="0" width="100%" cellspacing="1" cellpadding="2" bgcolor=" 1F4B6B" > <tr>'; echo '<tr>'; // put exploded first line in as <th> element for ($j = 0; $j <= $columns; $j++) { $data[$j] = str_replace('"','',$data[$j]); echo '<th>' . $data[$j] . '</th>'; } // end first table row echo '</tr>'; $win = 0; // run through remaining lines for ($i = 1; $i <= sizeof($lines)-1; $i++) { // explode line $data = explode(",", $lines[$i]); // start new row echo '<tr class="' . $bg[$win] . '">'; // put exploded data in as <td> element for ($j = 0; $j <= $columns; $j++) { $data[$j] = str_replace('"','',$data[$j]); if ($j == 0) echo '<td><img src="' . $flag_dir . $countries[$data[$j]] . '.jpg" alt="' . $data[$j] . '" /></td>'; else echo '<td>' . $data[$j] . '</td>'; } // end row echo '</tr>'; $win == 1 ? $win = 0 : $win = 1; } // close table tag echo '</table>'; ?> <hr> <H2>CUPS</H2> <img src='http://www.tonyarmer.net/WSL/LIGA/55.png' /></a> Champions Cup x0 <img src='http://www.tonyarmer.net/WSL/LIGA/1.png' /></a>WSL Cup x0 <img src='http://www.tonyarmer.net/WSL/LIGA/cltrophy.png' /></a>Liga Cup x0 <hr> Hello, On my website I wish to have a simple graphic and allow users to write their own text onto the graphic then they can save out the graphic. I'm new to PHP so I'm not that good at it. I've done some research and I think I need to use the GD library. Is this correct? What would be the easiest way to do what I want? Thanks I successfully load a page by simple_html_dom.php (developed in simplehtmldom.sourceforge.net) as $html = file_get_html('externalpage'); But sometimes this make a high load on CPU and the page does not load for a long time (probably due to the external site server). How can I skip the process when it is not normal to avoid high CPU usage? ok so i want to order by high to low on the field price but i don't know how to do this. i can order low to high by using ORDER BY `Price` ASC but how can i order high to low? I try to get a high score system to work. The problem is to write data to the txt file: The file adder.php contains: <?php if(array_key_exists('name',$_GET)==true and array_key_exists('score',$_GET)==true) { $name=$_GET['name']; $score=$_GET['score']; $file=fopen('highscore.txt','a'); fwrite($file,$name.';'.$score.';'); fclose($file); } header("Location: index.php"); // Replace index.php with the name (and, if not in the same folder, path) // of the page that will display the scores (see below) ?> I use this website: http://members.multimania.nl, so it looks like http://members.multimania.nl/mine/adder.php?name=winner&score=99 What am I doing wrong? I have just did this php code for the high-low game but the $tries variable always goes down to 0 when I refresh..Can someone help me to return the $tries to browser with the url? Thank you
<html>
<?php function High_Low($guess){
|