GithubHelp home page GithubHelp logo

g21589 / wmf2canvas Goto Github PK

View Code? Open in Web Editor NEW
34.0 2.0 13.0 1.47 MB

Convert WMF/EMF (Windows Metafile) image file to HTML5 canvas by using pure javascript.

Home Page: http://g21589.github.io/wmf2canvas/

HTML 0.24% JavaScript 99.76%
html5-canvas javascript windows-metafile wmf emf

wmf2canvas's Introduction

wmf2canvas

MIT License

Convert WMF (Windows Metafile) image file to HTML5 canvas by using pure javascript.

Online Demo

http://g21589.github.io/wmf2canvas

Usage

<input type="file" id="file" accept="image/x-wmf" />
<canvas id="canvas"></canvas>

<script>
let wmf = new WMFConverter();   // new the WMFConverter object
	
let canvas = document.getElementById("canvas");
let file = document.getElementById("file");
	
file.onchange = function() {
	let filename = this.files[0];
	wmf.toCanvas(filename, canvas); // load the wmf file and convert to canvas graph
}
</script>

Version

0.9.1

License

MIT

wmf2canvas's People

Contributors

g21589 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

wmf2canvas's Issues

EMF support?

Thank you for making your library available.

The project mentions both WMF and EMF, but as far as I can see, there is no actual support for EMF. Am I missing something, or is EMF support just in the planning stages?

Font "Escapement" (angle)

This affects rotated text (for example, a vertical axis title in a chart)

The META_CREATEFONTINDIRECT record stores the angle in the Escapement field (https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-wmf/dabb1ed6-e5e8-4243-80ed-e63443e5484f). To be more precise, it stores the angle in tenths of a degree.

To support text angle, the following mantra works:

ctx.save();
ctx.translate(x_offset, y_offset);
ctx.rotate(-(escapement / 10) * Math.PI / 180);
ctx.fillText(text, 0, 0);
ctx.translate(-x_offset, -y_offset);
ctx.restore();

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.