Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Web Coding › adding image into pdf with php
New Posts  All Forums:Forum Nav:

adding image into pdf with php

post #1 of 5
Thread Starter 
Hee guys could you help me with this.

Im trying to make an automatic pdf generator for on a site, but im stuck at adding an image that was submidded on the website to a pdf file.

here is some code
Warning: Spoiler! (Click to show)
Code:
<html>
        <head>
                <title>Stichting Veilig Online</title>
        </head>
        <body>
                <form name="internetprotocol" action="internetprotocol.php" method="POST">
                        Uw naam
                        <p><input type="text" name="naam" value="" size="30"/></p>
                        Uw emailadres
                        <p><input type="text" name="emailadres" value="" size="30"/></p>
                        Volledige naam van de school
                        <p><input type="text" name="naamSchool" value="" size="30"/></p>
                        Logo van de school
                        <p><input type="file" name="logoSchool" value="" size="30"/></p>
                        Adres van de school
                        <p><textarea rows="4" cols="50" name="textbox"></textarea></p>
                        Website van de school
                        <p><input type="text" name="websiteSchool" value="" size="30"/></p>
                        Overig
                        <p><input type="text" name="Overig" value="" size="30"/></p>
                        <br/>
                        Vul bovenstaande vier karakters hieronder in(spambestrijding)
                        <p><input type="text" name="karakters" value="" size="30"/></p>
                        <input type="submit" name="verzenden" value="verzenden"/>
                </form>
        </body>
</html>
Warning: Spoiler! (Click to show)
Code:
<html>
<head>
        <title>internetprotocol</title>
</head>
<body>
        <h3>Account aangemaakt</h3>
<?php
require ('C:\xampp\php\pear\fpdf\fpdf.php');
        $pdf = new FPDF('P', 'mm', 'A4');
        
                        if(!empty($_POST['naam']) || !empty($_POST['emailadres']) || !empty($_POST['naamSchool']) || !empty($_POST['websiteSchool']) || !empty($_POST['Overig']) || !empty($_POST['karakters']))
                        {
                                $x = 50;
                                $tekst = $_POST["naam"] . "\t" . $_POST["emailadres"] . "\t" . $_POST["naamSchool"] . "\t" . $_POST["websiteSchool"] . "\t" . $_POST['logoSchool'] . "\t" . $_POST["Overig"] . "\t" . $_POST["karakters"] . "\n";
                                
                                $pdf->SetFont('Times','B', 24);
                                $pdf->addPage();
                                $pdf->SetXY($x,50);
                        }
                                $pdf->write(25,$tekst);
                                $pdf->Output('Gegevens.pdf','F');
                                
                                if($pdf) 
                                {
                                        $pdf = file_get_contents('Gegevens.pdf');
                                        header('Content-Type: application/pdf');
                                        header('Content-Disposition: attachment; filename="Gegevens.pdf"');
                                        header('Content-Length: ' . strlen($pdf));
                                        echo $pdf;
                                }
                        else
                        {
                                if(isset($_POST['verzenden']))
                                {
                                        echo "<script>";
                                        echo "alert('alle velden moet ingevuld zijn')";
                                        echo "</script>";
                                        echo "PDF is niet aangemaakt";
                                }
                        }       
                ?>
</body>
</html>

Thanks in advance
The Frost Stryker
(19 items)
 
 
Core 2 Quad FTW
(17 items)
 
CPUMotherboardGraphicsRAM
i7 4770k 4.5ghz Sabertooth Z87 MSI GTX 660ti Power Edition 2x4 G.Skill Sniper 1866mhz cl9 
Hard DriveHard DriveCoolingOS
Samsung 840 120gb Seagate 7200.14 2tb Corsair H100i Windows 7 Professional N 
MonitorMonitorKeyboardPower
Acer S271HLCbid Acer AL1716FB Logitech G510 Corsair AX760 
CaseMouseMouse PadAudio
CM Storm Stryker SteelSeries Raw Sensei Frostblue RSI Origin Goliath Mousepad SteelSeries Siberia v2 FrostBlue 
AudioOtherOther
Grundig 2.1 Blue led Stereo Artic MX4 2x50cm White Ledstrips 
CPUMotherboardGraphicsRAM
Core 2 Quad q6600 EVGA 780i SLI EVGA GTX 550TI 2gb 2x2 gb Geil blackdragon evo one 800mhz 
RAMHard DriveOptical DriveCooling
2x 2 gb kingston 800mhz Western Digital WD5000AAKS LG GH24NS70 Coolermaster V8 
OSMonitorKeyboardPower
Windows 8 Pro HP LP2275W Sharkoon Skiller Sharkoon WPM500 
CaseMouseAudioAudio
Zalman Z11 Hama uRage Creative Sound Blaster Tactic 3D Alpha X union Stereo speakers 
Other
Artic silver MX-4 
  hide details  
Reply
The Frost Stryker
(19 items)
 
 
Core 2 Quad FTW
(17 items)
 
CPUMotherboardGraphicsRAM
i7 4770k 4.5ghz Sabertooth Z87 MSI GTX 660ti Power Edition 2x4 G.Skill Sniper 1866mhz cl9 
Hard DriveHard DriveCoolingOS
Samsung 840 120gb Seagate 7200.14 2tb Corsair H100i Windows 7 Professional N 
MonitorMonitorKeyboardPower
Acer S271HLCbid Acer AL1716FB Logitech G510 Corsair AX760 
CaseMouseMouse PadAudio
CM Storm Stryker SteelSeries Raw Sensei Frostblue RSI Origin Goliath Mousepad SteelSeries Siberia v2 FrostBlue 
AudioOtherOther
Grundig 2.1 Blue led Stereo Artic MX4 2x50cm White Ledstrips 
CPUMotherboardGraphicsRAM
Core 2 Quad q6600 EVGA 780i SLI EVGA GTX 550TI 2gb 2x2 gb Geil blackdragon evo one 800mhz 
RAMHard DriveOptical DriveCooling
2x 2 gb kingston 800mhz Western Digital WD5000AAKS LG GH24NS70 Coolermaster V8 
OSMonitorKeyboardPower
Windows 8 Pro HP LP2275W Sharkoon Skiller Sharkoon WPM500 
CaseMouseAudioAudio
Zalman Z11 Hama uRage Creative Sound Blaster Tactic 3D Alpha X union Stereo speakers 
Other
Artic silver MX-4 
  hide details  
Reply
post #2 of 5
Cant see where in the code you are adding the image? Unless thats part of the question - looking at the docs though you would prob need to add the following in after the $tekst = line;
Code:
// Insert a logo in the top-left corner at 300 dpi
$pdf->Image('path_to/image.png',10,10,-300);

The full details are here http://www.fpdf.org/en/doc/image.htm which gives the usage.

You will need to add an upload box to the form as well, and store that image somewhere on the web server.
post #3 of 5
Thread Starter 
Thank you upahill, it already got solved. I let someone else use my account and i only looked through the code for a few seconds.
But the real problem was that he didnt even add the part to upload the image to the server. And that was the missing part.
The Frost Stryker
(19 items)
 
 
Core 2 Quad FTW
(17 items)
 
CPUMotherboardGraphicsRAM
i7 4770k 4.5ghz Sabertooth Z87 MSI GTX 660ti Power Edition 2x4 G.Skill Sniper 1866mhz cl9 
Hard DriveHard DriveCoolingOS
Samsung 840 120gb Seagate 7200.14 2tb Corsair H100i Windows 7 Professional N 
MonitorMonitorKeyboardPower
Acer S271HLCbid Acer AL1716FB Logitech G510 Corsair AX760 
CaseMouseMouse PadAudio
CM Storm Stryker SteelSeries Raw Sensei Frostblue RSI Origin Goliath Mousepad SteelSeries Siberia v2 FrostBlue 
AudioOtherOther
Grundig 2.1 Blue led Stereo Artic MX4 2x50cm White Ledstrips 
CPUMotherboardGraphicsRAM
Core 2 Quad q6600 EVGA 780i SLI EVGA GTX 550TI 2gb 2x2 gb Geil blackdragon evo one 800mhz 
RAMHard DriveOptical DriveCooling
2x 2 gb kingston 800mhz Western Digital WD5000AAKS LG GH24NS70 Coolermaster V8 
OSMonitorKeyboardPower
Windows 8 Pro HP LP2275W Sharkoon Skiller Sharkoon WPM500 
CaseMouseAudioAudio
Zalman Z11 Hama uRage Creative Sound Blaster Tactic 3D Alpha X union Stereo speakers 
Other
Artic silver MX-4 
  hide details  
Reply
The Frost Stryker
(19 items)
 
 
Core 2 Quad FTW
(17 items)
 
CPUMotherboardGraphicsRAM
i7 4770k 4.5ghz Sabertooth Z87 MSI GTX 660ti Power Edition 2x4 G.Skill Sniper 1866mhz cl9 
Hard DriveHard DriveCoolingOS
Samsung 840 120gb Seagate 7200.14 2tb Corsair H100i Windows 7 Professional N 
MonitorMonitorKeyboardPower
Acer S271HLCbid Acer AL1716FB Logitech G510 Corsair AX760 
CaseMouseMouse PadAudio
CM Storm Stryker SteelSeries Raw Sensei Frostblue RSI Origin Goliath Mousepad SteelSeries Siberia v2 FrostBlue 
AudioOtherOther
Grundig 2.1 Blue led Stereo Artic MX4 2x50cm White Ledstrips 
CPUMotherboardGraphicsRAM
Core 2 Quad q6600 EVGA 780i SLI EVGA GTX 550TI 2gb 2x2 gb Geil blackdragon evo one 800mhz 
RAMHard DriveOptical DriveCooling
2x 2 gb kingston 800mhz Western Digital WD5000AAKS LG GH24NS70 Coolermaster V8 
OSMonitorKeyboardPower
Windows 8 Pro HP LP2275W Sharkoon Skiller Sharkoon WPM500 
CaseMouseAudioAudio
Zalman Z11 Hama uRage Creative Sound Blaster Tactic 3D Alpha X union Stereo speakers 
Other
Artic silver MX-4 
  hide details  
Reply
post #4 of 5
hehe no problem, glad its all sorted smile.gif
post #5 of 5
Hi,
I have never tried to add image into PDF using the code. But I think you can also google it and select a professional
PDF editor or image processor whose way of processing is simple and fast to help you with the related work. It will be better if it is totally manual and can be customized by users according to our own favors. Remember to check its free trial package first if possible. I hope you success. Good luck.



Best regards,
Arron
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Web Coding
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Web Coding › adding image into pdf with php