there4 / markdown-resume

Generate a responsive CSS3 and HTML5 resume with Markdown, with optional PDF output.
MIT License
1.77k stars 519 forks source link

Generating a PDF results in a non A4 format #78

Open GG-better opened 6 years ago

GG-better commented 6 years ago

Hey there, After having followed the installation instructions I used the respective command to generate a pdf file. In fact, a pdf file is generated, but its format is not A4 but a really tiny or miniature version sample.pdf (please see the file below: "sample.pdf").

To generate the pdf file mentioned above I used the following command (as shown in the example section):

./bin/md2resume pdf examples/source/sample.md examples/output/

If I use the command to generate a html file, the resulting output looks like fine (just as the provided example file). Only the pdf generation is different than expected.

Could anybody give me a hint how I could resolve this issue getting a pdf in A4 format (which might be the default setting)? Many thanks in advance!

PS: I have installed the latest version of wkhtmltopdf on my OSX.

craig-davis commented 6 years ago

I don't think it can be set via CSS. I think instead it may need to be added here when it calls wkhtmltopdf: https://github.com/there4/markdown-resume/blob/master/src/Resume/Command/PdfCommand.php#L86

With the --page-size A4 option. This would be a great option to add, but for now you could try that out and see how it goes.

GG-better commented 6 years ago

Thanks a lot, @craig-davis !!! You pointed me to the right code part! I played around with different options to wkhtmltopdf. Using the option --page-size A4 didn't solve the size issue mentioned above. However, a strong increase of the option --dpi (from 300 to 1800) solved the issue. Now the resume in the output pdf file is large enough. Finally, I used this code: exec('wkhtmltopdf --dpi 1800 ' . $pdfSource .' ' . $destFilename); Thank you, GG

danielklim commented 5 years ago

I've addressed this issue in there4/markdown-resume#84. If that PR is accepted, it will allow users to pass through arguments to the wkhtmltopdf engine instead of hardcoding PDF formatting in the PHP file. For example, for a PDF with 1in margins, Letter size and 300 dpi, the command would be invoked as something like:

md2resume pdf -k \
    --pdfargs="--dpi 300 -s Letter -T 1in -B 1in -L 1in -R 1in --print-media-type" \
    -t modern \
    ./src/resume.md ./