Skip to content
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
1 change: 1 addition & 0 deletions news/2 Fixes/9403.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ensure plot fits within the page of the `PDF`.
6 changes: 4 additions & 2 deletions src/client/datascience/plotting/plotViewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,14 @@ 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');
const pdfkit = require('pdfkit') as typeof import('pdfkit');
const doc = new pdfkit();
const ws = this.fileSystem.createWriteStream(file.fsPath);
traceInfo(`Writing pdf to ${file.fsPath}`);
ws.on('finish', () => deferred.resolve);
SVGtoPDF(doc, payload.svg, 0, 0);
// See docs or demo from source https://cdn.statically.io/gh/alafr/SVG-to-PDFKit/master/examples/demo.htm
// How to resize to fit (fit within the height & width of page).
SVGtoPDF(doc, payload.svg, 0, 0, { preserveAspectRatio: 'xMinYMin meet' });
doc.pipe(ws);
doc.end();
traceInfo(`Finishing pdf to ${file.fsPath}`);
Expand Down
2 changes: 1 addition & 1 deletion src/test/datascience/nativeEditor.functional.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2194,7 +2194,7 @@ df.head()`;
await makeChangesAndConfirmFileIsUpdated();
await makeChangesAndConfirmFileIsUpdated();
await makeChangesAndConfirmFileIsUpdated();
});
}).retries(2);

test('File saved with same format', async () => {
// Configure notebook to save automatically ever 1s.
Expand Down