I am currently using html2pdf to convert a document in my company to PHP, to be able to include my variables afterwards and save it as a pdf,
the problem is currently with my "div M1,M2,M3".
I make it align with "#M1,#M2,#M3{display: inline;}"
however I feel that my M2 "TEL:" is based on the top frame, rather than on the M1
$html = '<img src="logoTCSfinal.png" class="tcs" style="width:10%;margin-
left:20px;margin-right: 550px;">
<img src="ICSL.png" class="ics" style="width:10%;"><br>
<div style="width: 100%;padding-left:2px;padding-top:2px;font-weight: 600;padding-
bottom:2px;border: 3px solid #000000; text-align: left;">DEFINITION DES BESOINS</div>
<style>#M1,#M2,#M3{display: inline;}</style>
<div id="M1" style="padding-left:5px;padding-top: 10px;font-weight: 600;">SOCIETE:
</div>
<div id="M2" style="clear: both;font-weight: 600;">TEL:</div>
<div id="M3" style="font-weight: 600;">FAX:</div>';
$html2pdf = new Html2Pdf();
$html2pdf->writeHTML($html);
$html2pdf->output();
?>
but
however it displays it to me like
this
Related
I have php string like this :
$text = '<p>Artikel 20 November 2015,</p>
<p style="text-align: center;"><img src="../../../fileman/Uploads/Karangan Bunga Launching MD/Concert of Ari Lasso/Other/press conference/pers release/P_20151123_141352 - Copy 1.jpg" alt="" removed="" block="" auto="" margin-left:="" margin-right:="" width="723" height="1000" /></p>
<p style="text-align: left;">Artikel 21 November 2015,</p>
<p style="text-align: left;"><img src="../../../fileman/Uploads/Karangan Bunga Launching MD/Concert of Ari Lasso/Other/press conference/pers release/P_20151123_141312.jpg" alt="" style="display: block; margin-left: auto; margin-right: auto;" width="646" height="1000" /></p>';
I just want to take .jpg file from that string (ex: P_20151123_141352 - Copy 1.jpg & P_20151123_141312.jpg). I already try using preg_match_all but it did'nt work, maybe I just used wrong logic. Help me please :)
I have the following piece of code in php where I was trying to apply jquery slideToggle() for each youtube video presentation. My problem is that jquery slideToggle() works only for my first youtube video presentation inside my while statement. The rest of them are not working. Any idea how to fix this?
<style>
#flip
{
padding:0px;
}
#panel
{
width:475px;
margin-left:3px;
margin-bottom:5px;
padding:4px;
display:none;
box-shadow: 0 0 20px rgba(0, 30, 10, 2.8);
-webkit-box-shadow: 0 0 20px rgba(0, 10, 0, 2.8);
-moz-box-shadow: 0 0 20px rgba(0, 10, 0, 2.8);
background-color:#363636;
}
</style>
<script>
$(document).ready(function(){
$("#flip").click(function(){
$("#panel").slideToggle("slow");
});
});
</script>
<?php
// above code
//next starts the while and outputs from my table all rows that contains users posts
// my code outputs all youtube links in a presentation format
while(){
$row['comment'] = preg_replace("/\s*[a-zA-Z\/\/:\.]*youtube.com\/watch\?v=([a-zA-Z0-9\-_]+)([a-zA-Z0-9\/\*\-\_\?\&\;\%\=\.]*)/i", "</br>
<div id='panel'>
<object width=\"0px;\" height=\"0px;\">
<param name=\"movie\" value=\"http://www.youtube.com/v/$1&hl=en&fs=1\"></param>
<param name=\"allowFullScreen\" value=\"true\"></param>
<embed src=\"http://www.youtube.com/v/$1&hl=en&fs=1?&autoplay=1\" type=\"application/x-shockwave-flash\" allowfullscreen=\"true\" width=\"475px;\" height=\"260px;\"></embed>
</object>
</div>
<table style='border:1px solid lightgrey;'>
<td bgcolor='#EBEBEB' style='vertical-align:top;'>
<div id='flip' style='cursor:pointer;'>
<div id='container'><div id='img1'><img src='http://img.youtube.com/vi/$1/default.jpg'/></div><div id='img2'><img src='img/play-button.png' style='width:40px; height:40px;'/> </div></div>
</div>
</td>
<td width='355px;' bgcolor='#EBEBEB' style='vertical-align:top;'>
<font color='#363636'><b>$video_title</b></font><font color='#545454'></br><a href='http://www.youtube.com/watch?v={$id}' target='_blank'><font color='#69aa35'><b>Youtube.com</b></font></a> - $video_perigrafh...</font><font color='#949494'>[$view_count views]</font>
</td>
</table>", $row['comment']);
}
?>
You are using an id (#panel) and id's are supposed to be unique. The selector is based on the native GetElementByID, which returns the first match.
You should use a class (<div class="panel">) instead.
http://jsfiddle.net/gLXLr/ - illustration of the id vs class targeting
Edit: regarding the new code with classes, if your HTML is:
<div class='panel'>
...
</div>
<table style='border:1px solid lightgrey;'>
<tr>
<td bgcolor='#EBEBEB' style='vertical-align:top;'>
<div class='flip' style='cursor:pointer;'>
..
</div>
</td>
</tr>
</table>
The code for the toggle should be:
$(document).ready(function(){
$(".flip").click(function() {
$(this).parents('table').prev('.panel').slideToggle("slow");
});
});
You can adjust it to fit your needs , of course.
I am having an issue with tcpdf and rendering divs. Below is a cut down version of my code:
<?php
require_once (APP . 'vendors/xtcpdf.php');
ob_clean();
$tcpdf = new XTCPDF();
$tcpdf->AddPage();
$html = '<div style="width: 333px;height: 750px;float: left;border: 1px solid black;">
Col One Test
</div>
<div style="width: 333px;height: 750px;float: left;border: 1px solid black;">
Col Two Test
</div>
<div style="width: 333px;height: 750px;float: left;border: 1px solid black;">
Col Three Test
</div>';
$tcpdf->writeHTML($html, true, false, true, false, '');
echo $tcpdf->Output('test.pdf', 'D');
?>
The XTCPDF is simply just an extension to overwrite the header and footer so is irrelevant here as it is not used for now. The issue arises when putting this data into the PDF. Below is how the code renders when displayed in a webpage:
However when rendered in a PDF this is what I get:
Cheers,
Chris.
I'm using dreamweaver and php to return a list of images based on search critiera.
I have used Dreamweaver's repeat function and can get the images to repeat below each other (as below).
<table width="100" height="38" border="1">
<?php do { ?>
<tr>
<td width="38">
<img class='example' src="images/<?php echo $row_getresult['image_name']; ?>.png"/><br>
</a></td></tr>
<?php } while ($row_getamenityaccommodation = mysql_fetch_assoc($getamenityaccommodation));
?>
</table>
How can I get the images to go across from each other within a CSS Div e.g. float:left; width:45%; so that if there are more images than what would fit in 45%, the images would continue onto a new line?
Would somehow 'printing' the array work?
Remove the table and replace with
<div style='width:45%'>
<?php do{ ?>
<img style='float:left;class='example' src="images/<?php echo $row_getresult['image_name']; ?>.png"/>
<?php } while ($row_getamenityaccommodation = mysql_fetch_assoc($getamenityaccommodation)); ?>
</div>
or for a more semantic version use a ul since you are showing a list of images.
<ul class='gallery'>
<?php do{ ?>
<li><img style='float:left;class='example' src="images/<?php echo $row_getresult['image_name']; ?>.png"/></li>
<?php } while ($row_getamenityaccommodation = mysql_fetch_assoc($getamenityaccommodation)); ?>
</ul>
and in css
ul.gallery {
width: 45%;
list-style: none;
margin:0; padding:0;
}
ul.gallery li {
float:left;
padding: 5px;
}
I've been away from programming in general for a long time. Amazing how you forget the simplest things. So I'm trying to warm-up my web design/PHP by making a resume generator.
I made my resume in Word, and I want to try to mimic the document formatting.
I tried doing this with tables, and then I scraped that because it wasn't working exactly like I wanted, and now I'm using divs and spans.
But that's breaking the formatting even more so I don't know what to do...
My main problem is getting spaces to line up precisely the way tabs do in Microsoft Word, on the same line as other things.
Here is the code I'm using
function fieldFill($fieldL, $fieldR = 'NoneAtAll'){
$numOfSpaces = 50;
echo '<div class="left">' . $fieldL . '</div>';
//if ($fieldR != 'NoneAtAll'){
// for($i = 0; $i <= $numOfSpaces - strlen($fieldL); $i++){
// echo ' ';
// //echo $i;
if ($fieldR != 'NoneAtAll'){
for($i = 0; $i <= $numOfSpaces; $i++){
echo ' ';
}
echo '<span class="rightt">' . $fieldR . '</span>';
echo '<br></br>';
}
}
And here is the CSS section
<style>
.rightt {margin: 0 0 0 300px;}
.name { font-size: 22pt;}
.sections {
padding: 15px 0px 0px 0px;
font-size: 12pt;
font-weight: bold;
text-decoration: underline;
}
.years {
font-size: 12pt;
font-weight: bold;
/*white-space:pre*/
}
.jobtits {
font-size: 12pt;
font-weight: bold;
}
</style>
I know there's already good resume generators out there but I'm doing this for the practice. Thanks
Here we go, I want to mimic this format
As of today I'm finding that this code
<div id="page-container">
<div id="leftside">
<div class="name">Name</div>
Address
<br>
City
<br>
State
<div class="sections">Objective</div>
To do good stuff!
<div class="sections">Education</div>
A college
<div class="sections">Awards</div>
Did some good stuff
<div class="sections">Job Experience</div>
<div class="jobtits">Some place</div>
Was an editor
<div class="jobtits">Another place</div>
Did stuff there too.
<div class="sections">Skills</div>
</div>
<div id="rightside">
<div class="name">That's my name</div>
Mobile: 334-223-3244
<br>
Home: 334-223-3244
<br>
Email: Email#me.com
<div class="sections">Filler</div>
Filler
<div class="sections">Filler</div>
2012-1030
<div class="sections">Filler</div>
Filler
<div class="sections">Job Experience</div>
<div class="jobtits">Jul 00 - 32</div>
Filler
<div class="jobtits">Everybody's heard</div>
About the bird.
<div class="sections">Skills</div>
</div>
</div>
is working for the most part, but there are still parts that need to overlap, such as the objective line. I probably need to make a new div/table for that huh? I'm walking through the html static before making it dynamic.
SPAN tag is inline element so margin will not be appled to it, use DIV tag instead.