-2

Does anyone have examples of how to output in SVG format? I did a search on the boards and didn't get anything to return.

My output contest numbers.

I'd like to write string of numbers, like 1,2,3 on a middle of page.

  • 4
    Here is the spec for SVG 1.1: https://www.w3.org/TR/2003/REC-SVG11-20030114/ You can use a file stream to output into a file. There is no support for SVG processing in the standard library. – eerorika Jan 03 '17 at 14:43
  • 4
    Why not [Googling it first](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/text)? Outputting text with SVG is extremely simple. – Margaret Bloom Jan 03 '17 at 14:43
  • I googling it for hour but i still not find any solutions to my problem :( There is no support for SVG processing but my profesor still told us to do this as a home work :/ No idea what i'll do with this. – Jan Kowalski Jan 03 '17 at 14:50
  • There's plenty of learning SVG resources around such as this: https://www.w3.org/Graphics/SVG/IG/resources/svgprimer.html SVG is just XML so to output SVG in C++ there's lots of options e.g. http://stackoverflow.com/questions/303371/whats-the-easiest-way-to-generate-xml-in-c – Robert Longson Jan 03 '17 at 14:51
  • I go for it: some text but it dosent work in c++ – Jan Kowalski Jan 03 '17 at 15:12
  • What do you mean "it does't work in C++"? That might actually be a decent question. – Martin Bonner supports Monica Jan 03 '17 at 15:14

1 Answers1

0

As said in comment, just output the svg code you need in some I/O stream:

int main()
{
    int a = 5;
    std::cout << "<svg xmlns=\"http://www.w3.org/2000/svg\" width='100' height='100'>\n";
    std::cout << "<text x='10' y='20'>" << a << "</text>\n";
    std::cout << "</svg>\n";
}

Then compile:

$ g++ a.cpp

and run:

$ a.out > myfile.svg
kebs
  • 6,387
  • 4
  • 41
  • 70