jgraph / docker-drawio

Dockerized draw.io based on whichever is the most secure image at the time.
GNU General Public License v3.0
1.48k stars 359 forks source link

Unable to get image export to work using docker (docker-compose) #130

Closed hartzell closed 9 months ago

hartzell commented 9 months ago

This is likely to be a user-error, though perhaps it could lead to improved documentation.

My long term goal is to export each of the layers in a local file as an image that can be pasted into a PowerPoint (sigh) slide.

I'd really appreciate a minimal example, perhaps starting from docker-compose up and a URL to curl or ....

I'm working on a Mac, using Rancher desktop configured to use Docker/moby bits on the backend (e.g. as a license-free version of Docker Desktop for the Mac).

I've tried both the image-export and self-contained docker-compose configurations.

When I clone the project, cd into the self-contained subdirectory and run docker-compose up I am able to point a browser at http://localhost:8080/ and use the GUI diagramming tool, so basic things seem to be ok.

I can't figure out how to use the export server. I'm starting from example 2 in the draw-image-export project. The direct version of it complains about illegal characters (path obfuscated):

$ curl 'http://localhost:8080/ImageExport4/export\?format\=png\&bg\=ffffff\&url\=file:///path/to/diagram.drawio'
<!doctype html><html lang="en"><head><title>HTTP Status 400 – Bad Request</title><style type="text/css">body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 400 – Bad Request</h1><hr class="line" /><p><b>Type</b> Exception Report</p><p><b>Message</b> Invalid character found in the request target [&#47;ImageExport4&#47;export\?format\=png\&amp;bg\=ffffff\&amp;url\=file:&#47;&#47;&#47;path&#47;to&#47;diagram.drawio ]. The valid characters are defined in RFC 7230 and RFC 3986</p><p><b>Description</b> The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).</p><p><b>Exception</b></p><pre>java.lang.IllegalArgumentException: Invalid character found in the request target [&#47;ImageExport4&#47;export\?format\=png\&amp;bg\=ffffff\&amp;url\=file:&#47;&#47;&#47;Users&#47;georgehartzell&#47;projects&#47;20231113-how-to-git&#47;developer-flow.drawio ]. The valid characters are defined in RFC 7230 and RFC 3986
    org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:490)
    org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:263)
    org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63)
    org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:928)
    org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1794)
    org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)
    org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
    org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
    org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    java.base&#47;java.lang.Thread.run(Unknown Source)
</pre><p><b>Note</b> The full stack trace of the root cause is available in the server logs.</p><hr class="line" /><h3>Apache Tomcat/9.0.82</h3></body></html>%

I've tried, w/out success, not escaping with backslashes the bits in the URL.

Thinking that the file:// URL was giving me trouble, I started a little python webserver in the directory with the diagram.drawio file and tried passing that in, which returns a different error, The requested resource [&#47;ImageExport4&#47;export] is not available:


$ curl 'http://localhost:8080/ImageExport4/export?format=png&bg=ffffff&url=http://localhost:8765/diagram.drawio'
<!doctype html><html lang="en"><head><title>HTTP Status 404 – Not Found</title><style type="text/css">body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 404 – Not Found</h1><hr class="line" /><p><b>Type</b> Status Report</p><p><b>Message</b> The requested resource [&#47;ImageExport4&#47;export] is not available</p><p><b>Description</b> The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.</p><hr class="line" /><h3>Apache Tomcat/9.0.82</h3></body></html>%

I would love hints, clues, suggestions, or fully working examples that will help me on my way.

Thanks!
hartzell commented 9 months ago

Turns out that:

$ /Applications/draw.io.app/Contents/MacOS/draw.io  diagram.drawio --crop --export --format pdf --layers 2 --output diagram.pdf

Does what I need.

Sorry for the noise!