GithubHelp home page GithubHelp logo

jgraph / draw-image-export2 Goto Github PK

View Code? Open in Web Editor NEW
41.0 41.0 28.0 122 KB

The 2018 server-side PNG/PDF export implementation using Node, Puppeteer and Chrome headless

License: Apache License 2.0

JavaScript 99.82% Procfile 0.18%

draw-image-export2's People

Contributors

alderg avatar davidjgraph avatar m-mohamedin avatar squared9 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

draw-image-export2's Issues

On how to use it?

How should this project be used in the VUE project? NPM Start is called after the direct error, how to use the method in detail, does not seem to have a good example

PDF Generation issue

Why sometimes PDF will not generate- 500 internal server error .
Not sure - may be because of file size ??
PDF generation supports - How much file size?

Render background grid

Hi all, is there a way to tell exporter to render the background grid?

I'm trying to automate the diagram generation in project and we must generate with the grid!

This is image exported directly from draw.io:

image

And this is the image exported using this service:

image

CPU count detection works wrong

Latest commit introduced pool of workers, based on os.cpus().length.
This features works wrong in Linux containers, where it may see all the physical cores (e.g. 32), but the container is limited to a lesser value (e.g. 1), and thus it creates unreasonably large pool.

More reliable detection for containers would be to attempt to read something like /sys/fs/cgroup/cpu/cpu.cfs_quota_us and /sys/fs/cgroup/cpu/cpu.cfs_period_us, but the more simple and straightforward way would be to just support passing pool size via some environment variable, something like process.env.WORKER_POOL_SIZE.

Could you support it please?

Support export to svg

Would be useful support converting a diagram to SVG format.

It is possible to export to a raster (PNG or jpg) or a vector (pdf), but not a vector format that can be natively displayed within a webpage (like a PNG can).

This is possible if the diagram can be exported in svg+xml format.

Should be possible to achieve this in the section of export.js where the PNG/jpg image is extracted (albeit via a screenshot).

The diagram can be exported to svg in draw.io so should be possible to include this logic here, if not possible to retrieve the SVG data as it stands.

npm install fails in node_modules/puppeteer

node 18.2.0
npm 8.12.2
FreeBSD 13.1 amd64

[/tmp]$ git clone https://github.com/jgraph/draw-image-export2.git
…
[/tmp/draw-image-export2]$ cd draw-image-export2
[/tmp/draw-image-export2]$ npm install
npm notice 
npm notice New minor version of npm available! 8.12.2 -> 8.13.1
npm notice Changelog: https://github.com/npm/cli/releases/tag/v8.13.1
npm notice Run npm install -g [email protected] to update!
npm notice 
npm ERR! code 1
npm ERR! path /tmp/draw-image-export2/node_modules/puppeteer
npm ERR! command failed
npm ERR! command sh -c node install.js
npm ERR! /tmp/draw-image-export2/node_modules/puppeteer/lib/cjs/puppeteer/common/assert.js:26
npm ERR!         throw new Error(message);
npm ERR!               ^
npm ERR! 
npm ERR! Error: Unsupported platform: freebsd
npm ERR!     at assert (/tmp/draw-image-export2/node_modules/puppeteer/lib/cjs/puppeteer/common/assert.js:26:15)
npm ERR!     at BrowserFetcher.setPlatform (/tmp/draw-image-export2/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserFetcher.js:184:36)
npm ERR!     at new BrowserFetcher (/tmp/draw-image-export2/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserFetcher.js:168:14)
npm ERR!     at PuppeteerNode.createBrowserFetcher (/tmp/draw-image-export2/node_modules/puppeteer/lib/cjs/puppeteer/node/Puppeteer.js:188:16)
npm ERR!     at downloadBrowser (/tmp/draw-image-export2/node_modules/puppeteer/lib/cjs/puppeteer/node/install.js:51:46)
npm ERR!     at download (/tmp/draw-image-export2/node_modules/puppeteer/install.js:86:3)
npm ERR! 
npm ERR! Node.js v18.2.0

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2022-06-27T18_54_59_374Z-debug-0.log

Do you need log-file?

Self-Signed Certificate

Hi all.

Please tell me how puppeteer.js can solve the problem with a self-signed certificate for the address that points to DRAWIO_BASE_URL.

image-export:
        build:
           dockerfile: Dockerfile
           context: ./export        
        expose:
            - "8000"
        networks:
         - drawionet
        restart: always
        environment: 
          - WORKER_POOL_SIZE=1
          - DRAWIO_BASE_URL=https://local.space.d.net

ca-cartificate-update only solves the problem for curl.

warn: Handled exception: net::ERR_CERT_AUTHORITY_INVALID at https://local.space.d.net/export3.html req=ip=::ffff:172.25.0.3 format=pdf w=0 h=0 bg=%23ffffff {"stack":"Error: net::ERR_CERT_AUTHORITY_INVALID at https://local.space.d.net/export3.html\n at navigate (/home/pptruser/draw-image-export2/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/Frame.js:171:27)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async Deferred.race (/home/pptruser/draw-image-export2/node_modules/puppeteer-core/lib/cjs/puppeteer/util/Deferred.js:36:20)\n at async CdpFrame.goto (/home/pptruser/draw-image-export2/node_modules/puppeteer-core/lib/cjs/puppeteer/cdp/Frame.js:137:25)\n at async CdpPage.goto (/home/pptruser/draw-image-export2/node_modules/puppeteer-core/lib/cjs/puppeteer/api/Page.js:590:20)\n at async renderPage (/home/pptruser/draw-image-export2/export.js:569:8)\n at async handleRequest (/home/pptruser/draw-image-export2/export.js:711:20)"}

I found a solution by putting the '--ignore-certificate-errors' flag in puppeteer.launch, but I'm not completely satisfied with it

browser = await puppeteer.launch({
	headless: 'new',
	args: ['--disable-gpu', '--no-sandbox', '--disable-setuid-sandbox', '--disable-dev-shm-usage', '--ignore-certificate-errors']
});

Unable to export a specified page when a preceeding page contains brackets in its name

This diagram diagram has 3 pages:

  1. "First page"
  2. "Second page (of 2)"
  3. "Page-3"

Note, the file has been renamed from Sample file.xml to Sample file.txt to support GitHub attachment.

It is possible to export "First page" by specifying the pageId=0 parameter in an export request.

It is not possible export "Second page (of 2)" with the pageId=1 parameter in an export request, this is always interpreted as the last page. In short, "Page-3" gets rendered in every case, except where pageId=0.

This has been tested where the page names do not contain brackets and it behaves as expected.

The export url being used is: https://exp.draw.io/ImageExport4/export

With a payload equivalent to:

filename=preview&format=png&xml=

<file content>&base64=O&bg=#ffffff&w=500&h=500&border=1&pageId=1

Can you confirm if this is an issue or whether the export route requires different parameters?

Error 500 - testing

Is there a curl command that I can use to test my build? I am getting an error 500 when exporting from a local draw.io build.

I tried this but I got an error:
curl http:///?format=png&bg=ffffff&url=/#Lkarim.xml

But I get a message stating "Bad Request"

Is there a curl command I can use that can pull from a local drawio xml file and output to PDF?

documentation unclear

A collection of questions after reading the README:

The 2018 server-side PNG/PDF export

Does the "2018" part mean it is deprecated?

Updating internal draw.io versions
su chrome

Why do I have to have a user called chrome?

Usage

Well, I thought this is to render drawio files int png/pdf files. It looks like rendering any html into png/pdf, is that correct? If so how do i turn a .drawio into a html?

My use case is the same as this one here: jgraph/drawio-desktop#127 (comment)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.