skip to Main Content

I am facing a problem that bootstrap is not working in mpdf.
Is there anyway to solve this issue?
I need all the information in one page just like i did it in preview.

This is the html code:

This is the preview link something like this:
https://elisa.com.my/pdf/test/index1.html

<!DOCTYPE html>
    <!--[if IE 8]> <html lang="en" class="ie8"> <![endif]-->  
    <!--[if IE 9]> <html lang="en" class="ie9"> <![endif]-->  
    <!--[if !IE]><!--> <html lang="en"> <!--<![endif]-->  
    <head>
        <title>Responsive Resume/CV Template for Developers</title>
        <!-- Meta -->
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="description" content="Responsive HTML5 Resume/CV Template for Developers">
        <meta name="author" content="Xiaoying Riley at 3rd Wave Media">    
        <link rel="shortcut icon" href="favicon.ico">  
        <link href='https://fonts.googleapis.com/css?family=Roboto:400,500,400italic,300italic,300,500italic,700,700italic,900,900italic' rel='stylesheet' type='text/css'>
        <!-- Global CSS -->
        <link rel="stylesheet" href="assets/plugins/bootstrap/css/bootstrap.min.css">   
        <!-- Plugins CSS -->
        <link rel="stylesheet" href="assets/plugins/font-awesome/css/font-awesome.css">

        <!-- Theme CSS -->  
        <link id="theme-style" rel="stylesheet" href="assets/css/styles.css">
        <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
        <!--[if lt IE 9]>
          <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
          <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
        <![endif]-->

    </head>


    <body>
        <button class="btn btn-info" id="cmd">generate PDF</button>
        <div id="content">
        <div class="wrapper">
            <div class="sidebar-wrapper">
                <div class="profile-container">
                    <img class="profile" src="assets/images/profile.png" alt="" />
                    <h1 class="name">Alan Doe</h1>
                    <h3 class="tagline">Full Stack Developer</h3>
                </div><!--//profile-container-->

                <div class="contact-container container-block" style="margin-top:-10% !important;">
                    <ul class="list-unstyled contact-list">
                        <li class="email"><i class="fa fa-envelope"></i><a href="mailto: [email protected]">[email protected]</a></li>
                        <li class="phone"><i class="fa fa-phone"></i><a href="tel:0123 456 789">0123 456 789</a></li>
                        <li class="website"><i class="fa fa-globe"></i><a href="http://themes.3rdwavemedia.com/website-templates/free-responsive-website-template-for-developers/" target="_blank">portfoliosite.com</a></li>
                        <li class="linkedin"><i class="fa fa-linkedin"></i><a href="#" target="_blank">linkedin.com/in/alandoe</a></li>
                        <li class="github"><i class="fa fa-github"></i><a href="#" target="_blank">github.com/username</a></li>
                        <li class="twitter"><i class="fa fa-twitter"></i><a href="https://twitter.com/3rdwave_themes" target="_blank">@twittername</a></li>
                    </ul>
                </div><!--//contact-container-->
                <div class="education-container container-block" style="margin-top:-10% !important;">
                    <h2 class="container-block-title">Education</h2>
                    <div class="item">
                        <h4 class="degree">MSc in Computer Science</h4>
                        <h5 class="meta">University of London</h5>
                        <div class="time">2011 - 2012</div>
                    </div><!--//item-->
                    <div class="item">
                        <h4 class="degree">BSc in Applied Mathematics</h4>
                        <h5 class="meta">Bristol University</h5>
                        <div class="time">2007 - 2011</div>
                    </div><!--//item-->
                </div><!--//education-container-->

                <div class="languages-container container-block" style="margin-top:-10% !important;">
                    <h2 class="container-block-title">Languages</h2>
                    <ul class="list-unstyled interests-list">
                        <li>English <span class="lang-desc">(Native)</span></li>
                        <li>French <span class="lang-desc">(Professional)</span></li>
                        <li>Spanish <span class="lang-desc">(Professional)</span></li>
                    </ul>
                </div><!--//interests-->

                <div class="interests-container container-block" style="margin-top:-10% !important;">
                    <h2 class="container-block-title">Interests</h2>
                    <ul class="list-unstyled interests-list">
                        <li>Climbing</li>
                        <li>Snowboarding</li>
                        <li>Cooking</li>
                    </ul>
                </div><!--//interests-->

            </div><!--//sidebar-wrapper-->

            <div class="main-wrapper">

                <section class="section summary-section">
                    <h2 class="section-title"><i class="fa fa-user"></i>Career Profile</h2>
                    <div class="summary">
                        <p>Summarise your career here lorem ipsum dolor sit amet, consectetuer adipiscing elit. You can <a href="http://themes.3rdwavemedia.com/website-templates/orbit-free-resume-cv-template-for-developers/" target="_blank">download this free resume/CV template here</a>. Aenean commodo ligula eget dolor aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu.</p>
                    </div><!--//summary-->
                </section><!--//section-->

                <section class="section experiences-section">
                    <h2 class="section-title"><i class="fa fa-briefcase"></i>Experiences</h2>

                    <div class="item">
                        <div class="meta">
                            <div class="upper-row">
                                <h3 class="job-title">Lead Developer</h3>
                                <div class="time">2015 - Present</div>
                            </div><!--//upper-row-->
                            <div class="company">Startup Hubs, San Francisco</div>
                        </div><!--//meta-->
                        <div class="details">
                            <p>Describe your role here lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo.</p>  
                            <p>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. </p>
                        </div><!--//details-->
                    </div><!--//item-->

                    <div class="item">
                        <div class="meta">
                            <div class="upper-row">
                                <h3 class="job-title">Senior Software Engineer</h3>
                                <div class="time">2014 - 2015</div>
                            </div><!--//upper-row-->
                            <div class="company">Google, London</div>
                        </div><!--//meta-->
                        <div class="details">
                            <p>Describe your role here lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem.</p>  

                        </div><!--//details-->
                    </div><!--//item-->

                    <div class="item">
                        <div class="meta">
                            <div class="upper-row">
                                <h3 class="job-title">UI Developer</h3>
                                <div class="time">2012 - 2014</div>
                            </div><!--//upper-row-->
                            <div class="company">Amazon, London</div>
                        </div><!--//meta-->
                        <div class="details">
                            <p>Describe your role here lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem.</p>  
                        </div><!--//details-->
                    </div><!--//item-->

                </section><!--//section-->

                <section class="section projects-section">
                    <h2 class="section-title"><i class="fa fa-archive"></i>Projects</h2>
                    <div class="intro">
                        <p>You can list your side projects or open source libraries in this section. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum et ligula in nunc bibendum fringilla a eu lectus.</p>
                    </div><!--//intro-->
                    <div class="item">
                        <span class="project-title"><a href="#hook">Velocity</a></span> - <span class="project-tagline">A responsive website template designed to help startups promote, market and sell their products.</span>

                    </div><!--//item-->
                    <div class="item">
                        <span class="project-title"><a href="http://themes.3rdwavemedia.com/website-templates/responsive-bootstrap-theme-web-development-agencies-devstudio/" target="_blank">DevStudio</a></span> - 
                        <span class="project-tagline">A responsive website template designed to help web developers/designers market their services. </span>
                    </div><!--//item-->
                    <div class="item">
                        <span class="project-title"><a href="http://themes.3rdwavemedia.com/website-templates/responsive-bootstrap-theme-for-startups-tempo/" target="_blank">Tempo</a></span> - <span class="project-tagline">A responsive website template designed to help startups promote their products or services and to attract users &amp; investors</span>
                    </div><!--//item-->
                    <div class="item">
                        <span class="project-title"><a href="hhttp://themes.3rdwavemedia.com/website-templates/responsive-bootstrap-theme-mobile-apps-atom/" target="_blank">Atom</a></span> - <span class="project-tagline">A comprehensive website template solution for startups/developers to market their mobile apps. </span>
                    </div><!--//item-->
                    <div class="item">
                        <span class="project-title"><a href="http://themes.3rdwavemedia.com/website-templates/responsive-bootstrap-theme-for-mobile-apps-delta/" target="_blank">Delta</a></span> - <span class="project-tagline">A responsive Bootstrap one page theme designed to help app developers promote their mobile apps</span>
                    </div><!--//item-->
                </section><!--//section-->

                <section class="skills-section section">
                    <h2 class="section-title"><i class="fa fa-rocket"></i>Skills &amp; Proficiency</h2>
                    <div class="skillset">        
                        <div class="item">
                            <h3 class="level-title">Python &amp; Django</h3>
                            <div class="level-bar">
                                <div class="level-bar-inner" data-level="98%">
                                </div>                                      
                            </div><!--//level-bar-->                                 
                        </div><!--//item-->

                        <div class="item">
                            <h3 class="level-title">Javascript &amp; jQuery</h3>
                            <div class="level-bar">
                                <div class="level-bar-inner" data-level="98%">
                                </div>                                      
                            </div><!--//level-bar-->                                 
                        </div><!--//item-->

                        <div class="item">
                            <h3 class="level-title">Angular</h3>
                            <div class="level-bar">
                                <div class="level-bar-inner" data-level="98%">
                                </div>                                      
                            </div><!--//level-bar-->                                 
                        </div><!--//item-->

                        <div class="item">
                            <h3 class="level-title">HTML5 &amp; CSS</h3>
                            <div class="level-bar">
                                <div class="level-bar-inner" data-level="95%">
                                </div>                                      
                            </div><!--//level-bar-->                                 
                        </div><!--//item-->

                        <div class="item">
                            <h3 class="level-title">Ruby on Rails</h3>
                            <div class="level-bar">
                                <div class="level-bar-inner" data-level="85%">
                                </div>                                      
                            </div><!--//level-bar-->                                 
                        </div><!--//item-->

                        <div class="item">
                            <h3 class="level-title">Sketch &amp; Photoshop</h3>
                            <div class="level-bar">
                                <div class="level-bar-inner" data-level="60%">
                                </div>                                      
                            </div><!--//level-bar-->                                 
                        </div><!--//item-->

                    </div>  
                </section><!--//skills-section-->

            </div><!--//main-body-->
        </div>
    </div>    
        <!-- Javascript -->          
        <script type="text/javascript" src="assets/plugins/jquery-1.11.3.min.js"></script>
        <script type="text/javascript" src="assets/plugins/bootstrap/js/bootstrap.min.js"></script>    
        <!-- custom js -->
        <script type="text/javascript" src="assets/js/main.js"></script>        
        <!-- these js files are used for making PDF -->
        <script src="js/jspdf.js"></script>
        <script src="js/jquery-2.1.3.js"></script>
        <script src="js/pdfFromHTML.js"></script>
        <script src="https://rawgit.com/Xportability/css-to-pdf/master/js/xepOnline.jqPlugin.js"></script>
        <script>
        var doc = new jsPDF();
        var specialElementHandlers = {
            '#editor': function (element, renderer) {
                return true;
            }
        };

        $('#cmd').click(function () {
            doc.fromHTML($('#content').html(), 15, 15, {
                'width': 170,
                    'elementHandlers': specialElementHandlers
            });
            doc.save('sample-file.pdf');
        });
        </script>
    </body>
    </html> 

This is the php code where I generate my pdf using MPDF.

The output in the preview was totally not same:https://elisa.com.my/pdf/test/index.php

<?php

include('mpdf60/mpdf.php');
$html = file_get_contents('https://elisa.com.my/pdf/test/index1.html');
$mpdf=new mPDF();
$mpdf->WriteHTML($html);
$mpdf->SetDisplayMode('default');

$mpdf->Output();

?>

Is there any way to achieve make it one page and generate a clone in the preview? I did before using jsPDF but I don’t want it to be in an image

2

Answers


  1. mPDF does not support Bootstrap styles entirely. An option would be some alternative such as headless-chrome based wkhtmltopdf.

    Login or Signup to reply.
  2. According to the mPDF developers on the below github issue, bootstrap is not supported due to the way that it implements the device sizing and also the print overrides.

    However there are some workarounds mentioned in the issues:

    Source: https://github.com/mpdf/mpdf/issues/66

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search