Add a new pdf generation option using wkhtmltopdf

This commit is contained in:
Craig Davis 2012-03-04 15:09:53 -06:00
parent c8a859265b
commit 7c20b32294
8 changed files with 115 additions and 398 deletions

8
.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
output/resume-pdf.html
assets/templates/default.html
output/resume.pdf
output/resume.html

28
assets/css/pdf.css Normal file
View File

@ -0,0 +1,28 @@
body.pdf {
.container {
width: 1000px;
margin: 0 auto;
padding: 0;
background: none;
border: none;
border-width: 8px 0 2px 0;
text-align: left;
}
.resume {
position:relative;
padding: 40px 80px;
}
a[href$='.pdf'] {
display: none;
}
h1 {
letter-spacing: 0;
}
h2 {
letter-spacing: 0;
}
}

View File

@ -9,12 +9,14 @@
}
}
body {
font-family: Georgia;
font-family: Garamond, "Hoefler Text", Times New Roman, Times, serif;
color: #444;
padding: 2em 0;
}
h1, h2, h3, h4, ul dl dt {
font-family: Futura, "Century Gothic", AppleGothic, sans-serif;
}
.container {
width: 1000px;
@ -46,7 +48,7 @@ a[href$='.pdf'] {
blockquote {
top: 0;
right: 0;
right: 40px;
position: absolute;
}
@ -83,7 +85,7 @@ h2 {
h3 {
float: left;
width: 25%;
width: 16%;
margin: 0;
padding: 0;
font-style: italic;
@ -93,7 +95,7 @@ h3 {
h3+p {
margin: 0 0 16px; padding: 0;
float: left;
width: 75%;
width: 84%;
display: block;
font-size: 104%;
line-height: 24px;
@ -106,7 +108,7 @@ ul {
list-style: none;
}
ul li {
width: 25%;
width: 28%;
margin: 0;
padding: 0;
float: left;
@ -121,7 +123,7 @@ ul dl {
}
dd {
margin: 0 0 1em;
padding: .5em 3em 0 0;
padding: .5em 2em 0 0;
font-size: .8em;
line-height: 1.5em;
}
@ -130,7 +132,7 @@ ul dl {
ol {
margin: 0;
padding: 0;
width: 75%;
width: 84%;
display: inline-block;
}
@ -144,23 +146,29 @@ ol li {
line-height: 24px;
font-size: 14px;
}
ol li:nth-child(3n) {
width: 34%;
}
ol li:nth-child(1), ol li:nth-child(2), ol li:nth-child(3) {
border-top: none;
}
dl {
display: inline-block;
width: 75%;
margin: 0;
padding: 0;
dt {
margin: 0;
padding: 0;
font-size: 150%;
}
dd {
margin: 0 0 1.5em;
padding: 0;
font-size: 80%;
line-height: 1.4em;
}
strong {
float: right;
@ -173,4 +181,15 @@ dl {
font-style: normal;
}
}
}
#footer {
display: none;
}
#footer + p {
width: 100%;
font-size: 11px;
text-align: center;
}

View File

@ -12,7 +12,7 @@
</style>
</head>
<body>
<body class="">
<div class="container">
<div class="resume">

View File

@ -29,32 +29,39 @@ use Assetic\Asset\GlobAsset;
use Assetic\Filter;
$shortopts = "";
$shortopts .= "r";
$shortopts .= "s:";
$shortopts .= "rp";
$longopts = array(
"refresh"
"source:",
"refresh",
"pdf"
);
$options = getopt($shortopts, $longopts);
$refresh_dev = isset($options['r']) || isset($options['refresh']);
if (!isset($options['s'])) {
exit('Please specify a source document build.php -s resume.pdf');
}
$basename = pathinfo($options['s'], PATHINFO_FILENAME);
$source = './resume/' . $options['s'];
$pdf_source = './output/' . $basename . '-pdf.html';
$output = './output/' . $basename . '.html';
$pdf_output = './output/' . $basename . '.pdf';
$refresh_dev = isset($options['r']) || isset($options['refresh']);
$css = new AssetCollection(
array(
//new FileAsset('/path/to/src/styles.less', array(new LessFilter())),
new GlobAsset(APPLICATION_BASE_PATH . '/assets/css/*.css')
),
array(
new Filter\LessphpFilter(),
)
);
// the code is merged when the asset is dumped
$style = $css->dump();
$template = file_get_contents(APPLICATION_BASE_PATH . '/assets/templates/default.html');
$resume = file_get_contents(APPLICATION_BASE_PATH . '/resume/resume.md');
@ -80,9 +87,33 @@ $rendered = $m->render(
);
file_put_contents(
APPLICATION_BASE_PATH . '/resume/resume.html',
APPLICATION_BASE_PATH . '/output/resume.html',
$rendered
);
$pdf_classed = str_replace(
'body class=""',
'body class="pdf"',
$rendered
);
if (isset($options['pdf'])) {
file_put_contents(
$pdf_source,
$pdf_classed
);
exec(
'wkhtmltopdf '
. $pdf_source .' '
. $pdf_output
. ' && open ' . $pdf_output
);
//unlink(APPLICATION_BASE_PATH . '/resume/resume-pdf.html');
}
/* End of file build.php */

0
output/EMPTY Normal file
View File

View File

@ -1,375 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Craig Davis | Senior PHP Developer, UX Director</title>
<style type="text/css">
article, aside, details, figcaption, figure, footer, header, hgroup, nav, section, summary { display:block; }
audio, canvas, video {
display:inline-block;
*display:inline;
*zoom:1;
}
audio:not([controls]) { display:none; }
[hidden] { display:none; }
html {
font-size:100%;
-webkit-text-size-adjust:100%;
-ms-text-size-adjust:100%;
}
html, button, input, select, textarea { font-family:sans-serif; }
body { margin:0; }
a:focus { outline:thin dotted; }
a:hover, a:active { outline:0; }
h1 {
font-size:2em;
margin:0.67em 0;
}
h2 {
font-size:1.5em;
margin:0.83em 0;
}
h3 {
font-size:1.17em;
margin:1em 0;
}
h4 {
font-size:1em;
margin:1.33em 0;
}
h5 {
font-size:0.83em;
margin:1.67em 0;
}
h6 {
font-size:0.75em;
margin:2.33em 0;
}
abbr[title] { border-bottom:1px dotted; }
b, strong { font-weight:bold; }
blockquote { margin:1em 40px; }
dfn { font-style:italic; }
mark {
background:#ffff00;
color:#000000;
}
p, pre { margin:1em 0; }
pre, code, kbd, samp {
font-family:monospace, serif;
_font-family:'courier new', monospace;
font-size:1em;
}
pre {
white-space:pre;
white-space:pre-wrap;
word-wrap:break-word;
}
q { quotes:none; }
q:before, q:after {
content:'';
content:none;
}
small { font-size:75%; }
sub, sup {
font-size:75%;
line-height:0;
position:relative;
vertical-align:baseline;
}
sup { top:-0.5em; }
sub { bottom:-0.25em; }
dl, menu, ol, ul { margin:1em 0; }
dd { margin:0 0 0 40px; }
menu, ol, ul { padding:0 0 0 40px; }
nav ul, nav ol {
list-style:none;
list-style-image:none;
}
img {
border:0;
-ms-interpolation-mode:bicubic;
}
svg:not(:root) { overflow:hidden; }
figure { margin:0; }
form { margin:0; }
fieldset {
border:1px solid #c0c0c0;
margin:0 2px;
padding:0.35em 0.625em 0.75em;
}
legend {
border:0;
padding:0;
white-space:normal;
*margin-left:-7px;
}
button, input, select, textarea {
font-size:100%;
margin:0;
vertical-align:baseline;
*vertical-align:middle;
}
button, input { line-height:normal; }
button, input[type="button"], input[type="reset"], input[type="submit"] {
cursor:pointer;
-webkit-appearance:button;
*overflow:visible;
}
button[disabled], input[disabled] { cursor:default; }
input[type="checkbox"], input[type="radio"] {
box-sizing:border-box;
padding:0;
*height:13px;
*width:13px;
}
input[type="search"] {
-webkit-appearance:textfield;
-moz-box-sizing:content-box;
-webkit-box-sizing:content-box;
box-sizing:content-box;
}
input[type="search"]::-webkit-search-decoration, input[type="search"]::-webkit-search-cancel-button { -webkit-appearance:none; }
button::-moz-focus-inner, input::-moz-focus-inner {
border:0;
padding:0;
}
textarea {
overflow:auto;
vertical-align:top;
}
table {
border-collapse:collapse;
border-spacing:0;
}
.clearfix { zoom:1; }
.clearfix:after {
display:block;
visibility:hidden;
height:0;
clear:both;
content:".";
}
body {
font-family:Georgia;
color:#444444;
padding:2em 0;
}
.container {
width:1000px;
margin:0 auto;
padding:0;
background:whiteSmoke;
border:solid #666666;
border-width:8px 0 2px 0;
text-align:left;
}
.resume {
position:relative;
padding:40px 80px;
}
a { color:#990003; }
a[href$='.pdf'] {
display:inline-block;
background:#666666;
color:white;
padding:6px 50px 6px 12px;
margin-bottom:6px;
text-decoration:none;
}
blockquote {
top:0;
right:0;
position:absolute;
}
hr {
display:block;
position:relative;
padding:0;
margin:18px auto;
width:100%;
clear:both;
border:none;
border-top:1px solid #cccccc;
font-size:1px;
line-height:0;
overflow:visible;
}
h1 {
margin:0;
padding:0;
font-size:48px;
text-transform:uppercase;
letter-spacing:3px;
font-weight:normal;
}
h2 {
margin:0;
padding:0;
text-transform:uppercase;
font-style:italic;
letter-spacing:2px;
font-weight:normal;
}
h3 {
float:left;
width:25%;
margin:0;
padding:0;
font-style:italic;
font-weight:normal;
}
h3+p {
margin:0 0 16px;
padding:0;
float:left;
width:75%;
display:block;
font-size:104%;
line-height:24px;
}
ul {
margin:0;
padding:0;
list-style:none;
}
ul li {
width:25%;
margin:0;
padding:0;
float:left;
}
ul dl {
margin:0;
padding:0;
}
ul dl dt {
font-size:122%;
margin-bottom:.25em;
}
ul dl dd {
margin:0 0 1em;
padding:.5em 3em 0 0;
font-size:.8em;
line-height:1.5em;
}
ol {
margin:0;
padding:0;
width:75%;
display:inline-block;
}
ol li {
margin:0;
padding:0;
border-top:1px solid #cccccc;
width:33%;
float:left;
list-style:none;
line-height:24px;
font-size:14px;
}
ol li:nth-child(1), ol li:nth-child(2), ol li:nth-child(3) { border-top:none; }
dl {
display:inline-block;
width:75%;
}
dl dt { font-size:150%; }
dl dd {
margin:0 0 1.5em;
padding:0;
font-size:80%;
}
dl strong {
float:right;
margin-top:-3em;
}
dl em {
display:block;
font-size:130%;
margin-bottom:.5em;
font-style:normal;
}
</style>
</head>
<body>
<div class="container">
<div class="resume">
<h1>Craig Davis</h1>
<h2>Senior PHP Developer, UX Director</h2>
<blockquote>
<p><a href="resume.pdf">Download PDF</a><br />
<a href="craig@there4development.com">craig@there4development.com</a><br />
(999) 888-7777</p>
</blockquote>
<hr />
<h3 id="profile">Profile</h3>
<p>Progressively evolve cross-platform ideas before impactful infomediaries. Energistically visualize tactical initiatives before cross-media catalysts for change.</p>
<hr />
<h3 id="skills">Skills</h3>
<ul>
<li><dl>
<dt>Web Design</dt>
<dd>Assertively exploit wireless initiatives rather than synergistic core competencies.</dd>
</dl></li>
<li><dl>
<dt>Interface Design</dt>
<dd>Credibly streamline mission-critical value with multifunctional functionalities.</dd>
</dl></li>
<li><dl>
<dt>Project Direction</dt>
<dd>Proven ability to lead and manage a wide variety of design and development projects in team and independent situations.</dd>
</dl></li>
</ul>
<hr />
<h3 id="technical">Technical</h3>
<ol>
<li>XHTML</li>
<li>CSS</li>
<li>Javascript</li>
<li>Jquery</li>
<li>PHP</li>
<li>CVS / Subversion</li>
<li>OS X</li>
<li>Windows XP/Vista</li>
<li>Linux</li>
</ol>
<hr />
<h3 id="experience">Experience</h3>
<dl>
<dt>Microsoft</dt>
<dd><em>Principal and Creative Lead</em>
<strong>2004-2005</strong>
Intrinsicly transform flexible manufactured products without excellent intellectual capital. Energistically evisculate orthogonal architectures through covalent action items. Assertively incentivize sticky platforms without synergistic materials.</dd>
<dt>International Business Machines (IBM)</dt>
<dd><em>Lead Web Designer</em>
<strong>2001-2004</strong>
Globally re-engineer cross-media schemas through viral methods of empowerment. Proactively grow long-term high-impact human capital and highly efficient innovation. Intrinsicly iterate excellent e-tailers with timely e-markets.</dd>
</dl>
<hr />
</div>
</div>
</body>
</html>

View File

@ -52,4 +52,10 @@ International Business Machines (IBM)
__2001-2004__
Globally re-engineer cross-media schemas through viral methods of empowerment. Proactively grow long-term high-impact human capital and highly efficient innovation. Intrinsicly iterate excellent e-tailers with timely e-markets.
------
------
### Footer {#footer}
Craig Davis -- [craig@there4development.com](craig@there4development.com) -- (999) 888-7777
------