Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6225193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:47:57+00:00 2026-05-24T08:47:57+00:00

I am developing a drawing app, and now I want to add a function

  • 0

I am developing a drawing app, and now I want to add a function which creates SVG from my canvas or control points. (I save the mouse coordinates for each drawing step).

canvasElement.toDataURL("image/svg+xml"); // -- doesn't work

One condition – don’t use external libs.

I understand, that it is possible to generate an SVG file in Javascript like:

var mysvg = "<svg>"; for(something) { mysvg += "something"; } //etc

But I don’t think that it is good way.

Can you advise anything?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T08:47:58+00:00Added an answer on May 24, 2026 at 8:47 am

    I solved the problem by generating SVG file. I translated all my canvas drawing functions into SVG drawing tags.

    Something like that:

    function exportSVG() {
        var svg = '<?xml version="1.0" standalone="yes"?>';
    svg += '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">';
    svg += '<svg width="1065px" height="529px" xmlns="http://www.w3.org/2000/svg" version="1.1">';
    
    for(var i=0; i<myPoints.length; i++) {
       svg += "M"+myPoints.x[i]+","+myPoints.y[i]+" ";
       svg += "L"+myPoints.x[i+1]+","+myPoints.y[i+1];
       svg += '" fill="none" stroke="rgb('+color+')" stroke-opacity="'+opacity+'" stroke-width="'+size+'px" stroke-linecap="round" stroke-linejoin="round" />';
    }
    svg += "</svg>";
    }
    

    So, in svg variable there will be SVG file generated from Canvas.
    Thanks everybody!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing a custom control, which most resembles a text area. I am drawing
I am developing an iPad application which is basically a big drawing canvas with
I am developing an application and drawing SVG files, lines and images on canvas.
I'm developing a line drawing game, similar to Flight Control, Harbor Master, and others
I'm developing an application for Google App Engine which uses BigTable for its datastore.
I'm developing a live wallpaper app which will draw an analog clock. So far
I'm developing a painter program using HTML5 canvas. I have created a drawing tool
I'm developing an application in which I'm pasting images, doing drawing and painting on
I'm developing and C# app for Windows Mobile . I have a custom control
I am developing an ipad app with openGL. In my app basically I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.