Skip to content
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

Added prefix to pdF file name #649

Merged
merged 3 commits into from
Mar 3, 2020
Merged
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
11 changes: 9 additions & 2 deletions src/components/Settings/Export/Export.helpers.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import JSZip from 'jszip';
import axios from 'axios';
import moment from 'moment';
import pdfMake from 'pdfmake/build/pdfmake';
import pdfFonts from 'pdfmake/build/vfs_fonts';
import { saveAs } from 'file-saver';
Expand Down Expand Up @@ -471,16 +472,22 @@ export async function pdfExportAdapter(boards = [], intl) {
const pdfObj = pdfMake.createPdf(docDefinition);

if (pdfObj) {
let prefix = moment().format('hh-mm-ss-');
if (content.length === 2) {
prefix = prefix + content[0] + ' ';
} else {
prefix = prefix + 'boardsset ';
}
if (isCordova()) {
requestCvaWritePermissions();
pdfObj.getBuffer(buffer => {
var blob = new Blob([buffer], { type: 'application/pdf' });
const name = 'Download/board.pdf';
const name = 'Download/' + prefix + EXPORT_CONFIG_BY_TYPE.pdf.filename;
writeCvaFile(name, blob);
});
} else {
// On a browser simply use download!
pdfObj.download(EXPORT_CONFIG_BY_TYPE.pdf.filename);
pdfObj.download(prefix + EXPORT_CONFIG_BY_TYPE.pdf.filename);
}
}
}
Expand Down