Compare commits

..

No commits in common. "9c6e2e6df0f43acb5ae9d72208ba0f09f7f55d68" and "539a81c7a3cd6bc803da046813631b093e33675c" have entirely different histories.

9 changed files with 29 additions and 212 deletions

View File

@ -49,8 +49,6 @@ import {
lookupNormalRect,
lookupRect,
numberToString,
RESOURCES_KEYS_OPERATOR_LIST,
RESOURCES_KEYS_TEXT_CONTENT,
stringToAsciiOrUTF16BE,
stringToUTF16String,
} from "./core_utils.js";
@ -1198,7 +1196,7 @@ class Annotation {
const appearanceDict = appearance.dict;
const resources = await this.loadResources(
RESOURCES_KEYS_OPERATOR_LIST,
["ExtGState", "ColorSpace", "Pattern", "Shading", "XObject", "Font"],
appearance
);
const bbox = lookupRect(appearanceDict.getArray("BBox"), [0, 0, 1, 1]);
@ -1259,7 +1257,7 @@ class Annotation {
}
const resources = await this.loadResources(
RESOURCES_KEYS_TEXT_CONTENT,
["ExtGState", "Font", "Properties", "XObject"],
this.appearance
);

View File

@ -32,23 +32,6 @@ const MIN_INT_32 = -(2 ** 31);
const IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0];
const RESOURCES_KEYS_OPERATOR_LIST = [
"ColorSpace",
"ExtGState",
"Font",
"Pattern",
"Properties",
"Shading",
"XObject",
];
const RESOURCES_KEYS_TEXT_CONTENT = [
"ExtGState",
"Font",
"Properties",
"XObject",
];
function getLookupTableFactory(initializer) {
let lookup;
return function () {
@ -762,8 +745,6 @@ export {
readUint16,
readUint32,
recoverJsURL,
RESOURCES_KEYS_OPERATOR_LIST,
RESOURCES_KEYS_TEXT_CONTENT,
stringToAsciiOrUTF16BE,
stringToUTF16HexString,
stringToUTF16String,

View File

@ -45,8 +45,6 @@ import {
lookupNormalRect,
MissingDataException,
PDF_VERSION_REGEXP,
RESOURCES_KEYS_OPERATOR_LIST,
RESOURCES_KEYS_TEXT_CONTENT,
validateCSSFont,
XRefEntryException,
XRefParseException,
@ -421,25 +419,6 @@ class Page {
await objectLoader.load();
}
async #getMergedResources(streamDict, keys) {
// In rare cases /Resources are also found in the /Contents stream-dict,
// in addition to in the /Page dict, hence we need to prefer those when
// available (see issue18894.pdf).
const localResources = streamDict?.get("Resources");
if (!(localResources instanceof Dict)) {
return this.resources;
}
const objectLoader = new ObjectLoader(localResources, keys, this.xref);
await objectLoader.load();
return Dict.merge({
xref: this.xref,
dictArray: [localResources, this.resources],
mergeSubDicts: true,
});
}
async getOperatorList({
handler,
sink,
@ -450,7 +429,15 @@ class Page {
modifiedIds = null,
}) {
const contentStreamPromise = this.getContentStream();
const resourcesPromise = this.loadResources(RESOURCES_KEYS_OPERATOR_LIST);
const resourcesPromise = this.loadResources([
"ColorSpace",
"ExtGState",
"Font",
"Pattern",
"Properties",
"Shading",
"XObject",
]);
const partialEvaluator = new PartialEvaluator({
xref: this.xref,
@ -538,15 +525,11 @@ class Page {
contentStreamPromise,
resourcesPromise,
]).then(async ([contentStream]) => {
const resources = await this.#getMergedResources(
contentStream.dict,
RESOURCES_KEYS_OPERATOR_LIST
);
const opList = new OperatorList(intent, sink);
handler.send("StartRenderPage", {
transparency: partialEvaluator.hasBlendModes(
resources,
this.resources,
this.nonBlendModesSet
),
pageIndex: this.pageIndex,
@ -556,7 +539,7 @@ class Page {
await partialEvaluator.getOperatorList({
stream: contentStream,
task,
resources,
resources: this.resources,
operatorList: opList,
});
return opList;
@ -659,7 +642,12 @@ class Page {
sink,
}) {
const contentStreamPromise = this.getContentStream();
const resourcesPromise = this.loadResources(RESOURCES_KEYS_TEXT_CONTENT);
const resourcesPromise = this.loadResources([
"ExtGState",
"Font",
"Properties",
"XObject",
]);
const langPromise = this.pdfManager.ensureCatalog("lang");
const [contentStream, , lang] = await Promise.all([
@ -667,11 +655,6 @@ class Page {
resourcesPromise,
langPromise,
]);
const resources = await this.#getMergedResources(
contentStream.dict,
RESOURCES_KEYS_TEXT_CONTENT
);
const partialEvaluator = new PartialEvaluator({
xref: this.xref,
handler,
@ -689,7 +672,7 @@ class Page {
return partialEvaluator.getTextContent({
stream: contentStream,
task,
resources,
resources: this.resources,
includeMarkedContent,
disableNormalization,
sink,

View File

@ -462,8 +462,7 @@ class PartialEvaluator {
operatorList,
task,
initialState,
localColorSpaceCache,
seenRefs
localColorSpaceCache
) {
const dict = xobj.dict;
const matrix = lookupMatrix(dict.getArray("Matrix"), null);
@ -527,7 +526,6 @@ class PartialEvaluator {
resources: dict.get("Resources") || resources,
operatorList,
initialState,
prevRefs: seenRefs,
});
operatorList.addOp(OPS.paintFormXObjectEnd, []);
@ -852,8 +850,7 @@ class PartialEvaluator {
operatorList,
task,
stateManager,
localColorSpaceCache,
seenRefs
localColorSpaceCache
) {
const smaskContent = smask.get("G");
const smaskOptions = {
@ -883,8 +880,7 @@ class PartialEvaluator {
operatorList,
task,
stateManager.state.clone({ newPath: true }),
localColorSpaceCache,
seenRefs
localColorSpaceCache
);
}
@ -1069,7 +1065,6 @@ class PartialEvaluator {
stateManager,
localGStateCache,
localColorSpaceCache,
seenRefs,
}) {
const gStateRef = gState.objId;
let isSimpleGState = true;
@ -1132,8 +1127,7 @@ class PartialEvaluator {
operatorList,
task,
stateManager,
localColorSpaceCache,
seenRefs
localColorSpaceCache
)
);
gStateObj.push([key, true]);
@ -1702,19 +1696,7 @@ class PartialEvaluator {
operatorList,
initialState = null,
fallbackFontDict = null,
prevRefs = null,
}) {
const objId = stream.dict?.objId;
const seenRefs = new RefSet(prevRefs);
if (objId) {
if (prevRefs?.has(objId)) {
throw new Error(
`getOperatorList - ignoring circular reference: ${objId}`
);
}
seenRefs.put(objId);
}
// Ensure that `resources`/`initialState` is correctly initialized,
// even if the provided parameter is e.g. `null`.
resources ||= Dict.empty;
@ -1826,8 +1808,7 @@ class PartialEvaluator {
operatorList,
task,
stateManager.state.clone({ newPath: true }),
localColorSpaceCache,
seenRefs
localColorSpaceCache
)
.then(function () {
stateManager.restore();
@ -2177,7 +2158,6 @@ class PartialEvaluator {
stateManager,
localGStateCache,
localColorSpaceCache,
seenRefs,
})
.then(resolveGState, rejectGState);
}).catch(function (reason) {
@ -2359,19 +2339,7 @@ class PartialEvaluator {
markedContentData = null,
disableNormalization = false,
keepWhiteSpace = false,
prevRefs = null,
}) {
const objId = stream.dict?.objId;
const seenRefs = new RefSet(prevRefs);
if (objId) {
if (prevRefs?.has(objId)) {
throw new Error(
`getTextContent - ignoring circular reference: ${objId}`
);
}
seenRefs.put(objId);
}
// Ensure that `resources`/`stateManager` is correctly initialized,
// even if the provided parameter is e.g. `null`.
resources ||= Dict.empty;
@ -3358,7 +3326,6 @@ class PartialEvaluator {
markedContentData,
disableNormalization,
keepWhiteSpace,
prevRefs: seenRefs,
})
.then(function () {
if (!sinkWrapper.enqueueInvoked) {

View File

@ -1108,10 +1108,9 @@ class Font {
// Repair the TrueType file. It is can be damaged in the point of
// view of the sanitizer
data = this.checkAndRepair(name, file, properties);
adjustWidths(properties);
if (this.isOpenType) {
adjustWidths(properties);
type = "OpenType";
}
break;
@ -2646,6 +2645,8 @@ class Font {
cffFile = new Stream(tables["CFF "].data);
cff = new CFFFont(cffFile, properties);
adjustWidths(properties);
return this.convert(name, cff, properties);
}

View File

@ -28,7 +28,6 @@
!checkbox-bad-appearance.pdf
!issue4684.pdf
!issue8092.pdf
!issue19802.pdf
!issue5256.pdf
!issue5801.pdf
!issue5946.pdf
@ -206,7 +205,6 @@
!issue3928.pdf
!issue8565.pdf
!clippath.pdf
!issue19800.pdf
!issue8795_reduced.pdf
!bug1755507.pdf
!close-path-bug.pdf

View File

@ -1,90 +0,0 @@
%PDF-1.4
1 0 obj
<<
/Type /Catalog
/Outlines 2 0 R
/Pages 3 0 R
>>
endobj
2 0 obj
<<
/Type /Outlines
/Count 0
>>
endobj
3 0 obj
<<
/Type /Pages
/Kids [ 4 0 R ]
/Count 1
>>
endobj
4 0 obj
<<
/Type /Page
/Parent 3 0 R
/MediaBox [ 0 0 500 300 ]
/Contents 5 0 R
/Resources <<
/ProcSet [ /PDF /Text ]
/XObject << /X1 6 0 R >>
>>
>>
endobj
5 0 obj
<< /Length 24 >>
stream
1 0 0 1 25 25 cm /X1 Do
endstream
endobj
6 0 obj
<< /Subtype /Form
/BBox [0 0 1000 1000]
/Length 61
/Resources <<
/ProcSet [ /PDF /Text ]
/Font << /F1 7 0 R >>
/XObject << /X0 8 0 R >>
>>
>>
stream
BT
/F1 24 Tf
(Hello world) Tj
ET
0.5 0 0 0.5 25 25 cm /X0 Do
endstream
endobj
7 0 obj
<<
/Type /Font
/Subtype /Type1
/Name /F1
/BaseFont /Helvetica
/Encoding /MacRomanEncoding
>>
endobj
8 0 obj
<< /Subtype /Form
/BBox [0 0 1000 1000]
/Length 61
/Resources <<
/ProcSet [ /PDF /Text ]
/Font << /F1 7 0 R >>
/XObject << /X1 6 0 R >>
>>
>>
stream
BT
/F1 24 Tf
(Hello world) Tj
ET
0.5 0 0 0.5 25 25 cm /X1 Do
endstream
endobj
trailer
<<
/Size 8
/Root 1 0 R
>>
%%EOF

Binary file not shown.

View File

@ -3871,13 +3871,6 @@
"annotations": true,
"about": "LinkAnnotation with a relative link, and a /Catalog Base-URI."
},
{
"id": "issue19802",
"file": "pdfs/issue19802.pdf",
"md5": "7a431fb7951ad605f676c80636bbe5d3",
"rounds": 1,
"type": "eq"
},
{
"id": "issue14824",
"file": "pdfs/issue14824.pdf",
@ -6897,20 +6890,6 @@
"lastPage": 2,
"type": "eq"
},
{
"id": "issue19800-eq",
"file": "pdfs/issue19800.pdf",
"md5": "92825d3178196bdd01096c4081609efd",
"rounds": 1,
"type": "eq"
},
{
"id": "issue19800-text",
"file": "pdfs/issue19800.pdf",
"md5": "92825d3178196bdd01096c4081609efd",
"rounds": 1,
"type": "text"
},
{
"id": "issue3438",
"file": "pdfs/issue3438.pdf",