From 7c20b32294b8070669d636df29133079fc56d83f Mon Sep 17 00:00:00 2001 From: Craig Davis Date: Sun, 4 Mar 2012 15:09:53 -0600 Subject: [PATCH] Add a new pdf generation option using wkhtmltopdf --- .gitignore | 8 + assets/css/pdf.css | 28 +++ assets/css/style.css | 41 +++- assets/templates/default.html | 2 +- build/build.php | 51 ++++- output/EMPTY | 0 resume/resume.html | 375 ---------------------------------- resume/resume.md | 8 +- 8 files changed, 115 insertions(+), 398 deletions(-) create mode 100644 .gitignore create mode 100644 assets/css/pdf.css create mode 100644 output/EMPTY delete mode 100644 resume/resume.html diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d5b44df --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ + +output/resume-pdf.html + +assets/templates/default.html + +output/resume.pdf + +output/resume.html diff --git a/assets/css/pdf.css b/assets/css/pdf.css new file mode 100644 index 0000000..4f43a95 --- /dev/null +++ b/assets/css/pdf.css @@ -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; + } + +} \ No newline at end of file diff --git a/assets/css/style.css b/assets/css/style.css index 9af9bb1..b4e4497 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -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; } -} \ No newline at end of file +} + + +#footer { + display: none; +} + +#footer + p { + width: 100%; + font-size: 11px; + text-align: center; +} diff --git a/assets/templates/default.html b/assets/templates/default.html index e5f99fd..d04eade 100644 --- a/assets/templates/default.html +++ b/assets/templates/default.html @@ -12,7 +12,7 @@ - +
diff --git a/build/build.php b/build/build.php index 989cd42..4841f51 100644 --- a/build/build.php +++ b/build/build.php @@ -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 */ \ No newline at end of file diff --git a/output/EMPTY b/output/EMPTY new file mode 100644 index 0000000..e69de29 diff --git a/resume/resume.html b/resume/resume.html deleted file mode 100644 index e78210b..0000000 --- a/resume/resume.html +++ /dev/null @@ -1,375 +0,0 @@ - - - - - -Craig Davis | Senior PHP Developer, UX Director - - - - - -
-
-

Craig Davis

- -

Senior PHP Developer, UX Director

- -
-

Download PDF
- craig@there4development.com
- (999) 888-7777

-
- -
- -

Profile

- -

Progressively evolve cross-platform ideas before impactful infomediaries. Energistically visualize tactical initiatives before cross-media catalysts for change.

- -
- -

Skills

- -
    -
  • -
    Web Design
    -
    Assertively exploit wireless initiatives rather than synergistic core competencies.
    -
  • -
  • -
    Interface Design
    -
    Credibly streamline mission-critical value with multifunctional functionalities.
    -
  • -
  • -
    Project Direction
    -
    Proven ability to lead and manage a wide variety of design and development projects in team and independent situations.
    -
  • -
- -
- -

Technical

- -
    -
  1. XHTML
  2. -
  3. CSS
  4. -
  5. Javascript
  6. -
  7. Jquery
  8. -
  9. PHP
  10. -
  11. CVS / Subversion
  12. -
  13. OS X
  14. -
  15. Windows XP/Vista
  16. -
  17. Linux
  18. -
- -
- -

Experience

- -
-
Microsoft
-
Principal and Creative Lead -2004-2005 -Intrinsicly transform flexible manufactured products without excellent intellectual capital. Energistically evisculate orthogonal architectures through covalent action items. Assertively incentivize sticky platforms without synergistic materials.
- -
International Business Machines (IBM)
-
Lead Web Designer -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.
-
- -
- -
-
- - - \ No newline at end of file diff --git a/resume/resume.md b/resume/resume.md index 325b0cf..8e80690 100644 --- a/resume/resume.md +++ b/resume/resume.md @@ -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. ------- \ No newline at end of file +------ + +### Footer {#footer} + +Craig Davis -- [craig@there4development.com](craig@there4development.com) -- (999) 888-7777 + +------