Dompdf giving error frame not found in cellmap - php

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

Related

Route not working(showing blank page) in Laravel

I'm new to Laravel. I'm getting this issue from a long while. I've added a route to a page in web.php but it is showing a blank page instead of going to that page.
Here are the routes in web.php:
Route::group(['middleware' => ['auth','admin']], function() {
//For Admin Dashboard
Route::get('/dashboard', function () {
return view('admin.dashboard');
});
//For listing users
Route::get('/users-list', function () {
return view('admin.users');
});
});
The users-list route is not working. The users.blade.php file is placed in admin folder.
I'm trying to add the path directory to url but still not working. Here is another thing I'm trying.
Navbar
<li>
<!-- <a href="{{ url('/admin/users') }}"> -->
<a href="{{ url('/users-list') }}">
<i class="now-ui-icons users_single-02"></i>
<p>Users Profiles</p>
</a>
</li>
Here is my views directory
I'm trying to access it from here but still no results, same blank page. There's something wrong which I'm not able to find out. Any suggestion will be highly appreciated.
I'll be happy to provide any sorts of other details if required.
Replace your route with below route code:
Route::get('users-list', function () {
return view('admin/users');
});
Blade file code:
<li>
<!-- <a href="{{ url('/admin/users') }}"> -->
<a href="{{ url('users-list') }}">
<i class="now-ui-icons users_single-02"></i>
<p>Users Profiles</p>
</a>
</li>
just change your url in this way
Navbar
<li>
<a href="{{ url('/admin/users-list') }}">
<i class="now-ui-icons users_single-02"></i>
<p>Users Profiles</p>
</a>
Alright everyone, thanks alot for your answers and suggestions. I think I have found my issue.
I was using a layout file for dashboard.blade.php and users-list.blade.php named master.blade.php. And issue was in that file as it was not displaying output. I've corrected it and it worked.
Here is my users.blade.php
#extends('layouts.master')
#section('title')
Users Profiles | TestWeb
#endsection
#section('content')
<div class="row">
<div class="col-md-12">
<div class="card">
<div class="card-header">
<h4 class="card-title"> Simple Table</h4>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table">
<thead class=" text-primary">
<th>
Name
</th>
<th>
Country
</th>
<th>
City
</th>
<th class="text-right">
Salary
</th>
</thead>
<tbody>
<tr>
<td>
Dakota Rice
</td>
<td>
Niger
</td>
<td>
Oud-Turnhout
</td>
<td class="text-right">
$36,738
</td>
</tr>
<tr>
<td>
Minerva Hooper
</td>
<td>
Curaçao
</td>
<td>
Sinaai-Waas
</td>
<td class="text-right">
$23,789
</td>
</tr>
<tr>
<td>
Sage Rodriguez
</td>
<td>
Netherlands
</td>
<td>
Baileux
</td>
<td class="text-right">
$56,142
</td>
</tr>
<tr>
<td>
Philip Chaney
</td>
<td>
Korea, South
</td>
<td>
Overland Park
</td>
<td class="text-right">
$38,735
</td>
</tr>
<tr>
<td>
Doris Greene
</td>
<td>
Malawi
</td>
<td>
Feldkirchen in Kärnten
</td>
<td class="text-right">
$63,542
</td>
</tr>
<tr>
<td>
Mason Porter
</td>
<td>
Chile
</td>
<td>
Gloucester
</td>
<td class="text-right">
$78,615
</td>
</tr>
<tr>
<td>
Jon Porter
</td>
<td>
Portugal
</td>
<td>
Gloucester
</td>
<td class="text-right">
$98,615
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="col-md-12">
<div class="card card-plain">
<div class="card-header">
<h4 class="card-title"> Table on Plain Background</h4>
<p class="category"> Here is a subtitle for this table</p>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table">
<thead class=" text-primary">
<th>
Name
</th>
<th>
Country
</th>
<th>
City
</th>
<th class="text-right">
Salary
</th>
</thead>
<tbody>
<tr>
<td>
Dakota Rice
</td>
<td>
Niger
</td>
<td>
Oud-Turnhout
</td>
<td class="text-right">
$36,738
</td>
</tr>
<tr>
<td>
Minerva Hooper
</td>
<td>
Curaçao
</td>
<td>
Sinaai-Waas
</td>
<td class="text-right">
$23,789
</td>
</tr>
<tr>
<td>
Sage Rodriguez
</td>
<td>
Netherlands
</td>
<td>
Baileux
</td>
<td class="text-right">
$56,142
</td>
</tr>
<tr>
<td>
Philip Chaney
</td>
<td>
Korea, South
</td>
<td>
Overland Park
</td>
<td class="text-right">
$38,735
</td>
</tr>
<tr>
<td>
Doris Greene
</td>
<td>
Malawi
</td>
<td>
Feldkirchen in Kärnten
</td>
<td class="text-right">
$63,542
</td>
</tr>
<tr>
<td>
Mason Porter
</td>
<td>
Chile
</td>
<td>
Gloucester
</td>
<td class="text-right">
$78,615
</td>
</tr>
<tr>
<td>
Jon Porter
</td>
<td>
Portugal
</td>
<td>
Gloucester
</td>
<td class="text-right">
$98,615
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
#endsection
And #extends('layouts.master')
#section('title')
Users Profiles | TestWeb
#endsection
#section('content')
<div class="row">
<div class="col-md-12">
<div class="card">
<div class="card-header">
<h4 class="card-title"> Simple Table</h4>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table">
<thead class=" text-primary">
<th>
Name
</th>
<th>
Country
</th>
<th>
City
</th>
<th class="text-right">
Salary
</th>
</thead>
<tbody>
<tr>
<td>
Dakota Rice
</td>
<td>
Niger
</td>
<td>
Oud-Turnhout
</td>
<td class="text-right">
$36,738
</td>
</tr>
<tr>
<td>
Minerva Hooper
</td>
<td>
Curaçao
</td>
<td>
Sinaai-Waas
</td>
<td class="text-right">
$23,789
</td>
</tr>
<tr>
<td>
Sage Rodriguez
</td>
<td>
Netherlands
</td>
<td>
Baileux
</td>
<td class="text-right">
$56,142
</td>
</tr>
<tr>
<td>
Philip Chaney
</td>
<td>
Korea, South
</td>
<td>
Overland Park
</td>
<td class="text-right">
$38,735
</td>
</tr>
<tr>
<td>
Doris Greene
</td>
<td>
Malawi
</td>
<td>
Feldkirchen in Kärnten
</td>
<td class="text-right">
$63,542
</td>
</tr>
<tr>
<td>
Mason Porter
</td>
<td>
Chile
</td>
<td>
Gloucester
</td>
<td class="text-right">
$78,615
</td>
</tr>
<tr>
<td>
Jon Porter
</td>
<td>
Portugal
</td>
<td>
Gloucester
</td>
<td class="text-right">
$98,615
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="col-md-12">
<div class="card card-plain">
<div class="card-header">
<h4 class="card-title"> Table on Plain Background</h4>
<p class="category"> Here is a subtitle for this table</p>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table">
<thead class=" text-primary">
<th>
Name
</th>
<th>
Country
</th>
<th>
City
</th>
<th class="text-right">
Salary
</th>
</thead>
<tbody>
<tr>
<td>
Dakota Rice
</td>
<td>
Niger
</td>
<td>
Oud-Turnhout
</td>
<td class="text-right">
$36,738
</td>
</tr>
<tr>
<td>
Minerva Hooper
</td>
<td>
Curaçao
</td>
<td>
Sinaai-Waas
</td>
<td class="text-right">
$23,789
</td>
</tr>
<tr>
<td>
Sage Rodriguez
</td>
<td>
Netherlands
</td>
<td>
Baileux
</td>
<td class="text-right">
$56,142
</td>
</tr>
<tr>
<td>
Philip Chaney
</td>
<td>
Korea, South
</td>
<td>
Overland Park
</td>
<td class="text-right">
$38,735
</td>
</tr>
<tr>
<td>
Doris Greene
</td>
<td>
Malawi
</td>
<td>
Feldkirchen in Kärnten
</td>
<td class="text-right">
$63,542
</td>
</tr>
<tr>
<td>
Mason Porter
</td>
<td>
Chile
</td>
<td>
Gloucester
</td>
<td class="text-right">
$78,615
</td>
</tr>
<tr>
<td>
Jon Porter
</td>
<td>
Portugal
</td>
<td>
Gloucester
</td>
<td class="text-right">
$98,615
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
#endsection
And master.blade.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="apple-touch-icon" sizes="76x76" href="/assets/img/apple-icon.png">
<link rel="icon" type="image/png" href="/assets/img/favicon.png">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>
#yield('title')
</title>
<meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0, shrink-to-fit=no' name='viewport' />
<!-- Fonts and icons -->
<link href="https://fonts.googleapis.com/css?family=Montserrat:400,700,200" rel="stylesheet" />
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.1/css/all.css" integrity="sha384-fnmOCqbTlWIlj8LyTjo7mOUStjsKC4pOpQbqyi7RrhN7udi9RwhKkMHpvLbHG9Sr" crossorigin="anonymous">
<!-- CSS Files -->
<link href="{{ asset('assets/css/bootstrap.min.css') }}" rel="stylesheet" />
<link href="{{ asset('assets/css/now-ui-dashboard.css?v=1.3.0') }}" rel="stylesheet" />
<!-- CSS Just for demo purpose, don't include it in your project -->
<link href="{{ asset('assets/demo/demo.css') }}" rel="stylesheet" />
</head>
<body class="">
<div class="wrapper ">
<div class="sidebar" data-color="orange">
<!--
Tip 1: You can change the color of the sidebar using: data-color="blue | green | orange | red | yellow"
-->
<div class="logo">
<a href="http://www.creative-tim.com" class="simple-text logo-normal">
| TestWeb |
</a>
</div>
<div class="sidebar-wrapper" id="sidebar-wrapper">
#include('inc.admin_navbar')
</div>
</div>
<div class="main-panel" id="main-panel">
<!-- Navbar -->
<nav class="navbar navbar-expand-lg navbar-transparent bg-primary navbar-absolute">
<div class="container-fluid">
<div class="navbar-wrapper">
<div class="navbar-toggle">
<button type="button" class="navbar-toggler">
<span class="navbar-toggler-bar bar1"></span>
<span class="navbar-toggler-bar bar2"></span>
<span class="navbar-toggler-bar bar3"></span>
</button>
</div>
<a class="navbar-brand" href="#pablo">Table List</a>
</div>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navigation" aria-controls="navigation-index" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-bar navbar-kebab"></span>
<span class="navbar-toggler-bar navbar-kebab"></span>
<span class="navbar-toggler-bar navbar-kebab"></span>
</button>
<div class="collapse navbar-collapse justify-content-end" id="navigation">
<form>
<div class="input-group no-border">
<input type="text" value="" class="form-control" placeholder="Search...">
<div class="input-group-append">
<div class="input-group-text">
<i class="now-ui-icons ui-1_zoom-bold"></i>
</div>
</div>
</div>
</form>
<ul class="navbar-nav">
<!-- Logout Button Starts -->
<li class="nav-item dropdown">
<a id="navbarDropdown" class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-pre>
{{ Auth::user()->name }}
</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="{{ route('logout') }}"
onclick="event.preventDefault();
document.getElementById('logout-form').submit();">
{{ __('Logout') }}
</a>
<form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;">
#csrf
</form>
</div>
</li>
<!-- Logout Button Ends -->
</ul>
</div>
</div>
</nav>
<!-- End Navbar -->
<div class="panel-header panel-header-sm">
</div>
<div class="content">
#yield('content')
</div>
<footer class="footer">
<div class="container-fluid">
<nav>
<ul>
<li>
<a href="#">
TestWeb
</a>
</li>
<li>
<a href="#">
About Us
</a>
</li>
<li>
<a href="#">
Blog
</a>
</li>
</ul>
</nav>
<div class="copyright" id="copyright">
<script>
document.getElementById('copyright').appendChild(document.createTextNode(new Date().getFullYear()))
</script>
</div>
</div>
</footer>
</div>
</div>
<!-- Core JS Files -->
<script src="{{ asset('assets/js/core/jquery.min.js') }}"></script>
<script src="{{ asset('assets/js/core/popper.min.js') }}"></script>
<script src="{{ asset('assets/js/core/bootstrap.min.js') }}"></script>
<script src="{{ asset('assets/js/plugins/perfect-scrollbar.jquery.min.js') }}"></script>
<!-- Google Maps Plugin -->
<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_KEY_HERE"></script>
<!-- Chart JS -->
<script src="{{ asset('assets/js/plugins/chartjs.min.js') }}"></script>
<!-- Notifications Plugin -->
<script src="{{ asset('assets/js/plugins/bootstrap-notify.js') }}"></script>
<!-- Control Center for Now Ui Dashboard: parallax effects, scripts for the example pages etc -->
<script src="{{ asset('assets/js/now-ui-dashboard.min.js?v=1.3.0') }}" type="text/javascript"></script>
<!-- Now Ui Dashboard DEMO methods, don't include it in your project! -->
<script src="{{ asset('assets/demo/demo.js') }}"></script>
</body>
</html>

Solution for Frame not found in cellmap

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);

Convert to pdf "Frame not found in cellmap"

I'm building an invoice system, first you'll have to fill in the products you want to have on your invoice then it will convert the html view(where it will show the products in a foreach loop) to pdf. But if I have more than 6 products it will throw the following exception:
Frame not found in cellmap
I know this question has been asked a lot. But it seems there is still no real solution. It occurs when the input on the page is bigger than the first page and it can't jump to a new page so it throws an error:
Already tried a lottt!
This won't work for me:
$paper_orientation = 'landscape';
$customPaper = array(0,0,950,950);
$dompdf->set_paper($customPaper,$paper_orientation);
https://github.com/dompdf/dompdf/issues/657
This is my html view:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Factuur</title>
<link rel="stylesheet" href="/administration/style.css" media="all" />
</head>
<body>
<header class="clearfix">
<img src="/administration/logo.png">
<div id="company">
<h2 class="name">Company name</h2>
<div>Address</div>
<div>zip</div>
<div>email</div>
</div>
</div>
</header>
<main>
<div id="details" class="clearfix">
<div id="client">
<div class="to">{{ $sort == 0 ? 'Offerte' : 'Factuur' }} voor:</div>
<h2 class="name">{{ $company }}</h2>
<div class="address">{{ $address }}</div>
<div class="address">{{ $zip }}</a></div>
</div>
<div>
<h1>{{ $sort == 0 ? 'Offerte' : 'Factuur' }}nummer: {{ $number }}</h1>
<div class="date">Datum: {{ $date }}</div>
</div>
</div>
<table border="0" cellspacing="0" cellpadding="0">
<thead>
<tr>
<th class="no">#</th>
<th class="desc">Beschrijving</th>
<th class="unit">Prijs</th>
<th class="qty">Aantal</th>
<th class="total">Totaal</th>
</tr>
</thead>
<tbody>
#foreach($products as $product)
<tr>
<td class="no">{{ $product->id }}</td>
<td class="desc"><h3>{{ $product->title }}</h3>{{ $product->description }}</td>
<td class="unit">€{{ $product->price }}</td>
<td class="qty">{{ $product->number }}</td>
<td class="total">€{{ $product->total }}</td>
</tr>
#endforeach
</tbody>
<tfoot>
<tr>
<td colspan="2"></td>
<td colspan="2">SUBTOTAAL</td>
<td>€ {{ $subtotal }}</td>
</tr>
<tr>
<td colspan="2"></td>
<td colspan="2">BTW 21%</td>
<td>€ {{ $btw }}</td>
</tr>
<tr>
<td colspan="2"></td>
<td colspan="2">TOTAAL</td>
<td>€ {{ $total }}</td>
</tr>
</tfoot>
</table>
<div id="notices" class="{{ $sort == 0 ? 'hidePayment' : 'notices' }}">
<div>BETALING:</div>
</div>
</main>
<footer>
KvK nummer: | BTW nummer:
</footer>
</body>
</html>
Is there a solution?

regex select tag td only with specific property

so i have this html table:
$table = '<table cellpadding="0" cellspacing="0" class="calendar">
<tr>
<th>Sun</th>
<th>Mon</th>
<th>Tue</th>
<th>Wed</th>
<th>Thu</th>
<th>Fri</th>
<th>Sat</th>
</tr>
<tr>
<td> </td>
<td data-date="12/01/2014">
<div class="wrapper">
<div class="day">1</div>
</div>
</td>
<td data-date="12/02/2014">
<div class="wrapper">
<div class="day">2</div>
</div>
</td>
<td data-date="12/03/2014">
<div class="wrapper">
<div class="day">3</div>
</div>
</td>
<td data-date="12/04/2014" class="green">
<div class="wrapper">
<div class="day">4</div>
</div>
</td>
<td data-date="12/05/2014" class="green">
<div class="wrapper">
<div class="day">5</div>
</div>
</td>
<td data-date="12/06/2014" class="green">
<div class="wrapper">
<div class="day">6</div>
</div>
</td>
</tr>
<tr>
<td data-date="12/07/2014" class="green">
<div class="wrapper">
<div class="day">7</div>
</div>
</td>
<td data-date="12/08/2014" class="green">
<div class="wrapper">
<div class="day">8</div>
</div>
</td>
<td data-date="12/09/2014" class="green">
<div class="wrapper">
<div class="day">9</div>
</div>
</td>
<td data-date="12/10/2014" class="green">
<div class="wrapper">
<div class="day">10</div>
</div>
</td>
<td data-date="12/11/2014" class="green">
<div class="wrapper">
<div class="day">11</div>
</div>
</td>
<td data-date="12/12/2014">
<div class="wrapper">
<div class="day">12</div>
</div>
</td>
<td data-date="12/13/2014">
<div class="wrapper">
<div class="day">13</div>
</div>
</td>
</tr>
</table>';
i want to get the date inside data-date property in tag <td> which has no property class="green". the valid results expected are:
12/01/2014
12/02/2014
12/03/2014
12/12/2014
12/13/2014
(they are not have property class="green")
this my code:
preg_match_all('/<td[^>]*data-date="(.*?)">(.*?)<\/td>/', $table, $tag, PREG_PATTERN_ORDER);
print_r($tag);
however the regex i used is still match with tag <td> which has property class="green". since i want to exclude theme, what is the correct regex?
need your advise, thank you for helping.
<td[^>]*data-date="[^"]*"(?:(?!class="green"|>).)*>(.*?)<\/td>
Try this.See demo.
https://regex101.com/r/dU7oN5/9
I try this :
/<td[^>]*data-date="([0-9\/]+)">(.*?)<\/td>/s
and it looks like it does the job,
Use https://fr.functions-online.com/preg_match_all.html to test your regexp ;)
Sorry for my english

convert html div or page url to pdf using php

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;

Categories