rstudio / pagedown

Paginate the HTML Output of R Markdown with CSS for Print
https://pagedown.rbind.io
Other
892 stars 128 forks source link

Change the page size of the resume template #285

Closed danielvartan closed 2 years ago

danielvartan commented 2 years ago

Hi there,

I was wondering if there's a simple way to change the page size of the resume template.

The actual page size is Letter (8.5 by 11 inches). Most European and Latin American countries use A4 (210 mm × 297 mm) as the standard.

danielvartan commented 2 years ago

This seems to do the trick.

@page {
    size: A4 portrait;
    margin: 21mm 10.5mm 21mm 10.5mm;
}

@media screen and (min-width: 210mm) {
    body {
        margin: auto;
        width: unset;
    }
}

* {
    --pagedjs-margin-left: 5.25mm;
    --pagedjs-margin-right: 10.5mm;
}

.pagedjs_page {
    --pagedjs-pagebox-width: 210mm !important;
    --pagedjs-pagebox-height: 297mm !important;
    --pagedjs-margin-top: 21mm !important;
    --pagedjs-margin-bottom: 21mm !important;
    --pagedjs-margin-left: 5.25mm !important;
    --pagedjs-margin-right: 10.5mm !important;
    --sidebar-background-width: calc(1.5 * var(--pagedjs-margin-right) + var(--sidebar-width)) !important;
}

:root {
    --page-width: 210mm;
    --margin-left: 0mm;
    --margin-right: 21mm;
    --pagedjs-margin-top: 21mm;
    --pagedjs-margin-bottom: var(--pagedjs-margin-top);
    --pagedjs-margin-left: 5.25mm;
    --pagedjs-margin-right: 10.5mm;
    --sidebar-width: 12rem;
    --sidebar-horizontal-padding: 0mm;
}

[data-id="main"] {
    padding: 0 5.25mm 0 5.25mm;
}

.aside {
    width: var(--sidebar-width);
    padding: 15.75mm var(--sidebar-horizontal-padding);
}