Comments (16)
Thanks for the update
from html-to-docx.
@privateOmega I've just tested it and import htmlToDocx from 'html-to-docx'
leads to the same error. I've also tested import {htmlToDocx} from 'html-to-docx'
and const htmlToDocx = require('html-to-docx')
as well as const htmlToDocx = require('html-to-docx/dist/html-to-docx.esm')
and const htmlToDocx = require('html-to-docx/dist/html-to-docx.umd')
all of them throwing the previously mentioned error.
from html-to-docx.
Update: I've found out that this issue only occurs when targeting ES5. When targeting ES2015 in Angular html-to-docx works like a charm. Unfortunately targeting es2015 is not an option for us. I'll try to further investigate this issue
from html-to-docx.
@meta-akshita-agrawal Could you please post some details about what you have tried so far? A snippet of code or description would do.
from html-to-docx.
I tried
import * as htmlToDocx from 'html-to-docx'
import {htmlToDocx} from 'html-to-docx'
const htmlToDocx = require('html-to-docx')
also here is one of your example I tried to import this too. But that didn't work too
from html-to-docx.
@meta-akshita-agrawal What do you mean it didn't work? Any particular errors or it says htmlToDocx is undefined or something? Could you please post the exact log?
from html-to-docx.
While doing npm start
ERROR in ./node_modules/clean-css/lib/reader/read-sources.js Module not found: Error: Can't resolve 'fs' in 'node_modules\clean-css\lib\reader' ERROR in ./node_modules/clean-css/lib/reader/apply-source-maps.js Module not found: Error: Can't resolve 'fs' in 'node_modules\clean-css\lib\reader' ERROR in ./node_modules/clean-css/lib/reader/load-original-sources.js Module not found: Error: Can't resolve 'fs' in 'node_modules\clean-css\lib\reader' ERROR in ./node_modules/html-to-docx/node_modules/image-size/dist/index.js Module not found: Error: Can't resolve 'fs' in 'node_modules\html-to-docx\node_modules\image-size\dist' ERROR in ./node_modules/html-to-docx/node_modules/image-size/dist/fs.promises.js Module not found: Error: Can't resolve 'fs' in node_modules\html-to-docx\node_modules\image-size\dist' ERROR in ./node_modules/html-to-docx/node_modules/image-size/dist/types/tiff.js Module not found: Error: Can't resolve 'fs' in 'node_modules\html-to-docx\node_modules\image-size\dist\types' ERROR in ./node_modules/uglify-js/tools/node.js Module not found: Error: Can't resolve 'fs' in 'node_modules\uglify-js\tools' Error from chokidar (C:\): Error: EBUSY: resource busy or locked, lstat 'C:\hiberfil.sys' Error from chokidar (C:\): Error: EBUSY: resource busy or locked, lstat 'C:\DumpStack.log.tmp' Error from chokidar (C:\): Error: EBUSY: resource busy or locked, lstat 'C:\pagefile.sys' Error from chokidar (C:\): Error: EBUSY: resource busy or locked, lstat 'C:\swapfile.sys'
from html-to-docx.
@meta-akshita-agrawal Yup that error log makes sense, because fs
is a node.js module, hence stubbed out in browser environment and I forgot that I use a dependency which internally depends on fs module.
This has been a long running issue that I haven't had much time to focus on, I had created a branch for that. I will try to work on it sometime soon.
In the meanwhile I guess you can install using that branch and it should work, but you might be missing out on some features for the time being, which I can hopefully rebase it to latest version by tonight.
Closing this issue to track it at one place.
from html-to-docx.
@privateOmega any update on when that branch can be rebased on the latest version? I'm guessing it didn't happen "tonight" (16 days ago) ;)
from html-to-docx.
@joeskeen Please checkout the branch now, it was rebased against develop, hence should have the latest features, unfortunately I can't commit any time at present to this feature now due to my other commitments, but it should work for your use case I guess. Feel free to comment below, if you are facing some issues on that.
from html-to-docx.
@privateOmega Thank you for this long awaited feature :)
I am currently trying to get it to work in an Angular Application using the following code:
import * as htmlToDocx from 'html-to-docx/dist/html-to-docx.umd'
[...]
const htmlString = '<b>Test</b>'
const fileBuffer = await htmlToDocx(htmlString, null, {
table: {row: {cantSplit: true}},
footer: true,
pageNumber: true,
});
saveAs(fileBuffer, "document.docx");
However I am getting the following error:
ERROR Error: Uncaught (in promise): TypeError: Cannot call a class as a function
TypeError: Cannot call a class as a function
at _classCallCheck (classCallCheck.js:3)
at new NodeImpl (NodeImpl.js:18)
at DocumentImpl._createSuperInternal (createSuper.js:15)
at new DocumentImpl (DocumentImpl.js:21)
at Object.create_document (CreateAlgorithm.js:55)
at new WindowImpl (WindowImpl.js:19)
at Function._create (WindowImpl.js:29)
at Object.create_window (CreateAlgorithm.js:41)
at DOMImpl.get (DOMImpl.js:53)
at new DOMImplementationImpl (DOMImplementationImpl.js:18)
at resolvePromise (zone.js:1255)
at zone.js:1162
at rejected (components-gvp-overview-gvp-module.js:66753)
at ZoneDelegate.invoke (zone.js:400)
at Object.onInvoke (core.js:28553)
at ZoneDelegate.invoke (zone.js:399)
at Zone.run (zone.js:160)
at zone.js:1318
at ZoneDelegate.invokeTask (zone.js:434)
at Object.onInvokeTask (core.js:28540)
Any Ideas on how to resolve that?
from html-to-docx.
@tco7878 Why are you importing and using the umd build?
Can't you just do import * as htmlToDocx from 'html-to-docx'
and I guess that should work.
from html-to-docx.
@privateOmega thanks for your answer. Unfortunately this does not help. I did try importing from 'html-to-docx' as well as importing the esm and umd build directly. The error remains the same
My Angular project is targeting ES5 maybe it is related to that.
from html-to-docx.
@tco7878 Sorry I couldn't be of more help, I am not that used to typescript and also just curious, do you get the the same error when you use the import * as htmlToDocx from 'html-to-docx'
? and also see if import htmlToDocx from 'html-to-docx'
works for you?
from html-to-docx.
Any update about this issue @tco7878 @privateOmega ?
from html-to-docx.
As a workaround, you can use
// @ts-ignore
from html-to-docx.
Related Issues (20)
- support for line breaks like <br> tag HOT 2
- imgs with src as base64 do not come over
- Is width = 100% achievable?
- How to resize images - is it possible?
- Images & style doesn't apply well in .docx file HOT 4
- html to docx conversion raise an error when it transform a table with merged cell
- Margins don't work
- ADD page break if content doesn't have enough room
- XML error when using with Vite (React or Vue)
- browser webpack error
- How to preserve border-bottom without table
- Refactoring work done HOT 4
- bug: when an image is nested under spans, xml-builder doesn't pick up the img tag
- README.md does not show how to load the HTMLtoDOCX function HOT 2
- Nested formatting tags are not getting applied
- STRIKE THROUGH Not working HOT 3
- Reference error : ReferenceError: HTMLToDOCX is not defined.
- Uncaught TypeError: Class extends value undefined is not a constructor or null
- ul element not properly displayed HOT 1
- Nuxt 3 (no SSR)+ Vite not working - Cannot read properties of undefined (reading 'prototype')
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from html-to-docx.