1
|
1 |
|
module Resume |
2
|
1 |
|
module PDF |
3
|
|
|
# Module representing faking out an image link in the PDF. |
4
|
|
|
# |
5
|
|
|
# @author Paul Fioravanti |
6
|
1 |
|
module ImageLink |
7
|
|
|
# The character to be used as filler when placed over images |
8
|
|
|
# to make a transparent link. |
9
|
1 |
|
BAR = "|".freeze |
10
|
1 |
|
private_constant :BAR |
11
|
|
|
# Level of opaqueness for an image link. |
12
|
1 |
|
TRANSPARENT = 0 |
13
|
1 |
|
private_constant :TRANSPARENT |
14
|
|
|
|
15
|
1 |
|
module_function |
16
|
|
|
|
17
|
|
|
# Generates an image link on the PDF document. |
18
|
|
|
# This is done for social media, company, and educational |
19
|
|
|
# institution logos. |
20
|
|
|
# |
21
|
|
|
# @param pdf [Prawn::Document] |
22
|
|
|
# The PDF to on which to apply the image link. |
23
|
|
|
# @param logo [Hash] |
24
|
|
|
# Presentation information about the target logo for an image link. |
25
|
1 |
|
def generate(pdf, logo) |
26
|
|
|
image, fit, align, link_overlay_start = |
27
|
25 |
|
logo.values_at(:image, :fit, :align, :link_overlay_start) |
28
|
25 |
|
pdf.image(image, fit: fit, align: align) |
29
|
25 |
|
pdf.move_up(link_overlay_start) |
30
|
25 |
|
transparent_link(pdf, logo) |
31
|
|
|
end |
32
|
|
|
|
33
|
|
|
# Generates a set of transparent "bars" (|||) over |
34
|
|
|
# a section of a PDF document. |
35
|
|
|
# |
36
|
|
|
# @param pdf [Prawn::Document] |
37
|
|
|
# The PDF to on which to apply the transparent link. |
38
|
|
|
# @param logo [Hash] |
39
|
|
|
# Presentation information about the target logo. |
40
|
1 |
|
def transparent_link(pdf, logo) |
41
|
25 |
|
pdf.transparent(TRANSPARENT) do |
42
|
25 |
|
pdf.formatted_text( |
43
|
|
|
[ |
44
|
|
|
{ |
45
|
|
|
text: BAR * logo[:bars], |
46
|
|
|
size: logo[:size], |
47
|
|
|
link: logo[:link] |
48
|
|
|
} |
49
|
|
|
], align: logo[:align] |
50
|
|
|
) |
51
|
|
|
end |
52
|
|
|
end |
53
|
|
|
end |
54
|
|
|
end |
55
|
|
|
end |
56
|
|
|
|