Comments (6)
As far as I know csp restricts from appending <style> into document, but not from creating <style> element. Knowing that, there is one quick workarround but only for chrome (for know), but maybe it will give you some ideas for futher investigation:
var container = document.getElementById("doc");
// create dummy container for styles
var stylesContainer = document.createElement("div");
docx.renderAsync(file, container, stylesContainer).then(function(x){
// convert rendered styles into CSSStyleSheet
var styles = Array.from(stylesContainer.children).map(s => {
var css = new CSSStyleSheet();
css.replaceSync(s.innerHTML);
return css;
});
// apply styles to document
document.adoptedStyleSheets = styles;
// or apply styles to each element of content container manually
});
from docxjs.
I'm working on this.
from docxjs.
Hi,
Potentially it's possible to apply all styles via element styles, but there come issues
- custom fonts will not be supported
- numbering may not work correctly
from docxjs.
@theimo1221 I think a good compromise might be to load the docxjs script and other helper scripts like jszip inside an iframe and then use the CSP (<iframe csp=""
) attribute.
Have you tried this ?
from docxjs.
I did and it didn't work in our application.
But I found a proper work around and added it as a setting.
You can check my fork, from which I'll open more PR's once the current ones are merged.
from docxjs.
#17 resolves the topic for me.
from docxjs.
Related Issues (20)
- docx file is too large,can't find end of central directory: is this a zip file HOT 5
- The image will cover the text
- render document style error, Transparent shapes will be rendered black by plugin HOT 2
- SIMPLE FIX - Compile error : TS7010 'renderDocument', which lacks return-type annotation, implicitly has an 'any' return type. HOT 1
- SIMPLE FIX - "praseAsync" should be renamed to "parseAsync" HOT 1
- Failed to parse source map
- Retrieve image files and hyperlinks.(parseAsyn) HOT 1
- [BugReport]Can not show file preview correctly on mobile(simulation) HOT 2
- Text box cannot be displayed
- Uncaught ReferenceError: docx is not defined HOT 1
- Support for .docx comments?
- [FEATURE REQUEST] - Add support for link, svg files, chart
- [BUG] - Multi page docx is rendered as single page html HOT 1
- The chart content cannot be displayed
- When innerHtml container, image doesnt has src value HOT 1
- remote file's ab cannot be turn into WordDocument? HOT 1
- Mjs error after updating version HOT 5
- Mobile style HOT 1
- Numbering Styling Missing HOT 2
- docx file preview appears text box lines disappear
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 docxjs.