adjust document id pdf
This commit is contained in:
@@ -115,7 +115,7 @@ module Submissions
|
|||||||
canvas.save_graphics_state do
|
canvas.save_graphics_state do
|
||||||
document_id = Digest::MD5.hexdigest(submission.slug).upcase
|
document_id = Digest::MD5.hexdigest(submission.slug).upcase
|
||||||
|
|
||||||
canvas.font(FONT_NAME, size: FONT_SIZE)
|
font = composer.document.fonts.add(FONT_NAME)
|
||||||
|
|
||||||
text =
|
text =
|
||||||
if submission.account.testing?
|
if submission.account.testing?
|
||||||
@@ -128,7 +128,17 @@ module Submissions
|
|||||||
"Document ID: #{document_id}"
|
"Document ID: #{document_id}"
|
||||||
end
|
end
|
||||||
|
|
||||||
canvas.text(text, at: [2, 4])
|
text = HexaPDF::Layout::TextFragment.create(
|
||||||
|
text, font:, font_size: FONT_SIZE, underlays: [
|
||||||
|
lambda do |canv, box|
|
||||||
|
canv.fill_color('white').rectangle(-1, 0, box.width + 2, box.height).fill
|
||||||
|
end
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
HexaPDF::Layout::TextLayouter.new(font:, font_size: FONT_SIZE)
|
||||||
|
.fit([text], 1000, 1000)
|
||||||
|
.draw(canvas, 1, FONT_SIZE * 1.37)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -110,6 +110,8 @@ module Submissions
|
|||||||
pdfs_index.each_value do |pdf|
|
pdfs_index.each_value do |pdf|
|
||||||
next if pdf.trailer.info[:DocumentID].present?
|
next if pdf.trailer.info[:DocumentID].present?
|
||||||
|
|
||||||
|
font = pdf.fonts.add(FONT_NAME)
|
||||||
|
|
||||||
document_id = Digest::MD5.hexdigest(submitter.submission.slug).upcase
|
document_id = Digest::MD5.hexdigest(submitter.submission.slug).upcase
|
||||||
|
|
||||||
pdf.trailer.info[:DocumentID] = document_id
|
pdf.trailer.info[:DocumentID] = document_id
|
||||||
@@ -117,8 +119,6 @@ module Submissions
|
|||||||
font_size = (([page.box.width, page.box.height].min / A4_SIZE[0].to_f) * 9).to_i
|
font_size = (([page.box.width, page.box.height].min / A4_SIZE[0].to_f) * 9).to_i
|
||||||
cnv = page.canvas(type: :overlay)
|
cnv = page.canvas(type: :overlay)
|
||||||
|
|
||||||
cnv.font(FONT_NAME, size: font_size)
|
|
||||||
|
|
||||||
text =
|
text =
|
||||||
if submitter.account.testing?
|
if submitter.account.testing?
|
||||||
if with_signature_id
|
if with_signature_id
|
||||||
@@ -130,7 +130,17 @@ module Submissions
|
|||||||
"Document ID: #{document_id}"
|
"Document ID: #{document_id}"
|
||||||
end
|
end
|
||||||
|
|
||||||
cnv.text(text, at: [2, 4])
|
text = HexaPDF::Layout::TextFragment.create(
|
||||||
|
text, font:, font_size:, underlays: [
|
||||||
|
lambda do |canv, box|
|
||||||
|
canv.fill_color('white').rectangle(-1, 0, box.width + 2, box.height).fill
|
||||||
|
end
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
HexaPDF::Layout::TextLayouter.new(font:, font_size:)
|
||||||
|
.fit([text], page.box.width, page.box.height)
|
||||||
|
.draw(cnv, 1, font_size * 1.37)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user