<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Daryl Shannon</title>
    <description>The latest articles on DEV Community by Daryl Shannon (@dshannon).</description>
    <link>https://dev.to/dshannon</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F227919%2F1dfe93c2-032d-4d9a-b52f-bf025edf079d.jpg</url>
      <title>DEV Community: Daryl Shannon</title>
      <link>https://dev.to/dshannon</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dshannon"/>
    <language>en</language>
    <item>
      <title>HTML to PDF with Laravel 7 HTTP Client</title>
      <dc:creator>Daryl Shannon</dc:creator>
      <pubDate>Mon, 20 Apr 2020 10:11:49 +0000</pubDate>
      <link>https://dev.to/dshannon/html-to-pdf-with-laravel-7-http-client-236n</link>
      <guid>https://dev.to/dshannon/html-to-pdf-with-laravel-7-http-client-236n</guid>
      <description>&lt;p&gt;Laravel 7 has brough us a super minimal &lt;a href="https://laravel.com/docs/7.x/http-client"&gt;HTTP client&lt;/a&gt;. I'm a big fan. If you are familair with the powerful Guzzle HTTP client, you may have found it a little unintuitive or overkill for most projects.&lt;/p&gt;

&lt;p&gt;In this breif intro, I'll show you how awesomley minimal this HTTP client is, using the &lt;a href="https://docamatic.com"&gt;Docamatic API&lt;/a&gt; Docamatic API &lt;strong&gt;(disclaimer!!! - I am the founder)&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting Started
&lt;/h2&gt;

&lt;p&gt;Assuming you have  a Laravel project up and running, the first thing you need to do is obtain your API key from the Docamatic &lt;a href="https://docamatic.com/account/api-key"&gt;dashboard&lt;/a&gt;. Once you have your API key, add it to your &lt;code&gt;.env&lt;/code&gt; file as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nx"&gt;DOCAMATIC_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nx"&gt;YOUR&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;API&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nb"&gt;KEY&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;HERE&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Then, add the following to &lt;code&gt;config/services.php&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight php"&gt;&lt;code&gt;    &lt;span class="s1"&gt;'docamatic'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;  
           &lt;span class="s1"&gt;'key'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'DOCAMATIC_KEY'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  
    &lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Treat your API Key as a password — keep it secret. It should not be included in public repositories, emails or client side code&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Making an API Request
&lt;/h2&gt;

&lt;p&gt;For demonstration purposes, create a controller named &lt;code&gt;DocumentController.php&lt;/code&gt; as below. In a real world application you may want to use a &lt;a href="https://laravel.com/docs/7.x/queues#generating-job-classes"&gt;Job&lt;/a&gt; that can be dispatched to a Queue or a &lt;a href="https://laravel.com/docs/7.x/artisan#generating-commands"&gt;Console Command&lt;/a&gt; that runs as a scheduled task.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight php"&gt;&lt;code&gt;     &lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt;

    &lt;span class="kn"&gt;namespace&lt;/span&gt; &lt;span class="nn"&gt;App\Http\Controllers&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nn"&gt;Illuminate\Support\Facades\Http&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;DocumentController&lt;/span&gt; &lt;span class="k"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;Controller&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="c1"&gt;// Send the request&lt;/span&gt;
            &lt;span class="nv"&gt;$response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Http&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="na"&gt;withToken&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;config&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'services.docamatic.key'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'https://docamatic.com/api/v1/pdf'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
                &lt;span class="s1"&gt;'source'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'https://example.com'&lt;/span&gt;
            &lt;span class="p"&gt;]);&lt;/span&gt;

            &lt;span class="c1"&gt;// Access the response data via json()&lt;/span&gt;
            &lt;span class="nv"&gt;$data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$response&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;json&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

            &lt;span class="c1"&gt;// Dump out the data array&lt;/span&gt;
            &lt;span class="nx"&gt;dd&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$data&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Error Handling
&lt;/h2&gt;

&lt;p&gt;A nice benefit of using the Laravel HTTP client is that you no longer need to wrap your requests within a try/catch block. Laravel provides convenient methods that you can use to determine if anything went wrong with the request.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Determine if the status code was &amp;gt;= 200 and &amp;lt; 300...&lt;/span&gt;
&lt;span class="nv"&gt;$response&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;successful&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;// Determine if the response has a 400 level status code...&lt;/span&gt;
&lt;span class="nv"&gt;$response&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;clientError&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="c1"&gt;// Determine if the response has a 500 level status code...&lt;/span&gt;
&lt;span class="nv"&gt;$response&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;serverError&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Blade Template To PDF
&lt;/h2&gt;

&lt;p&gt;Laravel's &lt;strong&gt;render&lt;/strong&gt; method will return a view as a HTML string, which we can use to populate the &lt;code&gt;source&lt;/code&gt; parameter. As the Docamatic API doesnt have to look up an external URL, response times are usually quicker when sending raw HTML, opposed to a URL.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight php"&gt;&lt;code&gt;        &lt;span class="c1"&gt;// Blade template to PDF&lt;/span&gt;
        &lt;span class="nv"&gt;$response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Http&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="na"&gt;withToken&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;config&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'services.docamatic.key'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'https://docamatic.com/api/v1/pdf'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
            &lt;span class="s1"&gt;'source'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;view&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'documents.report'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;render&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="p"&gt;]);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Return PDF as Base64 String
&lt;/h2&gt;

&lt;p&gt;You may want to return your document as a base64 string, to save to your own storage or a database. To do so, set the &lt;code&gt;encode&lt;/code&gt; parameter to &lt;strong&gt;true&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight php"&gt;&lt;code&gt;    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Return the PDF as base64 string&lt;/span&gt;
        &lt;span class="nv"&gt;$response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Http&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="na"&gt;withToken&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;config&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'services.docamatic.key'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'https://docamatic.com/api/v1/pdf'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
            &lt;span class="s1"&gt;'source'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'https://example.com'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="s1"&gt;'encode'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
        &lt;span class="p"&gt;]);&lt;/span&gt;

        &lt;span class="c1"&gt;// Access the response data via json()&lt;/span&gt;
        &lt;span class="nv"&gt;$data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$response&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;json&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

        &lt;span class="c1"&gt;// Save to storage&lt;/span&gt;
        &lt;span class="nb"&gt;file_put_contents&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;storage_path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'app/document.pdf'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nb"&gt;base64_decode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'document'&lt;/span&gt;&lt;span class="p"&gt;]));&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Delete from Storage
&lt;/h2&gt;

&lt;p&gt;To delete a document from storage simply post the &lt;code&gt;transaction_id&lt;/code&gt; of the document to be deleted.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight php"&gt;&lt;code&gt;    &lt;span class="c1"&gt;// Delete a document from storage  &lt;/span&gt;
    &lt;span class="nv"&gt;$response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Http&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="na"&gt;withToken&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;config&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'services.docamatic.key'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="na"&gt;delete&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'https://docamatic.com/api/v1/delete'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;  
        &lt;span class="s1"&gt;'transaction_id'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'8c9a4943-5c13-483f-b3e4-de711e5b7006'&lt;/span&gt;  
    &lt;span class="p"&gt;]);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



</description>
      <category>laravel</category>
      <category>showdev</category>
      <category>pdf</category>
      <category>php</category>
    </item>
    <item>
      <title>Create a responsive Bootstrap invoice</title>
      <dc:creator>Daryl Shannon</dc:creator>
      <pubDate>Fri, 31 Jan 2020 15:10:14 +0000</pubDate>
      <link>https://dev.to/dshannon/create-a-responsive-bootstrap-invoice-21n6</link>
      <guid>https://dev.to/dshannon/create-a-responsive-bootstrap-invoice-21n6</guid>
      <description>&lt;p&gt;&lt;strong&gt;In this article, we’re going to build a responsive Bootstrap invoice template. Many times we need to display a HTML invoice in our application, we want it to look slick on mobile too.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Fd-shannon%2Fbootstrap-invoice-template%2Fmaster%2Fresponsive.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Fd-shannon%2Fbootstrap-invoice-template%2Fmaster%2Fresponsive.png" alt="enter image description here"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  So what is “Responsive Design”?
&lt;/h2&gt;

&lt;p&gt;In a nut shell, &lt;em&gt;responsive design&lt;/em&gt; is a website that adapts to different screen sizes. This means that it is easy to read and interact with on a mobile devices and desktops. The cool thing about this is we don’t need to develop a different site for mobile and one for desktop, the one design will do both.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is “Bootstrap”?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://getbootstrap.com" rel="noopener noreferrer"&gt;Bootstrap&lt;/a&gt; is the most popular CSS Framework for developing responsive and mobile-first websites. It’s very well documented and a really great starting point for getting into responsive design. Alternatively, you might want to check out &lt;a href="https://tailwindcss.com" rel="noopener noreferrer"&gt;Tailwind&lt;/a&gt;. It’s a beautiful framework with the same approach to responsive design. You could easily adapt this template to work with Tailwind.&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting started
&lt;/h2&gt;

&lt;p&gt;To ensure your website is responsive, you need to make sure you place the correct meta tag inside the head of your web pages like so:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;A &lt;code&gt;&amp;lt;meta&amp;gt;&lt;/code&gt; viewport element gives the browser instructions on how to control the page's dimensions and scaling.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;width=device-width&lt;/code&gt; part sets the width of the page to follow the screen width of the device and the &lt;code&gt;initial-scale=1.0&lt;/code&gt; part sets the initial zoom level.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using a custom font
&lt;/h2&gt;

&lt;p&gt;For our example, I want to use a custom font “Roboto” pulled in from &lt;a href="https://fonts.google.com" rel="noopener noreferrer"&gt;Google Fonts&lt;/a&gt;. A nice little boost to performance when using Google Fonts CDN is to precede the font import with &lt;strong&gt;&lt;em&gt;preconnect&lt;/em&gt;&lt;/strong&gt;. Just adding this line of code can reduce your page load time by 100ms – sweet!&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;link rel="preconnect" href="https://fonts.gstatic.com/" crossorigin&amp;gt;
&amp;lt;link href="https://fonts.googleapis.com/css?family=Roboto:400,700" rel="stylesheet"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Get Bootstrap
&lt;/h2&gt;

&lt;p&gt;Next we need to include the Bootstrap CSS. For tutorial simplicity, we will pull in the CSS from Bootstrap’s hosted CDN. There are many different ways to include Bootstrap in your project. My preferred method is to use a package manager such as NPM. You can explore the various options available to you &lt;a href="https://getbootstrap.com/docs/4.4/getting-started/download/" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Include the CSS:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384…" crossorigin="anonymous"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Writing the HTML
&lt;/h2&gt;

&lt;p&gt;To achieve a responsive design, we are going to utilize Bootstrap’s grid system and utilities. This will allow us to define certain behaviors for different screen sizes. To apply a breakpoint to a column for example, you would apply a class prefix such as &lt;code&gt;col-sm&lt;/code&gt; or &lt;code&gt;col-lg&lt;/code&gt;. I will go through some of the HTML markup to give you an idea of what is going on!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Lets have a look at our main container:&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class="container-fluid pt-2 pt-md-4 px-md-5"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;At first this may look a bit daunting. But it’s fairly straight forward once you get your head around it. &lt;strong&gt;It can be translated as follows&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;container-fluid&lt;/em&gt;&lt;/strong&gt; : our main container will fill 100% width of the screen&lt;br&gt;
(not a fixed width).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;pt-2&lt;/em&gt;&lt;/strong&gt; : apply padding to the top with a size of 2 (sizing runs from 1 to&lt;br&gt;
5).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;pt-md-4&lt;/em&gt;&lt;/strong&gt; : for screen size of medium and above, apply padding top  of&lt;br&gt;
size 4.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;px-md-5&lt;/em&gt;&lt;/strong&gt; : for screen size of medium and above, apply padding to the&lt;br&gt;
sides of size 5.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;And this &lt;code&gt;div&lt;/code&gt; can be broken down as follows:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class="col-md text-center text-md-left mb-3 mb-md-0"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;col-md&lt;/em&gt;&lt;/strong&gt; : for screen size of medium and above treat this div as a&lt;br&gt;
column.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;text-md-left&lt;/em&gt;&lt;/strong&gt; : for screen size of medium and above align the text to&lt;br&gt;
the left.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;mb-3&lt;/em&gt;&lt;/strong&gt; : apply margin to the bottom of size 3.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;&lt;em&gt;mb-md-0&lt;/em&gt;&lt;/strong&gt; : for screen size of medium and above do not apply a margin to&lt;br&gt;
the bottom.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Hopefully this brief rundown will give you a basic understanding of what is going on. Of course, you can check out the docs and get a deeper understanding of the Bootstrap grid system and utilities from the official &lt;a href="https://getbootstrap.com/docs/4.4/getting-started/introduction/" rel="noopener noreferrer"&gt;documentation&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Here is the full markup for our invoice template:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;title&amp;gt;Responsive Bootstrap Invoice Template&amp;lt;/title&amp;gt;
    &amp;lt;meta charset="utf-8"&amp;gt;
    &amp;lt;meta name="viewport" content="width=device-width, initial-scale=1"&amp;gt;

    &amp;lt;!-- Google fonts --&amp;gt;
    &amp;lt;link rel="preconnect" href="https://fonts.gstatic.com/" crossorigin&amp;gt;
    &amp;lt;link href="https://fonts.googleapis.com/css?family=Roboto:400,700" rel="stylesheet"&amp;gt;

    &amp;lt;!-- Bootstrap CDN --&amp;gt;
    &amp;lt;link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous"&amp;gt;

    &amp;lt;!-- Override some Bootstrap CDN styles - normally you should apply these through your Bootstrap variables / sass --&amp;gt;
    &amp;lt;style&amp;gt;
        body { font-family: "Roboto", serif; font-size: 0.8rem; font-weight: 400; line-height: 1.4; color: #000000; }
        h1, h2, h4, h5 { font-weight: 700; color: #000000; }
        h1 { font-size: 2rem; }
        h2 { font-size: 1.6rem; }
        h4 { font-size: 1.2rem; }
        h5 { font-size: 1rem; }
        .table { color: #000; }
        .table td, .table th { border-top: 1px solid #000; }
        .table thead th { vertical-align: bottom; border-bottom: 2px solid #000; }

        @page {
            margin-top: 2.5cm;
            margin-bottom: 2.5cm;
        }

        @page :first {
            margin-top: 0;
            margin-bottom: 2.5cm;
        }
    &amp;lt;/style&amp;gt;

&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;

&amp;lt;div style="background-color: #000000; height: 10px;"&amp;gt;&amp;lt;/div&amp;gt;

&amp;lt;div class="container-fluid pt-2 pt-md-4 px-md-5"&amp;gt;

    &amp;lt;!-- Invoice heading --&amp;gt;

    &amp;lt;table class="table table-borderless"&amp;gt;
        &amp;lt;tbody&amp;gt;
        &amp;lt;tr&amp;gt;
            &amp;lt;td class="border-0"&amp;gt;
                &amp;lt;div class="row"&amp;gt;
                    &amp;lt;div class="col-md text-center text-md-left mb-3 mb-md-0"&amp;gt;
                        &amp;lt;img class="logo img-fluid mb-3" src="https://docamatic.s3-eu-west-1.amazonaws.com/assets/360_logo.png" style="max-height: 140px;"/&amp;gt;
                        &amp;lt;br&amp;gt;

                        &amp;lt;h2 class="mb-1"&amp;gt;360 Footwear&amp;lt;/h2&amp;gt;
                        787 Brunswick, Los Angeles, CA 50028&amp;lt;br&amp;gt;
                        support@360footwear.co / 4444 555 555&amp;lt;br&amp;gt;
                        &amp;lt;strong&amp;gt;360footwear.co&amp;lt;/strong&amp;gt;
                    &amp;lt;/div&amp;gt;

                    &amp;lt;div class="col text-center text-md-right"&amp;gt;

                        &amp;lt;!-- Dont' display Bill To on mobile --&amp;gt;
                        &amp;lt;span class="d-none d-md-block"&amp;gt;
                            &amp;lt;h1&amp;gt;Billed To&amp;lt;/h1&amp;gt;
                        &amp;lt;/span&amp;gt;

                        &amp;lt;h4 class="mb-0"&amp;gt;Casey Williams&amp;lt;/h4&amp;gt;

                        57 Parkway, 5th Floor&amp;lt;br/&amp;gt;
                        New York, NY 10013&amp;lt;br/&amp;gt;
                        casey@test.com&amp;lt;br/&amp;gt;

                        &amp;lt;h5 class="mb-0 mt-3"&amp;gt;14th June, 2018&amp;lt;/h5&amp;gt;
                    &amp;lt;/div&amp;gt;
                &amp;lt;/div&amp;gt;
            &amp;lt;/td&amp;gt;
        &amp;lt;/tr&amp;gt;
        &amp;lt;/tbody&amp;gt;
    &amp;lt;/table&amp;gt;

    &amp;lt;!-- Invoice items table --&amp;gt;

    &amp;lt;table class="table"&amp;gt;
        &amp;lt;thead&amp;gt;
        &amp;lt;tr&amp;gt;
            &amp;lt;th&amp;gt;Summary&amp;lt;/th&amp;gt;
            &amp;lt;th class="text-right"&amp;gt;Price&amp;lt;/th&amp;gt;
        &amp;lt;/tr&amp;gt;
        &amp;lt;/thead&amp;gt;
        &amp;lt;tbody&amp;gt;
        &amp;lt;tr&amp;gt;
            &amp;lt;td&amp;gt;
                &amp;lt;h5 class="mb-1"&amp;gt;Pursuit Running Shoes&amp;lt;/h5&amp;gt;
                Men's Pursuit Running Shoes - 10/M
            &amp;lt;/td&amp;gt;
            &amp;lt;td class="font-weight-bold align-middle text-right text-nowrap"&amp;gt;$149.00 USD&amp;lt;/td&amp;gt;
        &amp;lt;/tr&amp;gt;
        &amp;lt;tr&amp;gt;
            &amp;lt;td&amp;gt;
                &amp;lt;h5 class="mb-1"&amp;gt;Shelby Boots&amp;lt;/h5&amp;gt;
                Men's Shelby Leather Boots - 10/M
            &amp;lt;/td&amp;gt;
            &amp;lt;td class="font-weight-bold align-middle text-right text-nowrap"&amp;gt;$99.00 USD&amp;lt;/td&amp;gt;
        &amp;lt;/tr&amp;gt;
        &amp;lt;tr&amp;gt;
            &amp;lt;td colspan="2" class="text-right border-0 pt-4"&amp;gt;&amp;lt;h5&amp;gt;Total: $248.00 USD&amp;lt;/h5&amp;gt;&amp;lt;/td&amp;gt;
        &amp;lt;/tr&amp;gt;
    &amp;lt;/table&amp;gt;

    &amp;lt;!-- Thank you note --&amp;gt;

    &amp;lt;h5 class="text-center pt-2"&amp;gt;
        Thank you for your custom!
    &amp;lt;/h5&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here is how our invoice looks rendered as a Letter document:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Fd-shannon%2Fbootstrap-invoice-template%2Fmaster%2Finvoice.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Fd-shannon%2Fbootstrap-invoice-template%2Fmaster%2Finvoice.png" alt="enter image description here"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  HTML to PDF
&lt;/h2&gt;

&lt;p&gt;If you need to convert your HTML to PDF or want to make use of &lt;a href="https://docamatic.com/templates" rel="noopener noreferrer"&gt;ready to go templates&lt;/a&gt; in your projects, please check out &lt;a href="https://docamatic.com" rel="noopener noreferrer"&gt;Docamatic&lt;/a&gt; (disclaimer!!! - I am the founder). &lt;/p&gt;

&lt;p&gt;You can see the final invoice rendered as a PDF &lt;a href="https://raw.githubusercontent.com/d-shannon/bootstrap-invoice-template/master/invoice.pdf" rel="noopener noreferrer"&gt;here&lt;/a&gt;. The source code can be downloaded from GitHub &lt;a href="https://github.com/d-shannon/bootstrap-invoice-template" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Happy coding and thanks for reading!&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>css</category>
      <category>html</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
