Comments (8)
Have you tried running the sample?
Here's the sample permalink.
from dxf-parser.
I'm able to get the sample working but can't get things to work in my liferay tomcat server.
from dxf-parser.
On the sample the parser is instanced like this:
var parser = new DxfParser();
Have you tried that?
from dxf-parser.
I've tried that, that gives me Uncaught ReferenceError: DxfParser is not defined at window.onload
For reference, the end goal is to securely display a dxf from a url using three-dxf. The sample that worked was from three-dxf.
from dxf-parser.
I managed to get a working example, I've never user javascript modules like this so it took me a while.
The index on the same is the same as the same here except for the import of the dxf-parser.js
.
I load the dxf-parser.js
on index.js
, import de module there and set the window.DxfParser
value so the index.hml
can use it.
The dxf-parser.js
on the sample is made by running npm run build
with a change on the webpack.config.js
. I changed the property libraryExport: 'default'
to libraryExport: 'this'
.
from dxf-parser.
Thank you very much for your help. I believe the issue came from my lack of understanding of webpack. Changing to libraryTarget:'this'
appears to solve my problem.
Relevant code in case someone comes wants to read a dxf from a URL:
<script src="/html/portlet/document_library/js/dxf-parser.js"></script>
<script type="text/javascript">
var request = new XMLHttpRequest();
var fileText;
request.open('GET', document.getElementById('file_to_show').getAttribute('data-file-location'), true);
request.responseType = 'blob';
request.onload = function() {
var reader = new FileReader();
reader.readAsDataURL(request.response);
reader.onload = function(e){
fileText = e.target.result;
fileText = atob(fileText.substr(fileText.indexOf(',')+1));
var parser = new window.DxfParser();
var dxf = null;
try {
dxf = parser.parseSync(fileText);
} catch(err) {
return console.error(err.stack);
}
console.log('Success!');
console.log("DXF JSON:" + JSON.stringify(dxf,null,4));```
from dxf-parser.
You are welcome, remember to close the issue if it's already solved.
from dxf-parser.
Thanks for helping with this @Serthys
I was last working toward modularizing this library to work better with react, angular or other module-oriented libraries. Sorry I have not been very responsive. Been a bit overwhelmed between work and moving. :)
from dxf-parser.
Related Issues (20)
- Group code does not have a defined type:
- 'should parse MULTILEADER entities' test fails because `leaders.dxf` is missing HOT 1
- Test 'should parse a complex BLOCKS section' is failing
- Problem with parsing/showing ARC entity HOT 3
- Can read/write DXF files in binary form? HOT 1
- final vertex of 3DFACE not being added to entity vertex list when encountering a code other than 0
- How to combine color of walls with color of closed area
- I decided this repo was dead and created a new parser repository.
- Support for pdf HOT 1
- How to handle large points HOT 1
- DxfParser export seems broken HOT 1
- `TypeError: Cannot call a class as a function` in tests
- npm or yarn? HOT 1
- Compilation issue with ParseHelpers HOT 3
- Question - Ability to read group of elements HOT 1
- How can get perimeter of DXF File ?
- Parsing blocks with attributes HOT 1
- The angle always in radians
- Types?
- How to convert to DXF JSON
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 dxf-parser.