Add support for Optional Content in TilingPatterns (issue 15716)

This can't be a particularly common feature, since we've supported Optional Content for over two years and this is the very first TilingPattern-case we've seen.
This commit is contained in:
Jonas Jenwald 2022-11-23 12:58:00 +01:00
parent 73c268dc1c
commit 47682985d3
5 changed files with 156 additions and 4 deletions

View File

@ -3245,7 +3245,7 @@ class InternalRenderTask {
this.commonObjs,
this.objs,
this.canvasFactory,
optionalContentConfig,
{ optionalContentConfig },
this.annotationCanvasMap,
this.pageColors
);

View File

@ -1022,7 +1022,7 @@ class CanvasGraphics {
commonObjs,
objs,
canvasFactory,
optionalContentConfig,
{ optionalContentConfig, markedContentStack = null },
annotationCanvasMap,
pageColors
) {
@ -1051,7 +1051,7 @@ class CanvasGraphics {
this.tempSMask = null;
this.suspendedCtx = null;
this.contentVisible = true;
this.markedContentStack = [];
this.markedContentStack = markedContentStack || [];
this.optionalContentConfig = optionalContentConfig;
this.cachedCanvases = new CachedCanvases(this.canvasFactory);
this.cachedPatterns = new Map();
@ -2471,7 +2471,11 @@ class CanvasGraphics {
ctx,
this.commonObjs,
this.objs,
this.canvasFactory
this.canvasFactory,
{
optionalContentConfig: this.optionalContentConfig,
markedContentStack: this.markedContentStack,
}
);
},
};

View File

@ -440,6 +440,7 @@
!issue6889.pdf
!issue11473.pdf
!bug1001080.pdf
!issue15716.pdf
!bug1671312_reduced.pdf
!bug1671312_ArialNarrow.pdf
!issue6108.pdf

132
test/pdfs/issue15716.pdf Normal file
View File

@ -0,0 +1,132 @@
%PDF-1.7
1 0 obj
<<
/Type /Catalog
/Pages 2 0 R
/OCProperties
<<
/OCGs [1000 0 R 1001 0 R]
/D << /Order [1000 0 R 1001 0 R] >>
>>
>>
endobj
2 0 obj
<< /Type /Pages /Count 1 /Kids [ 10 0 R ] >>
endobj
% PAGE 1
10 0 obj
<<
/Type /Page
/Parent 2 0 R
/MediaBox [ 0 0 200 200 ]
/Contents 11 0 R
/Resources
<<
/Pattern << /P1 12 0 R >>
>>
>>
endobj
11 0 obj
<< /Length 146 >>
stream
/Pattern cs % Set pattern color space
/P1 scn % Set pattern as nonstroking color
0 200 200 -200 re % Construct rectangular path
f % Fill path
endstream
endobj
12 0 obj
<<
/Type /Pattern
/PatternType 1
/PaintType 1
/TilingType 2
/BBox [0 0 100 100]
/XStep 100
/YStep 100
/Resources
<<
/Font << /F1 13 0 R >>
/Properties << /L1 1000 0 R /L2 1001 0 R >>
>>
/Length 788
>>
stream
BT % Begin text object
/F1 1 Tf % Set text font and size
64 0 0 64 7.1771 2.4414 Tm % Set text matrix
0 Tc % Set character spacing
0 Tw % Set word spacing
/OC /L1 BDC % Begin layer
0.0 0.0 0.0 rg % Set nonstroking color to black
(\001) Tj % Show spade glyph
EMC % End layer
0.7478 -0.007 TD % Move text position
/OC /L2 BDC % Begin layer
1.0 0.0 0.0 rg % Set nonstroking color to red
(\002) Tj % Show heart glyph
EMC % End layer
-0.7323 0.7813 TD % Move text position
/OC /L2 BDC % Begin layer
1.0 0.0 0.0 rg % Set nonstroking color to red
(\003) Tj % Show diamond glyph
EMC % End layer
0.6913 0.007 TD % Move text position
/OC /L1 BDC % Begin layer
0.0 0.0 0.0 rg % Set nonstroking color to black
(\004) Tj % Show club glyph
EMC % End layer
ET % End text object
endstream
endobj
13 0 obj
<<
/Type /Font
/Subtype /Type1
/BaseFont /ZapfDingbats
/Encoding
<<
/Type /Encoding /Differences [1 /a109 /a110 /a111 /a112]
>>
>>
endobj
% SHARED OBJECTS
1000 0 obj
<< /Type /OCG /Name (Black) >>
endobj
1001 0 obj
<< /Type /OCG /Name (Red) >>
endobj
xref
0 3
0000000000 65535 f
0000000010 00000 n
0000000151 00000 n
10 4
0000000223 00000 n
0000000367 00000 n
0000000565 00000 n
0000001603 00000 n
1000 2
0000001778 00000 n
0000001828 00000 n
trailer
<< /Size 8 /Root 1 0 R >>
startxref
1877
%%EOF

View File

@ -4562,6 +4562,21 @@
"rounds": 1,
"type": "text"
},
{ "id": "issue15716",
"file": "pdfs/issue15716.pdf",
"md5": "4d89aabeb97fcb181662406f092bbeb0",
"rounds": 1,
"type": "eq"
},
{ "id": "issue15716-no-red-oc",
"file": "pdfs/issue15716.pdf",
"md5": "4d89aabeb97fcb181662406f092bbeb0",
"rounds": 1,
"type": "eq",
"optionalContent": {
"1001R": false
}
},
{ "id": "issue845",
"file": "pdfs/issue845r.pdf",
"md5": "b5f8fe4005cf3fb685fdb4a4c44ee4a2",