jerosoler / Drawflow

Simple flow library 🖥️🖱️
https://jerosoler.github.io/Drawflow/
MIT License
4.65k stars 722 forks source link

Is there a way to print the flow diagram ? #397

Closed pkasson closed 2 years ago

pkasson commented 2 years ago

Is there a way today, or a plan to print out the flow to a file (jpeg, etc.) or printer ?

jerosoler commented 2 years ago

View:

pkasson commented 2 years ago

This shows promise, and maybe I am not doing it right - but took the example in #67 and got an error:

Node.CloneNode() not a function -dom-to-image.js

It seems that it expects a single div and no children elements ? (https://stackoverflow.com/questions/60238179/node-clonenode-not-a-function-dom-to-image-js)

jerosoler commented 2 years ago

It seems that more than one element is selected.

How is the element (code) selected?

pkasson commented 2 years ago

I opted to have the ability to download the image - but the code matches that on the example in the other issue.

function printFlow()
 {
  var node = document.getElementById('drawflow');

  domtoimage.toBlob(node).then(function (blob) 
  {
   window.saveAs(blob, 'drawflow.png');
  //  var img = new Image();
  //  img.src = dataUrl;
  //  document.body.appendChild(img);
  })
  .catch(function (error) 
  {
   alert('Oops, something went wrong !');
  });
jerosoler commented 2 years ago

It seems to be correct, unless you have more than one "drawflow" node.

Ask in the developer library. https://github.com/tsayen/dom-to-image

nbar10 commented 1 year ago

The domToImage will only print the items currently on viewable. If there are items hidden which you would have to scroll to, then it won't print them.