Skip to content
This repository was archived by the owner on Aug 11, 2020. It is now read-only.

Commit b7a1d82

Browse files
committed
v2.1.1
1 parent 0dd01f1 commit b7a1d82

File tree

6 files changed

+122
-90
lines changed

6 files changed

+122
-90
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jspdf-yworks",
3-
"version": "2.1.0",
3+
"version": "2.1.1",
44
"homepage": "https://github.com/yWorks/jsPDF",
55
"description": "PDF Document creation from JavaScript",
66
"main": [

dist/jspdf.debug.js

Lines changed: 42 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
/** @license
77
*
88
* jsPDF - PDF Document creation from JavaScript
9-
* Version 2.1.0 Built on 2019-08-07T08:11:40.854Z
10-
* CommitID d6c9d97817
9+
* Version 2.1.1 Built on 2019-10-11T08:56:17.234Z
10+
* CommitID 0dd01f177e
1111
*
1212
* Copyright (c) 2010-2018 James Hall <james@parall.ax>, https://github.com/MrRio/jsPDF
1313
* 2015-2018 yWorks GmbH, http://www.yworks.com
@@ -2474,9 +2474,14 @@
24742474
out("endobj");
24752475
};
24762476

2477-
var putTilingPattern = function putTilingPattern(pattern) {
2478-
var resourcesObjectNumber = putResourceDictionary(false);
2479-
pattern.objectNumber = newObject();
2477+
var putTilingPattern = function putTilingPattern(pattern, deferredResourceDictionaryIds) {
2478+
var resourcesObjectId = newObjectDeferred();
2479+
var patternObjectId = newObject();
2480+
deferredResourceDictionaryIds.push({
2481+
resourcesOid: resourcesObjectId,
2482+
objectOid: patternObjectId
2483+
});
2484+
pattern.objectNumber = patternObjectId;
24802485
var options = [];
24812486
options.push({
24822487
key: "Type",
@@ -2511,7 +2516,7 @@
25112516
});
25122517
options.push({
25132518
key: "Resources",
2514-
value: resourcesObjectNumber + " 0 R"
2519+
value: resourcesObjectId + " 0 R"
25152520
});
25162521

25172522
if (pattern.matrix) {
@@ -2528,15 +2533,15 @@
25282533
out("endobj");
25292534
};
25302535

2531-
var putPatterns = function putPatterns() {
2536+
var putPatterns = function putPatterns(deferredResourceDictionaryIds) {
25322537
var patternKey;
25332538

25342539
for (patternKey in patterns) {
25352540
if (patterns.hasOwnProperty(patternKey)) {
25362541
if (patterns[patternKey] instanceof API.ShadingPattern) {
25372542
putShadingPattern(patterns[patternKey]);
25382543
} else if (patterns[patternKey] instanceof API.TilingPattern) {
2539-
putTilingPattern(patterns[patternKey]);
2544+
putTilingPattern(patterns[patternKey], deferredResourceDictionaryIds);
25402545
}
25412546
}
25422547
}
@@ -2615,14 +2620,15 @@
26152620
}
26162621
};
26172622

2618-
var putTilingPatternDict = function putTilingPatternDict() {
2623+
var putTilingPatternDict = function putTilingPatternDict(objectOid) {
26192624
if (Object.keys(patterns).length > 0) {
26202625
out("/Pattern <<");
26212626

26222627
for (var patternKey in patterns) {
2623-
if (patterns.hasOwnProperty(patternKey) && patterns[patternKey] instanceof API.TilingPattern && patterns[patternKey].objectNumber >= 0) {
2624-
out("/" + patternKey + " " + patterns[patternKey].objectNumber + " 0 R");
2625-
}
2628+
if (patterns.hasOwnProperty(patternKey) && patterns[patternKey] instanceof API.TilingPattern && patterns[patternKey].objectNumber >= 0 && patterns[patternKey].objectNumber < objectOid // prevent cyclic dependencies
2629+
) {
2630+
out("/" + patternKey + " " + patterns[patternKey].objectNumber + " 0 R");
2631+
}
26262632
}
26272633

26282634
events.publish("putTilingPatternDict");
@@ -2646,34 +2652,44 @@
26462652
}
26472653
};
26482654

2649-
var putResourceDictionary = function putResourceDictionary(useDeferredObject) {
2650-
var oid;
2651-
2652-
if (useDeferredObject) {
2653-
oid = newObjectDeferredBegin(resourceDictionaryObjId, true);
2654-
} else {
2655-
oid = newObject();
2656-
}
2657-
2655+
var putResourceDictionary = function putResourceDictionary(objectIds) {
2656+
newObjectDeferredBegin(objectIds.resourcesOid, true);
26582657
out("<<");
26592658
out("/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]");
26602659
putFontDict();
26612660
putShadingPatternDict();
2662-
putTilingPatternDict();
2661+
putTilingPatternDict(objectIds.objectOid);
26632662
putGStatesDict();
26642663
putXobjectDict();
26652664
out(">>");
26662665
out("endobj");
2667-
return oid;
26682666
};
26692667

26702668
var putResources = function putResources() {
2669+
// FormObjects, Patterns etc. might use other FormObjects/Patterns/Images
2670+
// which means their resource dictionaries must contain the already resolved
2671+
// object ids. For this reason we defer the serialization of the resource
2672+
// dicts until all objects have been serialized and have object ids.
2673+
//
2674+
// In order to prevent cyclic dependencies (which Adobe Reader doesn't like),
2675+
// we only put all oids that are smaller than the oid of the object the
2676+
// resource dict belongs to. This is correct behavior, since the streams
2677+
// may only use other objects that have already been defined and thus appear
2678+
// earlier in their respective collection.
2679+
// Currently, this only affects tiling patterns, but a (more) correct
2680+
// implementation of FormObjects would also define their own resource dicts.
2681+
var deferredResourceDictionaryIds = [];
26712682
putFonts();
26722683
putGStates();
26732684
putXObjects();
2674-
putPatterns();
2685+
putPatterns(deferredResourceDictionaryIds);
26752686
events.publish("putResources");
2676-
putResourceDictionary(true);
2687+
deferredResourceDictionaryIds.forEach(putResourceDictionary);
2688+
putResourceDictionary({
2689+
resourcesOid: resourceDictionaryObjId,
2690+
objectOid: Number.MAX_SAFE_INTEGER // output all objects
2691+
2692+
});
26772693
events.publish("postPutResources");
26782694
};
26792695

@@ -6130,7 +6146,7 @@
61306146
* @memberof jsPDF#
61316147
*/
61326148

6133-
jsPDF.version = '2.1.0';
6149+
jsPDF.version = '2.1.1';
61346150

61356151
if (typeof define === "function" && define.amd) {
61366152
define(function () {

dist/jspdf.min.js

Lines changed: 18 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/jspdf.node.debug.js

Lines changed: 42 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
/** @license
44
*
55
* jsPDF - PDF Document creation from JavaScript
6-
* Version 2.1.0 Built on 2019-08-07T08:11:50.031Z
7-
* CommitID d6c9d97817
6+
* Version 2.1.1 Built on 2019-10-11T08:56:25.346Z
7+
* CommitID 0dd01f177e
88
*
99
* Copyright (c) 2010-2018 James Hall <james@parall.ax>, https://github.com/MrRio/jsPDF
1010
* 2015-2018 yWorks GmbH, http://www.yworks.com
@@ -1993,9 +1993,14 @@ var jsPDF = function (global) {
19931993
out("endobj");
19941994
};
19951995

1996-
var putTilingPattern = function putTilingPattern(pattern) {
1997-
var resourcesObjectNumber = putResourceDictionary(false);
1998-
pattern.objectNumber = newObject();
1996+
var putTilingPattern = function putTilingPattern(pattern, deferredResourceDictionaryIds) {
1997+
var resourcesObjectId = newObjectDeferred();
1998+
var patternObjectId = newObject();
1999+
deferredResourceDictionaryIds.push({
2000+
resourcesOid: resourcesObjectId,
2001+
objectOid: patternObjectId
2002+
});
2003+
pattern.objectNumber = patternObjectId;
19992004
var options = [];
20002005
options.push({
20012006
key: "Type",
@@ -2030,7 +2035,7 @@ var jsPDF = function (global) {
20302035
});
20312036
options.push({
20322037
key: "Resources",
2033-
value: resourcesObjectNumber + " 0 R"
2038+
value: resourcesObjectId + " 0 R"
20342039
});
20352040

20362041
if (pattern.matrix) {
@@ -2047,15 +2052,15 @@ var jsPDF = function (global) {
20472052
out("endobj");
20482053
};
20492054

2050-
var putPatterns = function putPatterns() {
2055+
var putPatterns = function putPatterns(deferredResourceDictionaryIds) {
20512056
var patternKey;
20522057

20532058
for (patternKey in patterns) {
20542059
if (patterns.hasOwnProperty(patternKey)) {
20552060
if (patterns[patternKey] instanceof API.ShadingPattern) {
20562061
putShadingPattern(patterns[patternKey]);
20572062
} else if (patterns[patternKey] instanceof API.TilingPattern) {
2058-
putTilingPattern(patterns[patternKey]);
2063+
putTilingPattern(patterns[patternKey], deferredResourceDictionaryIds);
20592064
}
20602065
}
20612066
}
@@ -2134,14 +2139,15 @@ var jsPDF = function (global) {
21342139
}
21352140
};
21362141

2137-
var putTilingPatternDict = function putTilingPatternDict() {
2142+
var putTilingPatternDict = function putTilingPatternDict(objectOid) {
21382143
if (Object.keys(patterns).length > 0) {
21392144
out("/Pattern <<");
21402145

21412146
for (var patternKey in patterns) {
2142-
if (patterns.hasOwnProperty(patternKey) && patterns[patternKey] instanceof API.TilingPattern && patterns[patternKey].objectNumber >= 0) {
2143-
out("/" + patternKey + " " + patterns[patternKey].objectNumber + " 0 R");
2144-
}
2147+
if (patterns.hasOwnProperty(patternKey) && patterns[patternKey] instanceof API.TilingPattern && patterns[patternKey].objectNumber >= 0 && patterns[patternKey].objectNumber < objectOid // prevent cyclic dependencies
2148+
) {
2149+
out("/" + patternKey + " " + patterns[patternKey].objectNumber + " 0 R");
2150+
}
21452151
}
21462152

21472153
events.publish("putTilingPatternDict");
@@ -2165,34 +2171,44 @@ var jsPDF = function (global) {
21652171
}
21662172
};
21672173

2168-
var putResourceDictionary = function putResourceDictionary(useDeferredObject) {
2169-
var oid;
2170-
2171-
if (useDeferredObject) {
2172-
oid = newObjectDeferredBegin(resourceDictionaryObjId, true);
2173-
} else {
2174-
oid = newObject();
2175-
}
2176-
2174+
var putResourceDictionary = function putResourceDictionary(objectIds) {
2175+
newObjectDeferredBegin(objectIds.resourcesOid, true);
21772176
out("<<");
21782177
out("/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]");
21792178
putFontDict();
21802179
putShadingPatternDict();
2181-
putTilingPatternDict();
2180+
putTilingPatternDict(objectIds.objectOid);
21822181
putGStatesDict();
21832182
putXobjectDict();
21842183
out(">>");
21852184
out("endobj");
2186-
return oid;
21872185
};
21882186

21892187
var putResources = function putResources() {
2188+
// FormObjects, Patterns etc. might use other FormObjects/Patterns/Images
2189+
// which means their resource dictionaries must contain the already resolved
2190+
// object ids. For this reason we defer the serialization of the resource
2191+
// dicts until all objects have been serialized and have object ids.
2192+
//
2193+
// In order to prevent cyclic dependencies (which Adobe Reader doesn't like),
2194+
// we only put all oids that are smaller than the oid of the object the
2195+
// resource dict belongs to. This is correct behavior, since the streams
2196+
// may only use other objects that have already been defined and thus appear
2197+
// earlier in their respective collection.
2198+
// Currently, this only affects tiling patterns, but a (more) correct
2199+
// implementation of FormObjects would also define their own resource dicts.
2200+
var deferredResourceDictionaryIds = [];
21902201
putFonts();
21912202
putGStates();
21922203
putXObjects();
2193-
putPatterns();
2204+
putPatterns(deferredResourceDictionaryIds);
21942205
events.publish("putResources");
2195-
putResourceDictionary(true);
2206+
deferredResourceDictionaryIds.forEach(putResourceDictionary);
2207+
putResourceDictionary({
2208+
resourcesOid: resourceDictionaryObjId,
2209+
objectOid: Number.MAX_SAFE_INTEGER // output all objects
2210+
2211+
});
21962212
events.publish("postPutResources");
21972213
};
21982214

@@ -5649,7 +5665,7 @@ var jsPDF = function (global) {
56495665
* @memberof jsPDF#
56505666
*/
56515667

5652-
jsPDF.version = '2.1.0';
5668+
jsPDF.version = '2.1.1';
56535669

56545670
if (typeof define === "function" && define.amd) {
56555671
define(function () {

dist/jspdf.node.min.js

Lines changed: 18 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jspdf-yworks",
3-
"version": "2.1.0",
3+
"version": "2.1.1",
44
"homepage": "https://github.com/yWorks/jsPDF",
55
"description": "PDF Document creation from JavaScript",
66
"main": "dist/jspdf.min.js",

0 commit comments

Comments
 (0)