Blame view

public/assets/addons/fastflow/plugins/jsPDF-master/src/modules/vfs.js 1.7 KB
2db47680   hexiaodong   chore: 初始提交 php 遗...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
  /**
   * @license
   * jsPDF virtual FileSystem functionality
   *
   * Licensed under the MIT License.
   * http://opensource.org/licenses/mit-license
   */
  
  import { jsPDF } from "../jspdf.js";
  
  /**
   * Use the vFS to handle files
   *
   * @name vFS
   * @module
   */
  (function(jsPDFAPI) {
    "use strict";
  
    var _initializeVFS = function() {
      if (typeof this.internal.vFS === "undefined") {
        this.internal.vFS = {};
      }
      return true;
    };
  
    /**
     * Check if the file exists in the vFS
     *
     * @name existsFileInVFS
     * @function
     * @param {string} Possible filename in the vFS.
     * @returns {boolean}
     * @example
     * doc.existsFileInVFS("someFile.txt");
     */
    jsPDFAPI.existsFileInVFS = function(filename) {
      _initializeVFS.call(this);
      return typeof this.internal.vFS[filename] !== "undefined";
    };
  
    /**
     * Add a file to the vFS
     *
     * @name addFileToVFS
     * @function
     * @param {string} filename The name of the file which should be added.
     * @param {string} filecontent The content of the file.
     * @returns {jsPDF}
     * @example
     * doc.addFileToVFS("someFile.txt", "BADFACE1");
     */
    jsPDFAPI.addFileToVFS = function(filename, filecontent) {
      _initializeVFS.call(this);
      this.internal.vFS[filename] = filecontent;
      return this;
    };
  
    /**
     * Get the file from the vFS
     *
     * @name getFileFromVFS
     * @function
     * @param {string} The name of the file which gets requested.
     * @returns {string}
     * @example
     * doc.getFileFromVFS("someFile.txt");
     */
    jsPDFAPI.getFileFromVFS = function(filename) {
      _initializeVFS.call(this);
  
      if (typeof this.internal.vFS[filename] !== "undefined") {
        return this.internal.vFS[filename];
      }
      return null;
    };
  })(jsPDF.API);