Skip to content

Commit

Permalink
Add --no-pdf-header-footer argument to Chromium (#182)
Browse files Browse the repository at this point in the history
* Add --no-pdf-header-footer argument to Chromium browsers for PDF generation
* Add link to Chromium browser command lline switches
  • Loading branch information
axunonb authored Aug 31, 2024
1 parent 71a4778 commit dd429d4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion League/Caching/ReportSheetCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,9 @@ private async Task<string> CreateReportSheetPdfChromium(string tempFolder, strin

// Run Chromium
// Command line switches overview: https://kapeli.com/cheat_sheets/Chromium_Command_Line_Switches.docset/Contents/Resources/Documents/index
// or better https://peter.sh/experiments/chromium-command-line-switches/
var startInfo = new System.Diagnostics.ProcessStartInfo(_pathToChromium,
$"--allow-pre-commit-input --disable-background-networking --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-component-update --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=Translate,BackForwardCache,AcceptCHFrame,MediaRouter,OptimizationHints --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --disable-sync --enable-automation --enable-blink-features=IdleDetection --enable-features=NetworkServiceInProcess2 --export-tagged-pdf --force-color-profile=srgb --metrics-recording-only --no-first-run --password-store=basic --use-mock-keychain --headless --hide-scrollbars --mute-audio --no-sandbox --disable-gpu --use-cmd-decoder=passthrough --no-margins --user-data-dir={tempFolder} --print-to-pdf={pdfFile} {htmlUri}")
$"--allow-pre-commit-input --disable-background-networking --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-component-update --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=Translate,BackForwardCache,AcceptCHFrame,MediaRouter,OptimizationHints --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --disable-sync --enable-automation --enable-blink-features=IdleDetection --enable-features=NetworkServiceInProcess2 --export-tagged-pdf --force-color-profile=srgb --metrics-recording-only --no-first-run --password-store=basic --use-mock-keychain --headless --hide-scrollbars --mute-audio --no-sandbox --disable-gpu --use-cmd-decoder=passthrough --no-margins --user-data-dir={tempFolder} --no-pdf-header-footer --print-to-pdf={pdfFile} {htmlUri}")
{ CreateNoWindow = true, UseShellExecute = false };
var proc = System.Diagnostics.Process.Start(startInfo);

Expand Down
2 changes: 1 addition & 1 deletion League/Views/Match/ReportSheet.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
@@media print {
@@page {
size: 210mm 297mm;
margin: 0; /* removes header and footer when printing with browsers */
margin: 0; /* removes header and footer when printing with browsers, for automatic pdf generation --no-pdf-header-footer is required for Chromium browsers */
}
div.container {
Expand Down

0 comments on commit dd429d4

Please sign in to comment.