Skip to content

Instantly share code, notes, and snippets.

@originalusername123
Last active May 20, 2018 20:25
Show Gist options
  • Save originalusername123/6b7ef310e5dabf938c0ec60b50434ef8 to your computer and use it in GitHub Desktop.
Save originalusername123/6b7ef310e5dabf938c0ec60b50434ef8 to your computer and use it in GitHub Desktop.
caracal-embedimage-windows-simplest-example
APP_ROOT = File.dirname(__FILE__)
$:.unshift(File.join(APP_ROOT, 'lib'))
require 'caracal'
Caracal::Document.save "superproject.docx" do |docx|
require 'base64'
data = File.open('lib\imagejpg.jpg', 'rb').read
finaldata = Base64.encode64(data)
print "The content of finaldata is #{finaldata}"
docx.img 'lib\imagejpg.jpg', data: finaldata, width: 400, height: 400, align: :right
docx.page
data2 = File.open('lib\imagepng.png', 'rb').read
finaldata2 = Base64.encode64(data2)
print "The content of finaldata is #{finaldata2}"
docx.img 'lib\imagepng.png', data: finaldata2, width: 400, height: 400, align: :right
end
system("start superproject.docx")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment