Skip to content

Instantly share code, notes, and snippets.

@janxious
Forked from mustmodify/html5.html
Created December 20, 2011 01:28

Revisions

  1. janxious revised this gist Dec 20, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion svg.rb
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@
    def render_with_doc_raptor( html )
    DocRaptor.api_key SOME_KEY

    response = DocRaptor.create(:document_content => html, :document_type => :pdf, :name => 'filename.pdf', :test => true, 'doc[strict]' => 'none')
    response = DocRaptor.create(:document_content => html, :document_type => :pdf, :name => 'filename.pdf', :test => true, :strict => "none")

    puts "Response Code: #{response.code}"

  2. @mustmodify mustmodify revised this gist Dec 14, 2011. 1 changed file with 28 additions and 0 deletions.
    28 changes: 28 additions & 0 deletions svg.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    require 'rubygems'
    require 'doc_raptor'

    def render_with_doc_raptor( html )
    DocRaptor.api_key SOME_KEY

    response = DocRaptor.create(:document_content => html, :document_type => :pdf, :name => 'filename.pdf', :test => true, 'doc[strict]' => 'none')

    puts "Response Code: #{response.code}"

    if response.code == 200
    f = File.open('public/sample.pdf', 'w')
    f.puts response.to_s
    f.close

    puts "please check /sample.pdf"
    else
    puts "\n\n#{response.body}"
    end
    end

    Dir.glob('public/svg/*.*').each do |filename|
    f = File.open(filename, 'r')
    puts "======================================="
    puts "Trying #{filename}..."
    render_with_doc_raptor( f.read )
    puts "\n\n\n"
    end
  3. @mustmodify mustmodify revised this gist Dec 14, 2011. 2 changed files with 0 additions and 30 deletions.
    1 change: 0 additions & 1 deletion html5.html
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,3 @@

    <!DOCTYPE html>
    <html>
    <head>
    29 changes: 0 additions & 29 deletions svg.rb
    Original file line number Diff line number Diff line change
    @@ -1,29 +0,0 @@
    require 'rubygems'
    require 'doc_raptor'

    def render_with_doc_raptor( html )
    DocRaptor.api_key '9C8MER0MpgFroXug239m'

    response = DocRaptor.create(:document_content => html, :document_type => :pdf, :name => 'filename.pdf', :test => true, 'doc[strict]' => 'none')

    puts "Response Code: #{response.code}"

    if response.code == 200
    f = File.open('public/sample.pdf', 'w')
    f.puts response.to_s
    f.close

    puts "please check /sample.pdf"
    else
    puts "\n\n#{response.body}"
    end
    end

    Dir.glob('public/svg/*.*').each do |filename|
    f = File.open(filename, 'r')
    puts "======================================="
    puts "Trying #{filename}..."
    render_with_doc_raptor( f.read )
    puts "\n\n\n"
    end

  4. @mustmodify mustmodify revised this gist Dec 14, 2011. 4 changed files with 59 additions and 39 deletions.
    15 changes: 15 additions & 0 deletions html5.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@

    <!DOCTYPE html>
    <html>
    <head>
    <title>MathML and SVG in text/html</title>
    </head>
    <body>
    <a href="https://developer.mozilla.org/en/Code_snippets/Embedding_SVG">Source</a>
    <h1>SVG in text/html</h1>
    <p><svg height=86 width=90 viewBox='5 9 90 86' style='float: left;'>
    <path stroke=#F53F0C stroke-width=10 fill=#F5C60C stroke-linejoin=round d='M 10,90 L 90,90 L 50,14 Z'/>
    <line stroke=black stroke-width=10 stroke-linecap=round x1=50 x2=50 y1=45 y2=75 />
    </svg>
    </body>
    </html>
    15 changes: 15 additions & 0 deletions strict.xhtml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:svg="http://www.w3.org/2000/svg"
    xmlns:xlink="http://www.w3.org/1999/xlink">
    <body>
    <a href="https://developer.mozilla.org/en/Code_snippets/Embedding_SVG">Source</a>
    <p>hello</p>
    <svg:svg version="1.1" baseProfile="full" width="150" height="150">
    <svg:rect x="10" y="10" width="100" height="100" fill="red"/>
    <svg:circle cx="50" cy="50" r="30" fill="blue"/>
    </svg:svg>
    <p>world</p>
    </body>
    </html>
    39 changes: 0 additions & 39 deletions strict_xhtml_example.rb
    Original file line number Diff line number Diff line change
    @@ -1,39 +0,0 @@
    require 'rubygems'
    require 'doc_raptor'

    def render_with_doc_raptor( html )
    DocRaptor.api_key SOME_KEY_HERE

    response = DocRaptor.create(:document_content => html, :document_type => :pdf, :name => 'filename.pdf', :test => true, 'doc[strict]' => 'none')

    puts "Response Code: #{response.code}"

    if response.code == 200
    f = File.open('public/sample.pdf', 'w')
    f.puts response.to_s
    f.close

    puts "please check /sample.pdf"
    else
    puts "\n\n#{response.body}"
    end
    end

    # Example from https://developer.mozilla.org/en/Code_snippets/Embedding_SVG
    MOZILLA_XHTML_EXAMPLE = %|
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:svg="http://www.w3.org/2000/svg"
    xmlns:xlink="http://www.w3.org/1999/xlink">
    <body>
    <p>hello</p>
    <svg:svg version="1.1" baseProfile="full" width="150" height="150">
    <svg:rect x="10" y="10" width="100" height="100" fill="red"/>
    <svg:circle cx="50" cy="50" r="30" fill="blue"/>
    </svg:svg>
    <p>world</p>
    </body>
    </html>|

    render_with_doc_raptor( MOZILLA_XHTML_EXAMPLE )
    29 changes: 29 additions & 0 deletions svg.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    require 'rubygems'
    require 'doc_raptor'

    def render_with_doc_raptor( html )
    DocRaptor.api_key '9C8MER0MpgFroXug239m'

    response = DocRaptor.create(:document_content => html, :document_type => :pdf, :name => 'filename.pdf', :test => true, 'doc[strict]' => 'none')

    puts "Response Code: #{response.code}"

    if response.code == 200
    f = File.open('public/sample.pdf', 'w')
    f.puts response.to_s
    f.close

    puts "please check /sample.pdf"
    else
    puts "\n\n#{response.body}"
    end
    end

    Dir.glob('public/svg/*.*').each do |filename|
    f = File.open(filename, 'r')
    puts "======================================="
    puts "Trying #{filename}..."
    render_with_doc_raptor( f.read )
    puts "\n\n\n"
    end

  5. @mustmodify mustmodify created this gist Dec 14, 2011.
    39 changes: 39 additions & 0 deletions strict_xhtml_example.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,39 @@
    require 'rubygems'
    require 'doc_raptor'

    def render_with_doc_raptor( html )
    DocRaptor.api_key SOME_KEY_HERE

    response = DocRaptor.create(:document_content => html, :document_type => :pdf, :name => 'filename.pdf', :test => true, 'doc[strict]' => 'none')

    puts "Response Code: #{response.code}"

    if response.code == 200
    f = File.open('public/sample.pdf', 'w')
    f.puts response.to_s
    f.close

    puts "please check /sample.pdf"
    else
    puts "\n\n#{response.body}"
    end
    end

    # Example from https://developer.mozilla.org/en/Code_snippets/Embedding_SVG
    MOZILLA_XHTML_EXAMPLE = %|
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:svg="http://www.w3.org/2000/svg"
    xmlns:xlink="http://www.w3.org/1999/xlink">
    <body>
    <p>hello</p>
    <svg:svg version="1.1" baseProfile="full" width="150" height="150">
    <svg:rect x="10" y="10" width="100" height="100" fill="red"/>
    <svg:circle cx="50" cy="50" r="30" fill="blue"/>
    </svg:svg>
    <p>world</p>
    </body>
    </html>|

    render_with_doc_raptor( MOZILLA_XHTML_EXAMPLE )