Skip to content

Port fix for PDF saving to release #11194

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@
([#11151](https://github.com/Microsoft/vscode-python/issues/11151))
1. Fix CTRL+Z and Z for undo on notebooks.
([#11160](https://github.com/Microsoft/vscode-python/issues/11160))

1. Fix saving to PDF for viewed plots.
([#11157](https://github.com/Microsoft/vscode-python/issues/11157))

### Code Health

Expand Down
2 changes: 1 addition & 1 deletion build/webpack/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ exports.nodeModulesToExternalize = [
'node-stream-zip',
'xml2js',
'vsls/vscode',
'pdfkit',
'pdfkit/js/pdfkit.standalone',
'crypto-js',
'fontkit',
'linebreak',
Expand Down
20 changes: 9 additions & 11 deletions build/webpack/webpack.extension.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,16 @@ const config = {
externals: ['vscode', 'commonjs', ...ppaPackageList, ...existingModulesInOutDir],
plugins: [
...common.getDefaultPlugins('extension'),
// Copy pdfkit bits after extension builds. webpack can't handle pdfkit.
new FileManagerPlugin({
onEnd: [
{
copy: [
{ source: './node_modules/fontkit/*.trie', destination: './out/client/node_modules' },
{ source: './node_modules/pdfkit/js/data/*.*', destination: './out/client/node_modules/data' },
{ source: './node_modules/pdfkit/js/pdfkit.js', destination: './out/client/node_modules/' }
]
}
]
// Copy pdfkit after extension builds. webpack can't handle pdfkit.
new removeFilesWebpackPlugin({
after: { include: ['./out/client/node_modules/pdfkit/js/pdfkit.standalone.*'] }
}),
new copyWebpackPlugin([
{
from: './node_modules/pdfkit/js/pdfkit.standalone.js',
to: './node_modules/pdfkit/js/pdfkit.standalone.js'
}
]),
// ZMQ requires prebuilds to be in our node_modules directory. So recreate the ZMQ structure.
// However we don't webpack to manage this, so it was part of the excluded modules. Delete it from there
// so at runtime we pick up the original structure.
Expand Down
2 changes: 1 addition & 1 deletion src/client/datascience/plotting/plotViewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export class PlotViewer extends WebViewHost<IPlotViewerMapping> implements IPlot
const SVGtoPDF = require('svg-to-pdfkit');
const deferred = createDeferred<void>();
// tslint:disable-next-line: no-require-imports
const pdfkit = require('pdfkit') as typeof import('pdfkit');
const pdfkit = require('pdfkit/js/pdfkit.standalone') as typeof import('pdfkit');
const doc = new pdfkit();
const ws = this.fileSystem.createWriteStream(file.fsPath);
traceInfo(`Writing pdf to ${file.fsPath}`);
Expand Down