Code Monkey home page Code Monkey logo

meteor-html2docx's Introduction

HTML to docx

Meteor package for creating .docx files on the client from html.

Quick start

meteor add babrahams:html2docx

To create a link that triggers the download of a specified element as a .docx file:

{{> html2docx selector="#target-element"}}

with

<div id="target-element"><strong>HTML</strong> to be turned into a docx file</div>

(the selector parameter is required)

Options

When initiating the widget, use these parameters to configure it:

linkText="Download" changes the text of the link (default is "Download as Word document")

linkClass="my-class-for-links" puts a custom class attribute on the link (users of Bootstrap might use btn here)

linkStyle="text-decoration: none;" puts a custom style attribute on the link

linkTitle="Download as Word document" puts a title attribute on the link

css="h1 { color: red; }" adds a custom set of css rules to the .docx file that is generated

filename="my_word_doc" changes the name of the downloaded file (default is "export")

includeStylesheets=false means there will be no attempt to include css from the application's stylesheets (default is true)

useDocNotDocx=true produces .doc file instead of a .docx file (added because Word 2016 won't open html files with extension changed to .docx but it will open .doc files made this way)

Warning

This is not going to work in all browsers. See this post (from which inspiration for this package was drawn), and note that this package only uses the download attribute of the <a> tag. This will probably only work with recent versions of Chrome and Firefox.

Application styles will not appear in the .docx file as they appear in the app. To quote from the post above:

"Word supports a small, outdated subset of CSS. Properties such as background-color, color, font-size, font-weight, text-align, margin, and padding are supported. CSS3 selectors, as well as properties like float and position don’t work. You can give elements class and id attributes to target with a stylesheet."

meteor-html2docx's People

Contributors

jackadams avatar

Stargazers

Liam Waters avatar GuoYingxu avatar Matt Mills avatar Suhas Gavad avatar Maximilian Stroh avatar

Watchers

James Cloos avatar  avatar

meteor-html2docx's Issues

The exported file not getting imported.

  • I want to import the same exported file, when I exported and saved the docx file using this package, after that I was unable to import the same file again.
  • I am using a mammoth package to import the same file.
  • If I do Save As to same file and save it with different name then the newly saved file gets imported successfully.
  • I also checked online for the type of the file which was exported using package which shows the extension as html.

print90?

When exporting to word, I keep getting Print90 on the first line.

Also, it won't open in Pages..

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.