Last active
June 5, 2024 19:58
-
-
Save aashish/f472f62ce0202eae8a33c2531649f5d6 to your computer and use it in GitHub Desktop.
Revisions
-
aashish revised this gist
Jun 5, 2018 . No changes.There are no files selected for viewing
-
aashish created this gist
Jun 5, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ require 'hexapdf' doc = HexaPDF::Document.open("/home/xxxx/Downloads/OoPdfFormExample.pdf") page = doc.pages[0] canvas = page.canvas(type: :overlay) canvas.translate(0, 20) do canvas.fill_color(0.3, 0.7, 0.7) canvas.rectangle(50, 0, 80, 80, radius: 80) canvas.fill solid = canvas.graphic_object(:solid_arc, cx: 190, cy: 40, inner_a: 20, inner_b: 15, outer_a: 40, outer_b: 30, start_angle: 10, end_angle: 130) canvas.line_width(0.5) canvas.opacity(fill_alpha: 0.5, stroke_alpha: 0.2) do canvas.image(File.join(__dir__, 'cloud.png'), at: [350, 0], height: 80) canvas.image(File.join(__dir__, 'freepik.jpg'), at: [50, 400], height: 80) end end doc.write('/home/xxxx/Downloads/graphics.pdf', optimize: true)