I'm working on a web application that manages VRML files. I also want to let users see the uploaded files, without requiring a specific plug-in or player. X3DOM allows viewing X3D files without plug-ins on most browsers, so I'd like to use it.
Alas, it works on X3D files, and not VRML files. I need to convert VRML files to the X3D format.
The same people behind X3DOM released a package called InstantReality that has a utility that converts VRML to X3D. However, I'd much rather not use an external utility (I'm not even sure I'm allowed to use it on a commercial environment, I couldn't find its terms of use) but call a conversion routine from my application code.
MeshLab! There's an opensource project called MeshLab that does all sorts of processing on 3D meshes. It also has a command-line tool called MeshlabServer.
Running meshlabserver.exe -i <wrl file> -o <x3d file> performs the conversion (very quickly). Since it's open-source, I don't have any licensing issues.
are you talking about this online converter?
http://doc.instantreality.org/tools/x3d_encoding_converter/
you could probably build some scripting to convert the vrml to x3d/x3dom and then store and or display
as well blender aopt and others should be able to convert vrml to x3d on the command line. depending on your servers os this could be batched/scripted as well
im in a rush to get some other work done but hope this helps.
let me know if you need more info or examples and ill see what i can do
I also needed to convert VRML .wrl to .x3d; I tried meshlab (meshlabserver), but unfortunately, the version I have (.deb 2016.12~trusty2 on Ubuntu 14.04) compacts everything to a single mesh, and looses color in the process.
I found that view3dscene can do conversion from the command line, where the materials/colors are preserved in .x3d, as they were in .wrl:
view3dscene mymodel.wrl --write --write-encoding xml > mymodel.x3d
Since view3dscene functions as a viewer for both .wrl and .x3d files, it can also be used immediately, to check if the converted (or the original) file has colors or not.
ok so i think this is the full solution for you
1) user uploads a vrml file
2) that file gets saved to (file or db)
3) upon confirmation that the vrml file has been saved (and possibly validated as correct vrml syntax) it gets converted and saved to x3d (again as file or db) , with aopt this would be accomplished by aopt -i input.wrl -o output.x3d
FYI: aopt is avail for linux windows and mac
since you use python this maybe a way you could do it as well with blender although there are no full example of vrml to x3d this link should get you started
http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Import-Export/Wavefront_OBJ#Command_Line_Converting
4) display the x3d via x3dom
Since the ClassicVRML X3D Encoding is a direct successor of the VRML97 standard, in most cases you can copy the file, rename the .wrl file extension to a .x3dv file extension, and change the scene header from
#VRML V2.0 utf8
to
#VRML V3.3 utf8
PROFILE Immersive
Many converters exist, both commercial and open source. Several are integrated with X3D-Edit. A full list is maintained at
X3D Resources: Conversions and Translation Tools
http://www.web3d.org/x3d/content/examples/X3dResources.html#Conversions
Personal favorite:
Castle Game Engine: Convert everything to X3D
https://castle-engine.io/convert.php
If you simply want to convert X3D XML encoded files to VRML Classic encoded files you can use Titania, http://titania.create3000.de/. Open your .x3d file and save it as .x3dv or .wrl.
Titania also comes with a command line utitity »x3dtidy« that can do the conversion too.
You can use this tool (a java jar that can be run from the command line) to convert VRML to X3D:
http://www.deem7.com/vrmlmerge/howto.php
java -jar VrmlMerge-[version].jar -convert inputfile.wrl [outputfile.x3d]
The license:
VrmlMerge is free for non-commercial use. If you somehow make money out of VrmlMerge then I'd like you to contact me to agree on some terms of use. VrmlMerge is provided "as is" and I don't take any responsibility for any damage it can make to you, your computer, files, data, wife, brain etc..
Related
So I am generating reports with Python and Ninja in the ASCIIDoc format.
But from within my app I need to convert them into PDF and upload them to another system.
I have seen that there are multiple HowTo for command line that involve ASCIIDoctor or other tools, but they always are invoked at OS level by starting a program or running a docker container and writing the output to a file.
Isn't there a way to perform those action within my app and get the PDF as a string that I can use for the upload?
You can certainly use the available tools to generate a PDF, which you could then read into memory as an opaque string that could be uploaded as needed.
If your question is: how do I generate and upload a PDF without installing any other tools?
Then the answer is that you'd have to implement the PDF generation logic yourself, rather than using tested tooling.
Is it possible to convert Dwg to pdf file using Python?
I have multiple Dwg files that need to convert to pdf.
I am experimenting to create an app to convert but can not find any solution?
Please, if you have any idea help.
Vector Express is a free API you may able to use. (requires a network connection, though)
https://github.com/smidyo/vectorexpress-api
Of course it is possible to write a code in Python to publish DWG file as PDF.
However, DWG is a proprietary file format from AutoCAD, therefore there are a lot of legal issues to distribute the code (beyond your private usage), unless you get a written consent from AutoCAD...
You'll find several application that would already do the job.
Maybe check Open Design Alliance as a starting point.
Using QCAD Command Line Tools (Open Source)
According to qcad.org "QCAD is a free, open source application for computer aided drafting (CAD) in two dimensions (2D). With QCAD you can create technical drawings such as plans for buildings, interiors, mechanical parts or schematics and diagrams. QCAD works on Windows, macOS and Linux. The source code of QCAD is released under the GPL version 3 (GPLv3), a popular Open Source license."
Supported Command Line Conversions
dwginfo
dwg2csv
dwg2bmp
dwg2svg
dwg2pdf
dwgmapconvert
dwg2maptiles
dwg2dwg / pdf2dwg
dwghatch
dwghatcharea
dwgexplode
merge
bbox
dwgnest (QCAD/CAM)
The above commands are very self-explanatory for further information please refer to the above embedded url at qcad.org
Usage in Python
Though I believe that this might not be best practice but a os.system command as follows, might be enough for most use cases
I'm running a RHEL7 system as a web server using Django 1.8.2
I'm researching a solution where a PostScript (PS) file can be uploaded by a Django API and is then converted to either a PDF or Image (such as JPG or PNG).
I put Django or Python, since it doesn't matter whether Django handles the conversion, or passes it off to a pure Python script and receives the result back.
I've been looking into Ghostscript, but I'm coming up with this error...
$ gs -sDEVICE=pdfwrite -sOutputFile=test.pdf -dBATCH -dNOPAUSE file.ps
GPL Ghostscript 9.05 (2012-02-08)
Copyright (C) 2010 Artifex Software, Inc. All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Loading NimbusMonL-Regu font from /usr/share/fonts/type1/gsfonts/n022003l.pfb... 2849640 1507460 4012484 2498014 1 done.
%%[ Error handled by opdfread.ps : undefined; OffendingCommand: 9!_NGH!_NGH! ]%%
%%[STACK:
--nostringval--
14
%%]%
Open to any solutions. Thanks!
===
#KenS
Thanks for pointing out my failure to include an example of the PS file.
file.ps
It looks like your (PostScript) file was originally produced by using Ghostscript to convert a PDF to PostScript. It also looks very much like your PostScript file has been corrupted, it is trying to interpret binary (probably image) data as language tokens.
This may possibly have happened as a result of CR/LF translation, but in any event the reason Ghostscript is throwing you an error is because your PostScript program is broken. It doesn't matter what software you try to use on it, it won't work, the program is (most likely irretrievably) broken.
Of course this is speculation, since you have not posted a URL to the PostScript file.
I'd suggest that you try with one of the sample files in the Ghostscript folder, such as tiger or golfer, those are known to work.
You should also consider using a more up to date version of Ghostscript, 9.05 is 3 years old now.
We have a project in python with django.
We need to generate complex word, excel and pdf files.
For the rest of our projects which were done in PHP we used PHPexcel ,
PHPWord and tcpdf for PDF.
What libraries for python would you recommend for creating this kind of files ? (for excel and word its imortant to use the open xml file format xlsx , docx)
Python-docx may help ( https://github.com/mikemaccana/python-docx ).
Python doesn't have highly-developed tools to manipulate word documents. I've found the java library xdocreport ( https://code.google.com/p/xdocreport/ ) to be the best by far for Word reporting. Because I need to generate PCL, which is efficiently done via FOP I also use docx4j.
To integrate this with my python, I use the spark framework to wrap it up with a simple web service, and use requests on the python side to talk to the service.
For excel, there's openpyxl, which actually is a python port of PHPexcel, afaik. I haven't used it yet, but it sounds ok to me.
I would recommend using Docutils. It takes reStructuredText files and converts them to a range of output files. Included in the package are HTML, LaTeX and .odf file writers but in the sandbox there are a whole load of other writers for writing to other formats, see for example, the WordML writer (disclaimer: I haven't used it).
The advantage of this solution is that you can write plain text (reStructuredText) master files, which are human readable as is, and then convert to a range of other file formats as required.
Whilst not a Python solution, you should also look at Pandoc a Haskell library which supports a much wider range of output and input formats than docutils. One major advantage of Pandoc over Docutils is that you can do the reverse translation, i.e. WordML to reStructuredText. You can try Pandoc here.
I have never used any libraries for this, but you can change the extension of any docx, xlsx file to zip, and see the magic!
Generating openxml files is as simple as generating couple of XML files (you can use templates) and zipping it.
Simplest way to generate PDF is to generate HTML (with CSS+images) and convert it using wkhtmltopdf tool.
I'm creating a "slideshow room" web page. The user will upload a PowerPoint file that my server will use to generate a set of .jpg image files representing the slides to present in a custom "gallery viewer".
I'm an experienced Python developer but I cannot find anything useful.
How can I do that?
Off the top of my head, the way I'd do it:
Use OpenOffice.org to convert the .ppt file into a PDF. (OO.o has a very rich Java API. Rich and bloody difficult to use, mind, but once you figure out how to get it to do the task you need, you're all set. Dunno if you can do anything useful with it via Python; not my language.)
Use ImageMagick to convert the PDF into .jpg files. (Though I've been told converting the PDF into a PS file before turning it into images gives better results.) (IM's command line interface is damn near a language unto itself -- though again, once you figure out how to get it to do what you want, you're all set.)
Dunno if that's the most efficient/reliable way to do it. But fundamentally, I'd be on Google trolling for open-source third party tools that do all the dirty work for me.
Apache POI and Jython. POI, even has an ImageExtractor class, but having just glanced at the Javadocs, I suspect it is incomplete.
Are you doing this on Windows? If so win32 com:
import win32com.client
Application = win32com.client.Dispatch("PowerPoint.Application")
Application.Visible = True
Presentation = Application.Presentations.Open(pathToPPT)
Presentation.Slides[1].Export("C:/path/to/jpg.jpg", "JPG", 800, 600);
etc...