23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/gitlab/pdf/header.rb', line 23
def render
y = @pdf.bounds.top
@pdf.bounding_box([0, y], width: @pdf.bounds.right, height: @height) do
@pdf.bounding_box([0, @pdf.bounds.top], width: @halfway_point, height: @height) do
logo_path = Rails.root.join('app/assets/images/gitlab_logo.png')
begin
@pdf.image(logo_path, width: 21, height: 21, position: :left, vposition: 6)
rescue ArgumentError
nil
end
@pdf.text_box(
"GitLab",
at: [25, @pdf.bounds.top],
width: 100,
height: 30,
valign: :center,
size: 24,
style: :bold
)
end
@pdf.bounding_box([@halfway_point, @pdf.bounds.top], width: @halfway_point, height: @height) do
@exportable_title ||= "Vulnerability Summary"
@pdf.text_box(
"#{@exportable_title} | #{Date.current.strftime('%B %-d, %Y')} | #{@page}",
align: :right,
valign: :center,
size: 10
)
end
gradient_svg = <<~SVG
<svg width="#{@pdf.bounds.width}" height="10">
<defs>
<linearGradient id="grad" x1="0%" y1="0%" x2="100%" y2="0%">
<stop offset="0%" style="stop-color:#d2afed;stop-opacity:1" />
<stop offset="25%" style="stop-color:#fa8bca;stop-opacity:1" />
<stop offset="50%" style="stop-color:#ff76a4;stop-opacity:1" />
<stop offset="100%" style="stop-color:#fd6c30;stop-opacity:1" />
</linearGradient>
</defs>
<rect width="100%" height="10" fill="url(#grad)"/>
</svg>
SVG
@pdf.svg gradient_svg, at: [0, @pdf.bounds.top - 45]
end
end
|