Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

savePDF.js 1.5KB

12345678910111213141516171819
  1. "use strict";
  2. var __importDefault = (this && this.__importDefault) || function (mod) {
  3. return (mod && mod.__esModule) ? mod : { "default": mod };
  4. };
  5. Object.defineProperty(exports, "__esModule", { value: true });
  6. const fs_1 = __importDefault(require("fs"));
  7. const utils_1 = require("../../utils");
  8. async function savePDF(filepath, options) {
  9. if (typeof filepath != 'string' || !filepath.endsWith('.pdf')) {
  10. throw new Error('savePDF expects a filepath of type string and ".pdf" file ending');
  11. }
  12. const absoluteFilepath = utils_1.getAbsoluteFilepath(filepath);
  13. utils_1.assertDirectoryExists(absoluteFilepath);
  14. const pdf = await this.printPage(options === null || options === void 0 ? void 0 : options.orientation, options === null || options === void 0 ? void 0 : options.scale, options === null || options === void 0 ? void 0 : options.background, options === null || options === void 0 ? void 0 : options.width, options === null || options === void 0 ? void 0 : options.height, options === null || options === void 0 ? void 0 : options.top, options === null || options === void 0 ? void 0 : options.bottom, options === null || options === void 0 ? void 0 : options.left, options === null || options === void 0 ? void 0 : options.right, options === null || options === void 0 ? void 0 : options.shrinkToFit, options === null || options === void 0 ? void 0 : options.pageRanges);
  15. const page = Buffer.from(pdf, 'base64');
  16. fs_1.default.writeFileSync(absoluteFilepath, page);
  17. return page;
  18. }
  19. exports.default = savePDF;