vscode-sql-notebook icon indicating copy to clipboard operation
vscode-sql-notebook copied to clipboard

Exporting as PDF

Open claireboyd opened this issue 2 years ago • 6 comments

Is there a way to export SQL notebooks as PDFs easily? Thanks!

claireboyd avatar Mar 27 '23 21:03 claireboyd

Not at the moment. I think I've seen this feature request from others, so I'll prioritize it for future work.

cmoog avatar Mar 28 '23 00:03 cmoog

@claireboyd UChicago!

cmoog avatar Mar 28 '23 00:03 cmoog

Small world! I could be interested in collaborating to add it if that would help - I'm not sure how big a lift it might be, but would be happy to learn.

claireboyd avatar Mar 28 '23 01:03 claireboyd

also my friend/fellow CAPP student @divij-sinha would be down to collab to make this work as well!

claireboyd avatar Mar 29 '23 01:03 claireboyd

@claireboyd @divij-sinha Great! I'd be happy to accept this as a contribution. Here are some high level steps on how I think this should be accomplished

  • add a new command in the extension manifest, something like Export as PDF, docs on that here
  • when the command is invoked, generate some HTML from the notebook state (should include cells and cell "outputs"). Right now, the tabular output is formatted as markdown– this will need to be converted into HTML. The same goes for any "markdown cells". The SQL query cells should be placed in <pre></pre> tags. (maybe a future enhancement could give these blocks syntax highlighting in the final output). Finally, some simple embedded CSS to give reasonably attractive tables that format well in the final PDF output.
  • convert this HTML into a PDF (pretty sure there are libraries for this) and... (write to the current directory?, maybe prompt for a filename then write?)

If you make some progress and want to open a draft PR I'll be happy to give feedback along the way or iron out any issues you're having. In general, the VS Code extension API can be a bit tricky to work with but the docs are great.

cmoog avatar Mar 29 '23 01:03 cmoog

Just chipping in with a suggestion :

Exporting the whole lot to markdown might be easier & more flexible as conversion to pdf, html could be done from the complete markdown.

Even a select all, copy-as-markdown would be cool

bmrussell avatar Apr 14 '23 16:04 bmrussell