Class: WirisPlugin::ImageFormatControllerSvg

Inherits:
Object
  • Object
show all
Extended by:
ImageFormatControllerInterface
Includes:
Wiris
Defined in:
lib/com/wiris/plugin/impl/ImageFormatControllerSvg.rb

Instance Method Summary collapse

Methods included from ImageFormatControllerInterface

ImageFormatController

Constructor Details

#initializeImageFormatControllerSvg

Returns a new instance of ImageFormatControllerSvg.



10
11
12
# File 'lib/com/wiris/plugin/impl/ImageFormatControllerSvg.rb', line 10

def initialize()
    super()
end

Instance Method Details

#getContentTypeObject



13
14
15
# File 'lib/com/wiris/plugin/impl/ImageFormatControllerSvg.rb', line 13

def getContentType()
    return "image/svg+xml"
end

#getMetrics(bytes, ref_output) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/com/wiris/plugin/impl/ImageFormatControllerSvg.rb', line 16

def getMetrics(bytes, ref_output)
    svg = bytes::toString()
    svgRoot = Std::substr(svg,0,svg::indexOf(">"))
    firstIndex = svgRoot::indexOf("height=") + 8
    endIndex = svgRoot::indexOf("\"",firstIndex)
    height = Std::substr(svgRoot,firstIndex,endIndex - firstIndex)
    firstIndex = svgRoot::indexOf("width=") + 7
    endIndex = svgRoot::indexOf("\"",firstIndex)
    width = Std::substr(svgRoot,firstIndex,endIndex - firstIndex)
    firstIndex = svgRoot::indexOf("wrs:baseline=") + 14
    endIndex = svgRoot::indexOf("\"",firstIndex)
    baseline = Std::substr(svgRoot,firstIndex,endIndex - firstIndex)
    output = ref_output
    if output != nil
        PropertiesTools::setProperty(output,"width","" + width)
        PropertiesTools::setProperty(output,"height","" + height)
        PropertiesTools::setProperty(output,"baseline","" + baseline)
        r = ""
    else 
        r = (((("&cw=" + width) + "&ch=") + height) + "&cb=") + baseline
    end
    return r
end

#scalateMetrics(dpi, metrics) ⇒ Object



39
40
# File 'lib/com/wiris/plugin/impl/ImageFormatControllerSvg.rb', line 39

def scalateMetrics(dpi, metrics)
end