I managed to download my D3JS tree as a SVG file, which fits in the view box, when viewed in Inkscape, using the below code:
// This event is used to download