The following:
Frame not found in cellmap
https://github.com/dompdf/dompdf/issues/657
Is a well know problem on the internet. But I can't find a solution
for the problem. I'm trying to convert my html template to pdf. When I remove the <table> it's working. Otherwise it throws an exception.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Example 2</title>
<link rel="stylesheet" href="/administration/style.css" media="all" />
</head>
<body>
<header class="clearfix">
<div id="logo">
<img src="/administration/logo.png">
</div>
<div id="company">
<h2 class="name">Company Name</h2>
<div>455 Foggy Heights, AZ 85004, US</div>
<div>(602) 519-0450</div>
<div>company#example.com</div>
</div>
</div>
</header>
<main>
<div id="details" class="clearfix">
<div id="client">
<div class="to">INVOICE TO:</div>
<h2 class="name">John Doe</h2>
<div class="address">796 Silver Harbour, TX 79273, US</div>
<div class="email">john#example.com</div>
</div>
<div id="invoice">
<h1>INVOICE 3-2-1</h1>
<div class="date">Date of Invoice: 01/06/2014</div>
<div class="date">Due Date: 30/06/2014</div>
</div>
</div>
<table border="0" cellspacing="0" cellpadding="0">
<thead>
<tr>
<th class="no">#</th>
<th class="desc">DESCRIPTION</th>
<th class="unit">UNIT PRICE</th>
<th class="qty">QUANTITY</th>
<th class="total">TOTAL</th>
</tr>
</thead>
<tbody>
<tr>
<td class="no">01</td>
<td class="desc"><h3>Website Design</h3>Creating a recognizable design solution based on the company's existing visual identity</td>
<td class="unit">$40.00</td>
<td class="qty">30</td>
<td class="total">$1,200.00</td>
</tr>
<tr>
<td class="no">02</td>
<td class="desc"><h3>Website Development</h3>Developing a Content Management System-based Website</td>
<td class="unit">$40.00</td>
<td class="qty">80</td>
<td class="total">$3,200.00</td>
</tr>
<tr>
<td class="no">03</td>
<td class="desc"><h3>Search Engines Optimization</h3>Optimize the site for search engines (SEO)</td>
<td class="unit">$40.00</td>
<td class="qty">20</td>
<td class="total">$800.00</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="1"></td>
<td colspan="1">SUBTOTAL</td>
<td>$5,200.00</td>
</tr>
<tr>
<td colspan="1"></td>
<td colspan="1">TAX 25%</td>
<td>$1,300.00</td>
</tr>
<tr>
<td colspan="1"></td>
<td colspan="1">GRAND TOTAL</td>
<td>$6,500.00</td>
</tr>
</tfoot>
</table>
<div id="thanks">Thank you!</div>
<div id="notices">
<div>NOTICE:</div>
<div class="notice">A finance charge of 1.5% will be made on unpaid balances after 30 days.</div>
</div>
</main>
<footer>
Invoice was created on a computer and is valid without the signature and seal.
</footer>
</body>
</html>
I had a similar problem, but was able to discover that I had an extra < in one of my text items (the text was entered by a user, so they had an age question that was like Are you < 21 years old. Make sure you escape these (in PHP, use htmlentities).
This can also happen with invalid html or an extra HTML tag. I looked through your <table> above and ran it through dompdf, but it didn't throw the error, so perhaps you had an errant < in your code that was not copied to StackOverflow?
SOLUTION:
use this:
$orientation = 'landscape';
$customPaper = array(0,0,950,950);
$this->setPaper($customPaper, $orientation);
Related
I want to use a PDF converter for my Laravel project so I thought Dompdf might be a good idea. I managed to get it to work to convert a simple invoice file. However when I wanted to structured my invoice more with tables tag and others to make it look nicer, it wouldn't convert for me and throws a:
domPDF exception: frame not found in cellmap
Here is my invoice.blade.php for reference:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Invoice</title>
<link href="{{ asset('css/app.css') }}" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" />
</head>
<body>
<div class="container">
<div class="card">
<div class="card-header">
<span class="float-left " > <img src="{{ asset('images/Logo.png') }}" style="width:60%;" alt="No Logo"></span>
<div class="float-center">
<h4>DC Signature Livingstyle SDN BHD</h4>
<small> 1-21-01,Menara Bangkok Bank,Berjaya Central Park,No 105,Jalan Ampang,50450 Kuala Lumpur,Malaysia </small><br>
<small>603-02818821 bujishu#gmail.com www.bujishu.com </small>
</div>
<div class="float-right">
<strong>Invoice:[Invoice Number]</strong>
<br>
<strong>[Date Placeholder]</strong> <br>
<strong>Credit Term:[Cash]</strong>
</div>
</div>
<div class="card-body">
<div class="row mb-4">
<div class="col-sm-6">
<h6 class="mb-3">From:</h6>
<div>
<strong>[Panel Name]</strong>
</div>
<div>[Address 1]</div>
<div>[Address 2]</div>
<div>Email:[panel_email]</div>
<div>Phone: [panel_number]</div>
</div>
<div class="col-sm-6">
<h6 class="mb-3">To:</h6>
<div>
<strong>[Customer Name]</strong>
</div>
<div> [Shipping address 1] </div>
<div>[shipping address 2]</div>
<div>Email:[customer_email]</div>
<div>Phone: [customer_number]</div>
</div>
</div>
<div class="table-responsive-sm">
<table class="table table-striped">
<thead>
<tr>
<th class="center">No</th>
<th>Item</th>
<th>Description</th>
<th class="left">Quantity</th>
<th class="center">Unit Price (RM)</th>
<th class="right">Amount(RM)</th>
</tr>
</thead>
<tbody>
<tr>
<td class="center">1</td>
<td class="left strong">Electrical wire</td>
<td class="left">Longest wire ever</td>
<td class="center">1</td>
<td class="left">999,00</td>
<td class="right">999,00</td>
</tr>
<tr>
<td class="center">2</td>
<td class="left">Interior design</td>
<td class="left">Instalation and Customization (cost per hour)</td>
<td class="left">20</td>
<td class="center">150</td>
<td class="right">3.000,00</td>
</tr>
<tr>
<td class="center">3</td>
<td class="left">Table</td>
<td class="left">Round table</td>
<td class="left">1</td>
<td class="center">499,00</td>
<td class="right">499,00</td>
</tr>
</tbody>
</table>
</div>
<div class="row">
<div class="col-lg-4 col-sm-5 ml-auto " >
<table class="table table-clear ">
<th><strong> Payment Received </strong></th>
<tbody>
<tr>
<td class="left">
Payment Method: xxxxxx
</td>
</tr>
<tr>
<td class="left">
Reference No: 2192012
</td>
</tr>
<tr>
<td class="left">
Amount Paid: RM10,000.00
</td>
</tr>
<tbody>
</table>
</div>
<div class="col-lg-4 col-sm-5 ml-auto">
<table class="table table-clear">
<tbody>
<tr>
<td class="left">
<strong>Subtotal</strong>
</td>
<td class="right">8.497,00</td>
</tr>
<tr>
<td class="left">
<strong>Transportation(Klang Valley)</strong>
</td>
<td class="right">xxxxx</td>
</tr>
<tr>
<td class="left">
<strong>Grand Total</strong>
</td>
<td class="right">8.497,00</td>
</tr>
<tr>
<td class="left">
<strong>Discount (20%)</strong>
</td>
<td class="right">1,699,40</td>
</tr>
<tr>
<td class="left">
<strong>Amount Paid</strong>
</td>
<td class="right">679,76</td>
</tr>
<tr>
<td class="left">
<strong>Balance Due</strong>
</td>
<td class="right">
<strong>7.477,36</strong>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<h6 style="margin-left:30%;">This invoice is computer generated,no signature is required.</h6>
</div>
</div>
</body>
</html>
Does anyone know how to resolve this?
Edit:
Validator returns this:
Error: Bad value {{ asset('css/app.css') }} for attribute href on element link: Illegal character in path segment: { is not allowed.
From line 8, column 2; to line 8, column 58
</title>↩ <link href="{{ asset('css/app.css') }}" rel="stylesheet"> ↩↩
Error: Bad value {{ asset('images/Logo.png') }} for attribute src on element img: Illegal character in path segment: { is not allowed.
From line 18, column 37; to line 18, column 111
-left " > <img src="{{ asset('images/Logo.png') }}" style="width:60%;" alt="No Logo"></span
Error: th start tag in table body.
From line 112, column 43; to line 113, column 12
e-clear ">↩ <th><stron
I am able to get the coding of a website with file_get_contents but I want to be able to get certain values out of the html. This piece of code is always the same but the value between the html tag changes from time to time. This is the HTML Code:
<div class="cheapest-bins">
<h3>Cheapest Live Buy Now</h3>
<table>
<tbody><tr>
<th>Console</th>
<th>Buy Now Price</th>
</tr>
<tr class=" active">
<td class="xb1">XB1</td>
<td>1,480,000</td>
</tr>
<tr class="">
<td class="ps4">PS4</td>
<td>1,590,000</td>
</tr>
<tr class="">
<td class="x360">360</td>
<td>---</td>
</tr>
<tr class="">
<td class="ps3">PS3</td>
<td>2,800,000</td>
</tr>
</tbody></table>
</div>
How would I go about getting the: 1,480,000 .. 1,590,000 .. --- and 2,800,000?
short answer:
find a css selector library such as https://github.com/tj/php-selector
then you could grab all td:last-child elements/innerhtml
for your specific example you could just just
preg_match_all('#<td>(.*?)</td>#', $html, $matches);
I'm trying to create a simple form to show a basic table and a delete query...
I can get the delete query working but when I use an include it does not work, if i run the 'display.php' file alone in browser it runs perfectly and shows the database...
Can anyone advise what would be best way incorporate the display.php file in this html file? Or explain the issue?
<!DOCTYPE html>
<div id="content">
<?php include('display.php')?>
<div id="sidebar"></div>
<div id="footer">
<h5></h5>
</div>
<table>
<tr>
<td>
<form action="delete.php" method="post"></form>
<table border="0" cellpadding="3" cellspacing="1" style="background-color: #536977" width="100%">
<tr>
<td width="150">Enter Username to be deleted</td>
<td width="6">:</td>
<td width="294"><input name="delusername" type="text"></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input type="submit" value="submit"></td>
</tr>
</table>
</td>
</tr>
</table>
</div>
</div>
<?php require_once('display.php'); ?>
Presuming they are in the same folder.
I understand that the question is little bit vague. Still I am tempted to ask this. I will give one working example and would like to know, how I can use this in my project. There is a site called http://erail.in .In this, if I want to get the details of a train or PNR, just enter in the form and submit. This (I assume) opens the train or PNR search page of Indian Railways (probably in the background) and get details pertaining to the value given by me and display the result in the page in which I am.
Similar way I have a form in my page which has one input box for entering TLD No.
<html>
<head>
<title>Untitled Document</title>
<link href="/DatePicker.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery-1.5.1.js"></script>
</head>
<body>
<form>
TLD No.<input type="text" id="tip"/>
<input type="submit" id="submit" value="Get" />
</form>
</body>
</html>
Upon submitting this form , I need a jQuery script which opens another search page in another server and submit the form in that page get the result from that page to my script. The search page in that server is like this:
<html>
<head>
<title>INDIVIDUAL ALL REPORT</title>
<base target="_self">
</head>
<body >
<form method="POST" name="form1" action="../dbms/allindvres.asp" target="I1">
<table border="0" cellpadding="0" cellspacing="0" style="BORDER-COLLAPSE: collapse" bordercolor="#669999" width="100%" id="AutoNumber1" >
<tr>
<th width="100%" colspan="4" style="BACKGROUND-COLOR: #cc6600; COLOR: #ffffff; FONT-WEIGHT: bold; TEXT-TRANSFORM: uppercase">individual data in one click</th>
</tr>
<tr>
<td width="33%" height="22" align="middle" ><font size=4>TLD No <input name="TLDNO" size="10"></td>
<td width="33%" height="22" align="middle" ><font size=4>CC No <input name="CCNO" size="10"></td>
<td width="33%" height="22" align="middle"><font size=4>or Name <input name="name" size="30"></td>
<td width="33%" height="22" align="middle">
<p align="center"><input type="submit" value="Get Life Dose" name="B1"></p>
</td>
</tr>
</table>
</form>
<iframe name="I1" width="100%" height="500" src="../DBMS/allindvres.asp" marginwidth="10" marginheight="5">
Your browser does not support inline frames or is currently configured not to display inline frames.</iframe></p></p>
</body>
</html>
Once the form is submitted, the result is displayed in the iframe above. The resulting html will look like this
<html>
<head>
<body>
<h3 align = 'center'><font color="red">
OTHER STATION
</h3>
<table border="2" align = 'center' cellpadding="0" style="border-collapse: collapse" width="80%" id="AutoNumber2">
<tr>
<TD WIDTH = 85% align = 'left' colspan='3'>
<table border="0" align = 'center' cellpadding="0" width =100%>
<tr>
<td>CC NO:</td>
<td>xxx</td>
<Td>SECTION: </td>
<td>xxx</td>
</tr>
<tr>
<td>NAME: </td>
<td>XXXX </td>
<Td>CATEGORY: </td>
<td>XX</td>
</tr>
<tr>
<td>FATHER'S NAME:</td>
<td>XXXX</td>
<Td>EMP NO: </td>
<td>XXXXX</td>
</tr>
<tr>
<td>BIRTH PLACE </td>
<td>XXXXX</td>
<td>CC NO:</td>
<td>XXXX</td>
</tr>
<tr>
<td>STATE</td>
<td>XXXXX</td>
<td>DATE OF BIRTH</td>
<td>3thMay1968</td>
</tr>
<tr>
<td>QUALIFICATION: </td>
<td>XXXX</td>
<td>DESIGNATION: </td>
<td>XXXX</td>
</tr>
</table>
</body>
</html>
I want to get values in second of second from the above table and display it in my page. How can I accomplish this?
If I am using the action="http://anotherserver/dbms/allindvres.asp" in the form above, After submitting I can get the result in an I frame in my page. But I do not want to use the default form submit method which refreshes the page. That is why I use jQuery. Any work around?
I have a HTML code like this:
<div id="invoice">
<div id="invoice-header"> <img alt="Mainlogo_large" class="logo screen" src="http://colosus.com/invoice/images/freeagent_logo.png">
<!-- hCard microformat -->
<div class="vcard" id="company-address">
<div class="fn org"><strong>KIOSBAN.COM</strong></div>
<div class="adr">
<div class="street-address">Gedung Atlantica Lt.4<br>
Jl. Kuningan Barat No. 7, Mampang<br>
</div>
<!-- street-address -->
<div class="locality">Indonesia</div>
<div id="company-postcode"><span class="region">Jakarta Selatan</span> <span class="postal-code">12710</span></div>
</div>
<!-- adr -->
<div class="email">fajar#kiosban.com</div>
<div id="sales-tax-reg-number">Fajar tampan</div>
</div>
<!-- company-address vcard -->
</div>
<!-- #invoice-header -->
<div id="invoice-info">
<h2>Invoice <strong>INV001</strong></h2>
<h3>21 February 2008</h3>
<p id="payment-terms">Payment Terms: 30 days</p>
<p id="payment-due">Payment due by 21 March 2008</p>
<p id="payment-total">£2643.75</p>
</div>
<!-- #invoice-info -->
<div class="vcard" id="client-details">
<div class="fn">John Doe</div>
<div class="org">Client Company</div>
<div class="adr">
<div class="street-address"> Client Street Address<br>
Street Address 2<br>
Street Address 3<br>
</div>
<!-- street-address -->
<div class="locality">LOCALITY</div>
<div id="client-postcode"><span class="region">Region</span> <span class="postal-code">MV2 8SX</span></div>
<div id="your-tax-number">SALES TAX: 193528491</div>
</div>
<!-- adr -->
</div>
<!-- #client-details vcard -->
<table id="invoice-amount">
<thead>
<tr id="header_row">
<th class="quantity_th">Quantity</th>
<th class="left details_th">Details</th>
<th class="unitprice_th">Unit Price (£)</th>
<th class="salestax_th">VAT</th>
<th class="subtotal_th">Net Subtotal (£)</th>
</tr>
</thead>
<tfoot>
<tr id="discount_tr">
<td colspan="2"> </td>
<td colspan="2" class="item_r">10% Discount</td>
<td class="item_r">£250.00</td>
</tr>
<tr id="net_total_tr">
<td colspan="2"> </td>
<td colspan="2" class="item_r">Net Total</td>
<td class="item_r">2250.00</td>
</tr>
<tr id="vat_tr">
<td colspan="2"> </td>
<td colspan="2" class="item_r">VAT</td>
<td class="item_r">393.75</td>
</tr>
<tr id="total_tr">
<td colspan="2"> </td>
<td colspan="2" class="total" id="total_currency"><span class="currency">GBP </span> Total</td>
<td class="total">£2643.75</td>
</tr>
</tfoot>
<tbody>
<tr class="item odd">
<td class="item_l">1 Day</td>
<td class="item_l">Details of project activity to be billed </td>
<td class="item_r">500.00</td>
<td class="item_r">17.5%</td>
<td class="item_r">500.00</td>
</tr>
<tr class="item">
<td class="item_l">2 Days</td>
<td class="item_l">Other Details of project activity to be billed </td>
<td class="item_r">1000.00</td>
<td class="item_r">17.5%</td>
<td class="item_r">1000.00</td>
</tr>
<tr class="item odd">
<td class="item_l">2 Days</td>
<td class="item_l">More d etails of project activity to be billed </td>
<td class="item_r">1500.00</td>
<td class="item_r">17.5%</td>
<td class="item_r">1000.00</td>
</tr>
</tbody>
</table>
<!-- invoice-amount -->
<div id="invoice-other">
<h2>Other Information</h2>
<div id="company-reg-number"><strong>Company Registration Number:</strong> 9273109</div>
<div id="contract-number"><strong>Contract/PO:</strong> PO 87227643</div>
</div>
<!-- invoice-other -->
<div id="payment-details">
<h2>Payment Details</h2>
<div id="bank_name">Bank Name</div>
<div id="sort-code"><strong>Bank/Sort Code:</strong> 32-75-97</div>
<div id="account-number"><strong>Account Number:</strong> 28270761</div>
<div id="iban"><strong>IBAN:</strong> 973547</div>
<div id="bic"><strong>BIC:</strong> 220197</div>
<div id="payment-reference"><strong>Payment Reference:</strong> INV001</div>
</div>
<!-- payment-details -->
<div id="comments">Payment should be made by bank transfer or cheque made payable to John Smith.</div>
<!-- comments -->
</div>
My question is: how to convert that HTML code only element inside <div id='invoice'>bla bla bla</div> or maybe just the specified url of that page (ex: localhost/invoice/index.php) to a downloadable pdf?
I've been searching many pdf class libraries but I can't find a solution.
Can anyone give me a solution, idea or possible approach?
You can use this service http://pdfmyurl.com/ to have PDF downloaded for urls, like having them in this format - http://pdfmyurl.com/?url=http://facebook.com
I would recommend using Zend_Pdf, it can be given a page which is used as the template for the PDF and you can do all sorts of PDF stuff.
Try mPDF it is a great and easy to use tool. And you can take a look on this quick start tutorial smaizys.com
Try TCPDF http://www.tcpdf.org/ . It is a php class for generating pdfs. Read http://www.tcpdf.org/examples/example_006.phps
I suggest to used DOMPDF.
[https://github.com/dompdf/dompdf][1]
it had huge problems with tables. I factored out my large nested tables and it helped (before it was just consuming up to 128M of memory then dying--thats my limit on memory in php.ini) but it makes a complete mess of tables and doesn't seem to get images. The tables were just basic stuff with some border styles to add some lines at various points;