瀏覽代碼

Add directives for proper conversion into PDF

theenglishway (time) 2 年之前
父節點
當前提交
0c9348442e
共有 2 個文件被更改,包括 18 次插入0 次删除
  1. 1 0
      lib/templates/cv.html.heex
  2. 17 0
      lib/views/layout.ex

+ 1 - 0
lib/templates/cv.html.heex

@@ -19,6 +19,7 @@
     <style>
       <%= Layout.resets() |> Phoenix.HTML.raw() %>
       <%= Layout.page_css() |> Phoenix.HTML.raw() %>
+      <%= Layout.page_print_css() |> Phoenix.HTML.raw() %>
 
       dl {
         display: grid;

+ 17 - 0
lib/views/layout.ex

@@ -94,4 +94,21 @@ defmodule CvGenView.Layout do
       font-size: larger;
     }
     """
+
+  def page_print_css(),
+    do: """
+      @media print {
+        html {
+          background-color: initial;
+        }
+
+        body {
+          width: 100%;
+        }
+
+        .work {
+          break-inside: avoid;
+        }
+      }
+    """
 end