Skip to content

Commit

Permalink
Fixing PDF attachment styles
Browse files Browse the repository at this point in the history
  • Loading branch information
stankut committed Jun 20, 2023
1 parent 5e628e9 commit 9024f5f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
6 changes: 3 additions & 3 deletions modules/os2forms_attachment/os2forms_attachment.module
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ function _os2forms_attachment_print_form_add_template_override(array &$element,
'#options' => $header_options,
'#description' => t('Select default header that will be used on all forms (use standard for no override)'),
'#empty_option' => t('Use standard'),
'#default_value' => $template_settings['os2forms_header'] ?? '',
'#default_value' => $template_settings['os2form_header'] ?? '',
'#weight' => -1,
];

Expand All @@ -208,7 +208,7 @@ function _os2forms_attachment_print_form_add_template_override(array &$element,
'#options' => $colophon_options,
'#description' => t('Select default colophon that will be used on all forms (use standard for no override)'),
'#empty_option' => t('Use standard'),
'#default_value' => $template_settings['os2forms_colophon'] ?? '',
'#default_value' => $template_settings['os2form_colophon'] ?? '',
'#weight' => -1,
];

Expand All @@ -218,7 +218,7 @@ function _os2forms_attachment_print_form_add_template_override(array &$element,
'#options' => $footer_options,
'#description' => t('Select default footer that will be used on all forms (use standard for no override)'),
'#empty_option' => t('Use standard'),
'#default_value' => $template_settings['os2forms_footer'] ?? '',
'#default_value' => $template_settings['os2form_footer'] ?? '',
'#weight' => 0,
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ protected function prepareRenderer(array $entities, PrintEngineInterface $print_
'#attached' => [],
];

$print_engine->addPage($renderer->generateHtml($entities, $render, $use_default_css, TRUE));
// Adding hardcoded negative margin to avoid margins in <fieldset> <legend>
// structure. That margin is automatically added in PDF and PDF only.
$generatedHtml = (string) $renderer->generateHtml($entities, $render, $use_default_css, TRUE);
$generatedHtml .= "<style>fieldset legend {margin-left: -12px;}</style>";

$print_engine->addPage($generatedHtml);

return $renderer;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@
.table {
width: 100%;
}
legend, summary, .details-wrapper, fieldset {
padding: 0;
}
fieldset {
margin: 0;
border: 0;
}
</style>
</head>
<body>
Expand Down

0 comments on commit 9024f5f

Please sign in to comment.