Skip to content

Commit 511b0a3

Browse files
committed
improve hotfix documentation and mention px_scaling hotfix in jsPDF documentation
1 parent 77ce3d3 commit 511b0a3

File tree

2 files changed

+30
-15
lines changed

2 files changed

+30
-15
lines changed

HOTFIX_README.md

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,51 +3,64 @@
33
We sometimes bake-in solutions (A.K.A. hotfixes) to solve issues for specific use cases.
44

55
When we deem a hotfix will not break existing code,
6-
will make it default behaviour and mark the hotfix as _accepted_,
7-
At that point the define can be removed.
8-
9-
To enable a hotfix, define the following member of your created PDF,
10-
where the pdf.hotfix field is the name of the hotfix.
11-
12-
var pdf new jsPDF(...);
13-
pdf.hotfix.fill_close = true;
14-
6+
will make it default behaviour and mark the hotfix as _accepted_,
7+
At that point the define can be removed.
8+
9+
To enable a hotfix, pass the `hotfixes` option to the jsPDF constructor:
10+
11+
```js
12+
new jsPDF({
13+
hotfixes: ["px_scaling"]
14+
});
15+
```
16+
1517
# Active Hotfixes
18+
1619
## px_scaling
1720

1821
### Applies To
22+
1923
jsPDF Core
2024

2125
### Description
26+
2227
When supplying 'px' as the unit for the PDF, the internal scaling factor was being miscalculated making drawn components
23-
larger than they should be. Enabling this hotfix will correct this scaling calculation and items will be drawn to the
28+
larger than they should be. Enabling this hotfix will correct this scaling calculation and items will be drawn to the
2429
correct scale.
2530

2631
### To Enable
32+
2733
To enable this hotfix, supply a 'hotfixes' array to the options object in the jsPDF constructor function, and add the
2834
string 'px_scaling' to this array.
2935

3036
#Accepted Hotfixes
37+
3138
## scale_text
3239

3340
### Applies To
41+
3442
context2d plugin
3543

3644
### Affects
45+
3746
Drawing and Filling Text when a scale transformation is active.
3847

3948
### Description
49+
4050
jsPDF currently has no way to draw scaled text.
4151
This hotfix scales the current font size by the x-axis scale factor.
42-
52+
4353
## fill_close
54+
4455
### Applies To
56+
4557
context2d plugin
4658

4759
### Affects
48-
Filling paths
60+
61+
Filling paths
4962

5063
### Description
64+
5165
In certain cases, closing a fill would result in a path resolving to an incorrect point.
52-
The was most likely fixed when we refactored matrix logic. Enabling this hotfix will ignore a most-likely unneeded workaround.
53-
66+
The was most likely fixed when we refactored matrix logic. Enabling this hotfix will ignore a most-likely unneeded workaround.

src/jspdf.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,13 +177,15 @@ function TilingPattern(boundingBox, xStep, yStep, gState, matrix) {
177177
* @param {Object} [options] - Collection of settings initializing the jsPDF-instance
178178
* @param {string} [options.orientation=portrait] - Orientation of the first page. Possible values are "portrait" or "landscape" (or shortcuts "p" or "l").<br />
179179
* @param {string} [options.unit=mm] Measurement unit (base unit) to be used when coordinates are specified.<br />
180-
* Possible values are "pt" (points), "mm", "cm", "m", "in" or "px".
180+
* Possible values are "pt" (points), "mm", "cm", "m", "in" or "px". Note that in order to get the correct scaling for "px"
181+
* units, you need to enable the hotfix "px_scaling" by setting options.hotfixes = ["px_scaling"].
181182
* @param {string/Array} [options.format=a4] The format of the first page. Can be:<ul><li>a0 - a10</li><li>b0 - b10</li><li>c0 - c10</li><li>dl</li><li>letter</li><li>government-letter</li><li>legal</li><li>junior-legal</li><li>ledger</li><li>tabloid</li><li>credit-card</li></ul><br />
182183
* Default is "a4". If you want to use your own format just pass instead of one of the above predefined formats the size as an number-array, e.g. [595.28, 841.89]
183184
* @param {boolean} [options.putOnlyUsedFonts=false] Only put fonts into the PDF, which were used.
184185
* @param {boolean} [options.compress=false] Compress the generated PDF.
185186
* @param {number} [options.precision=16] Precision of the element-positions.
186187
* @param {number} [options.userUnit=1.0] Not to be confused with the base unit. Please inform yourself before you use it.
188+
* @param {string[]} [options.hotfixes] An array of strings to enable hotfixes such as correct pixel scaling.
187189
* @param {number|"smart"} [options.floatPrecision=16]
188190
* @returns {jsPDF} jsPDF-instance
189191
* @description

0 commit comments

Comments
 (0)