Closed dconlan closed 2 years ago
@dconlan Thank you for sharing this! I agree with having those dependencies standalone for now. The majority of the line changes in this PR appear to be the package.lock file, though the project dependencies weren't changed. Is it alright if I remove that file from this PR and then merge?
Happy for you to remove that file.
Merged it into a local branch to do the surgery, but have decided to just merge it into master for simplicity. Thank you again.
These changes allow for the export of an SVG image or a PDF file of the pedigree diagram. The actual image is constructed using the raw web page graphics object. This has a side effect that if a node is currently highlighted on the web page the same node will be highlighted in the svg/pdf. I found that names on nodes in the SVG were using 20 point font and comments 19 point font. I used this to implement the privacy settings, so if names are hidden, text of font size 20 are removed from the SVG and if 'minimal' privacy option is selected text of size 19 is also removed. This mechanism is a bit fragile. It would be better if the renderer added some sort of attribute to the underlying graphics to indicate name/dob/comment text blocks.
The change adds the following public javascript libraries.
PDFKit - https://pdfkit.org/ - MIT license SVG-to-PDFKit - https://github.com/alafr/SVG-to-PDFKit - MIT license blob-stream - https://github.com/devongovett/blob-stream - MIT license
PDFKit was built for running in an nodejs server, not in a browser. There are some instructions for getting it to work in a browser, but I went with the simpliest solution of a standalone js file, rather than using npm to manage the dependancy. A future version may want to fix this.
blob-stream was the suggested way to write the blob to file.