Skip to content

Instantly share code, notes, and snippets.

@semihozkoroglu
Created January 14, 2012 22:23
Show Gist options
  • Save semihozkoroglu/1613113 to your computer and use it in GitHub Desktop.
Save semihozkoroglu/1613113 to your computer and use it in GitHub Desktop.
xml2pdf #eksik
require 'rexml/document'
include REXML
UTF8 = "<head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/></head>"
file = File.new( "yazılar.xml" )
doc = REXML::Document.new file
doc.elements.each("*/channel/item/") do |f|
garbage = File.new('foo.html',"w")
garbage.write(UTF8 + f.elements['title'].text + f.elements['content:encoded'].text)
garbage.close
%x{ touch '#{f.elements['title'].text}'.pdf }
%x{ wkhtmltopdf foo.html '#{f.elements['title'].text}'.pdf }
%x{ rm -rf foo.html }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment