output from PHP = ok, from DOMPDF = wrong. (display) - php

This output run fine in HTML / PHP:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="es">
<head>
<title>(PAbi)</title>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
<link rel="icon" href="https://cdn.sstatic.net/Sites/stackoverflow/img/favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="https://cdn.sstatic.net/Sites/stackoverflow/img/favicon.ico" type="image/x-icon" />
<style type="text/css">html,body{margin:0;padding:0;background:#000;color:#fff;font-family:helvetica;}
.pie{position:fixed;width:100%;bottom:0;color:#000;background:#fff9f2;font-size:6.5pt;text-align:center;border-top:1px dashed #aa0000;}
#indice{width:430px;margin:auto;}
#indice dt{float:left;width:300px;overflow:hidden;white-space:nowrap;}
#indice dd{margin:0;float:left;width:100px;overflow:hidden;}
#indice dt span:after{content:".....................................................";}
</style></head>
<body><div id="cosmos"><br />
<h1 class="marin">index</h1>
<ul id="indice">
<dt><span>Índice</span></dt><dd>2</dd>
<dt><span>intro</span></dt><dd>3</dd>
<dt><span>functions</span></dt><dd>4</dd>
</ul></div>
<div class="pie">Aliens is here</div>
</body></html>
just as you can see, I need create the index page, then I need this "doits", I get this code from:
CSS Justify text, fill space with dots
But when I export to PDF with DOMPDF, the display go bad...
Thanks by any help to I can create the page "index" using doits to numbers of pages?, thanks!

Regards friends.
Using this code I can "create" my "page index" using:
XHTML
DOMPDF
index info with "doits" to show page number
Problem is when you used from css [TAG:after{content:"...your string here...";}]
DOMPDF forever put a newline and then display of "page index" is wrong in the document PDF.
maybe any person want used this option...
<?php
// I put excesive doits only by do test xD
$puntos = str_repeat('.', 999);
echo '<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="es">
<head><title>(PAbi)</title>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
<link rel="icon" href="https://cdn.sstatic.net/Sites/stackoverflow/img/favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="https://cdn.sstatic.net/Sites/stackoverflow/img/favicon.ico" type="image/x-icon" />
<style type="text/css">
table{width:650px;border-spacing:0.5em;}
#indice1 td{overflow:hidden;max-width:400px;border-radius:2em;padding:0.3em;}
#indice1 span:after{content:"'.$puntos.'";}
.numpa{text-align:center;width:20px;background:#d3dbfa;border:1px solid #000;}
.info{width:205px;background:#d1f6a5;border:1px solid #000;}
</style></head><body>
<table id="indice1"><tr>
<td class="info">ÍNDICE</td>
<td class="puntos"><span></span></td>
<td class="numpa">2</td></tr><tr>
<td class="info">Introducción</td>
<td class="puntos"><span></span></td>
<td class="numpa">3</td></tr><tr>
<td class="info">Características del servicio</td>
<td class="puntos"><span></span></td>
<td class="numpa">4</td>
</tr></table></body></html>';
?>

Unfortunately Dompdf (current release being v0.8.0) is unable to handle that particular styling. The main issue is that Dompdf does not correctly reflow floats at the end of the line. But even if you force it using something like #indice dd + dt { clear: both; } Dompdf does not appropriately clear the float and continues writing floats the additional floats to the same line.

Related

laravel 5.1 css and js files are not reading

I have copied my assets folder to public and called my css files using
<link href="{{!! asset('assets/global/plugins/font-awesome/css/font-awesome.min.css') !!}}" rel="stylesheet" type="text/css" />
<link href="{{ asset('assets/global/plugins/font-awesome/css/font-awesome.min.css') }}" rel="stylesheet" type="text/css" />
but when I open my local host to view my app the css does not working and when I check the css using inspect element it shows this error
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Object not found!</title>
<link rev="made" href="mailto:postmaster#localhost" />
<style type="text/css"><!--/*--><![CDATA[/*><!--*/
body { color: #000000; background-color: #FFFFFF; }
a:link { color: #0000CC; }
p, address {margin-left: 3em;}
span {font-size: smaller;}
/*]]>*/--></style>
</head>
<body>
<h1>Object not found!</h1>
<p>
The requested URL was not found on this server.
The link on the
<a href="http://localhost:7777/laravel/resources/views/login.blade.php">referring
page</a> seems to be wrong or outdated. Please inform the author of
that page
about the error.
</p>
<p>
If you think this is a server error, please contact
the webmaster.
</p>
<h2>Error 404</h2>
<address>
localhost<br />
<span>Apache/2.4.16 (Win32) OpenSSL/1.0.1p PHP/5.6.12</span>
</address>
</body>
</html>
First you put all your css and js file inside public folder.
ie, wamp->www->your project folder->public.
then in the coding section simply use the below mentioned technique.
<link href="css/bootstrap.css" rel="stylesheet" type="text/css" media="all" />
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="js/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="../css/jquery.datetimepicker.css"/>
<script type="text/javascript" src="../select/select2.min.js"></script>
<script type="text/javascript" src="../select/select2.js"></script>
<link href="../select/select2.css" rel="stylesheet">
Add a slash to the beginning of your assets urls:
<link href="{{!!asset('/assets/global/plugins/font-awesome/css/font-awesome.min.css') !!}}" rel="stylesheet" type="text/css" />
<link href="{{ asset('/assets/global/plugins/font-awesome/css/font-awesome.min.css') }}" rel="stylesheet" type="text/css" />

what does a "0" at the end of a raw http header mean (header("Location: http://www.sitename.com/0");)

The index.php file in the html document root of a web server contains:
<?php
header("Location: http://www.sitename.com/0");
exit();
?>
...
(see below for full listing but I think nothing gets done b/c the exit())
There is no file or directory in the document root named "0"
Can anyone tell me what it's doing / why it would be used?
When I enter http:/www.sitename.com/ in my browser address bar, the site loads and the address bar displays:
www.sitename.com/0
if I click on a button, a new page loads and the address bar displays something like:
www.sitename.com/0/index.php?toDo=sometext
and it I type in a file name that doesn't exist like this:
www.sitename.com/0/file_not_there.php
it doesn't complain, it just goes too the main page (and leaves www.sitename.com/0/file_not_there.php displaying in the address bar).
Any assistance you can give in helping me understand what's going on is appreciated.
full listing of public_html/index.php:
<?php
header("Location: http://www.sitename.com/0");
exit();
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Site Name</title>
<style type="text/css">
<!--
.style1 {font-family: Arial, Helvetica, sans-serif}
-->
</style>
</head>
<body>
<div align="center">
<p> </p>
<p><img src="/somedir/images/logo.png" /></p>
<p class="style1"><strong>Welcome</strong><br />
</p>
</div>
</body>
</html>

How to properly include a header file in a webpage

So I have a header file:
<html>
<head>
<link href="/design_header.css" rel="stylesheet" type="text/css" />
</head>
<body>
content
</body>
</html>
And I want to place this header in my file
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
meta tags etc.
</head>
<body>
<div id="container_big">
<?php include 'header_login.php'; ?>
content
</div>
</body>
</html>
The problem is now I have regular <html>, <head>, <body> tags inside the <body> tag of my webpage. In the html validator I receive errors like
Stray start tag html.
Stray end tag head.
An body start tag seen but an element of th
e same type was already open.
How to do it properly? Btw. I also place a footer to the bottom of the webpage the same way.
Your header file should only contain the HTML text you want for the header.
As it will be inserted into another webpage, it should not be a full HTML document.
Having only HTML for Header in Header
One option is to instead include in your header file only the HTML that is for the header (used by all pages that include it). However this has the downside that your not following the recommendation to have CSS loading before is rendered.
See: https://stackoverflow.com/a/1642259/1688441
Header File
<link href="/design_header.css" rel="stylesheet" type="text/css" />
content
Other files
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
meta tags etc.
</head>
<body>
<div id="container_big">
<?php include 'header_login.php'; ?>
content
</div>
</body>
</html>
Having only HTML for Header in HeaderFile and Separate HeadFile
You could have have a separate global_head_include.html (or txt, php, etc) file and put your CSS code there.
Header File (for include)
Header content
File with CSS includes (for include)
<link href="/design_header.css" rel="stylesheet" type="text/css" />
Whatever else is global...
Other files
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
meta tags etc.
<?php include 'global_head_include.php'; ?>
</head>
<body>
<div id="container_big">
<?php include 'header_login.php'; ?>
content
</div>
</body>
</html>
This is how I set out my headers and footers in my current PHP site:
header.php:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
<title>James Wright - Young Software Developer</title>
<link rel="stylesheet" href="style.css" />
<meta name="description" content="The online home of a young web designer and software developer." />
<link rel="icon" type="image/png" href="/img/ico.png" />
</head>
<body>
<div id="holder">
<div id="menu"></div>
<div id="mainContent">
footer.php:
</div>
<div id="mainReflect"></div>
<p class="footer">© James Wright <?php echo date("Y"); ?>. Minimum resolution: 1024x768 <a href="http://validator.w3.org/check?uri=referer" target="_blank"><img
src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0 Transitional" height="31" width="88" style="vertical-align: middle;"/></a>
<a href='http://www.powermapper.com/products/sortsite/'><img src='http://www.powermapper.com/images/badge-v1/sortsite-badge-small-5.png' width="80" height="15" alt='Broken link checker and accessibility checker top 5% - SortSite' style='vertical-align: middle;'/></a>
</p>
</div>
</body>
</html>
Then whenever I create a new page, all I need to do is this:
<?php include("header.php"); ?>
<p>Main body content!</p>
<?php include("footer.php"); ?>

doesnt display anything on the browser when using filename.php

it produces output when it is saved as filename.html
but when i try to change it to filename.php
then open the link in the brown using filename.php
it doesnt produce output anymore
NOTE: i removed some of the code too long
<?php
echo"
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script>
print code requirement
function printpage()
{
window.print();
}
</script>
print code requirement
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>WildFlowers by FCT</title>
<link href='http://fonts.googleapis.com/css?family=Oswald:400,300' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Abel' rel='stylesheet' type='text/css'>
<link href="style.css" rel="stylesheet" type="text/css" media="screen" />
<style type="text/css">
#wrapper #header-wrapper #header h1 a strong {
font-family: Georgia, "Times New Roman", Times, serif;
size: '100';
font-size: 40px;
</body>
</html>
";
?>
You have to remove <?php and ?>. Between these two tags there must be php-code and no html.
Edit: Maybe no errors are reported, because your server is configured to suppress errors.
Put some space after the echo..And use single quote['] insted of double.And change all single quotes from your code to double quote.(")
eg: -
<?php echo '
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head></head>
<body> Bla bla bla
</body>
</html>';
?>
The problem in your code is, you just started the codes with double quote.So the PHP server consider the next double quote is the closing of the echo statement.So there is nothing to print inside the first two double quote.But if you take the page source, you can see
<!DOCTYPE html PUBLIC
This is because you open PHP tag at the beginning of file:
<?php
Close it before your HTML markup:
<?php
// your php code
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
You can not have html in your php tags, if you want to use html you have to end the close your php first so something like this:
<?php
// php code here
?>
html code here
<?php
// php here
?>
If You need to write html inside php code use the echo statement.
ex:
<?php echo"
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head></head>
<body>
//your code here
</body>
</html>";
?>

Creating custom "html"-tags for CMS?

I am working with a CMS for a web app in PHP, that has the needs of shortening the process for inserting (embedding) stuff, like a video from youtube or vimeo by wroting the following, which are stored in the database:
<youtube id="wfI0Z6YJhL0" />
Which would output the following after some sort of replace:
<!-- Custom formatting before object !-->
<object width="640" height="385"><param name="movie" value="http://www.youtube-nocookie.com/v/wfI0Z6YJhL0&hl=sv_SE&fs=1?rel=0&color1=0xe1600f&color2=0xfebd01"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube-nocookie.com/v/wfI0Z6YJhL0&hl=sv_SE&fs=1?rel=0&color1=0xe1600f&color2=0xfebd01" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object>
<!-- Custom formatting after object !-->
How could I do this in PHP?
I've written a class that does exactly what you ask for my own cms. I've uploaded the src for you as although I've never released it the source is released under a BSD style license. Custom Tags
It basically allows you do do exactly what you ask for. In the class there are some example custom tags so I won't paste code here. Let me know how you go.
Edit 1: Example Code as requested. :-)
Edit 2: I should add it supports buried custom tags.
Edit 3: It also supports inline templating and tag substitution, ie
<ct:inline some="attribute">
This is an in line template. <br />
This is a #{tag} that can be accessed by the callback function
</ct:inline>
PHP/HTML: example.php
<?php
$current_dir = dirname(__FILE__).DIRECTORY_SEPARATOR;
require_once dirname($current_dir).DIRECTORY_SEPARATOR.'customtags.php';
$ct = new CustomTags(array(
'parse_on_shutdown' => true,
'tag_directory' => $current_dir.'tags'.DIRECTORY_SEPARATOR,
'sniff_for_buried_tags' => true
));
?><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>untitled</title>
<meta name="generator" content="TextMate http://macromates.com/">
<meta name="author" content="Oliver Lillie">
<!-- Date: 2010-07-10 -->
</head>
<body>
<ct:youtube id="wfI0Z6YJhL0" />
</body>
</html>
Custom Tag PHP Function: tags/youtube/tag.php:
function ct_youtube($tag)
{
return '<object id="'.$tag['attributes']->id.'" value="http://www.youtube.com/v/'.$tag['attributes']->id.'" /><param ......>';
}
Output:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>untitled</title>
<meta name="generator" content="TextMate http://macromates.com/">
<meta name="author" content="Oliver Lillie">
<!-- Date: 2010-07-10 -->
</head>
<body>
<object id="wfI0Z6YJhL0" value="http://www.youtube.com/v/wfI0Z6YJhL0" /><param ......>
</body>
</html>
I'm not 100% sure how it will react to non-standard tags, but if it works, simpleHTMLDom will be perfect for this.
$html = str_get_html('....');
then something along the lines of ...
$element = $html->find('youtube',0 ); // Finds first element
// - use "foreach" loop for final version
$element->tag = 'object';
$element->value = "http://www.youtube.com/v/".$element->id;
$element->innertext= "<param ......>"
....
echo $html;
you get the drift.
The beauty of this approach would be that every specific extension could add its data in clean HTML notation <tagname attribute="value">, with even the possibility of adding sub-tags for structured info, instead of kludgy {placeholder}s and regexes and so on.
I have never tried this and I don't have the time to test this right now, but if you decide to give it a try, I'd be interested to know whether this way turned out to be useful.

Categories