shairontoledo / rghost

RGhost is a document creation and conversion API. It uses the Ghostscript framework for the format conversion, utilizes EPS templates and is optimized to work with larger documents. Support(PDF,PS,GIF,TIF,PNG,JPG,etc)
http://rghost.rubyforge.org
MIT License
187 stars 46 forks source link

Using angle brackets with font tags produces incorrect output #60

Closed jerryjohnjacob closed 9 years ago

jerryjohnjacob commented 9 years ago

When using font tags to add text to a document, if the tag used contains opening and closing angle brackets, the resulting string on the output PDF is incorrect. For example,

<font_tag><></font_tag>

produces "font_tag /font_tag" on the final generated PDF document.

What can be done to avoid this?

shairontoledo commented 9 years ago

RGhost uses a very primitive parser to treat tags, you can either replace failing pattern before adding the text to your rghost document or patch the RGhost to be more smart for this kind of pattern.

jerryjohnjacob commented 9 years ago

So in the above example, what should the input be replaced with in order to achieve the desired output ("<>" itself)?

shairontoledo commented 9 years ago
text = "<font_tag><></font_tag>"
text.gsub(/<\s*>/, '')   #=> "<font_tag></font_tag>"
jerryjohnjacob commented 9 years ago

Thanks @shairontoledo :)