Skip to content

Instantly share code, notes, and snippets.

@cabo
Created July 24, 2022 15:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cabo/c3927cafa495c6995973d9cc7653f5cb to your computer and use it in GitHub Desktop.
Save cabo/c3927cafa495c6995973d9cc7653f5cb to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rexml/document'
require 'open3'
default_fn = "svg-fig-00"
d = REXML::Document.new(ARGF)
REXML::XPath.each(d.root, "//svg:svg", {"svg" => "http://www.w3.org/2000/svg"}) do |x|
fn = default_fn.succ!
# insert code to override fn with @name of ancestor
o, s = Open3.capture2("rsvg-convert -f pdf", stdin_data: x.to_s)
File.write("#{fn}.pdf", o)
puts "#{fn}.pdf -- #{s.inspect}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment