Skip to content

Commit 363356a

Browse files
committed
Add the possibility to create a pdf from different ones (bug 1997379)
For now it's just possible to create a single pdf in selecting some pages in different pdf sources. The merge is for now pretty basic (it's why it's still a WIP) none of these data are merged for now: - the struct trees - the page labels - the outlines - named destinations For there are 2 new ref tests where some new pdfs are created: one with some extracted pages and an other one (encrypted) which is just rewritten. The ref images are generated from the original pdfs in selecting the page we want and the new images are taken from the generated pdfs.
1 parent 0a2680b commit 363356a

19 files changed

+1088
-44
lines changed

src/core/decode_stream.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,19 @@ class DecodeStream extends BaseStream {
131131
getBaseStreams() {
132132
return this.stream ? this.stream.getBaseStreams() : null;
133133
}
134+
135+
clone() {
136+
// Make sure it has been fully read.
137+
while (!this.eof) {
138+
this.readBlock();
139+
}
140+
return new Stream(
141+
this.buffer,
142+
this.start,
143+
this.end - this.start,
144+
this.dict.clone()
145+
);
146+
}
134147
}
135148

136149
class StreamsSequenceStream extends DecodeStream {

src/core/decrypt_stream.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ class DecryptStream extends DecodeStream {
5252
buffer.set(chunk, bufferLength);
5353
this.bufferLength = newLength;
5454
}
55+
56+
getOriginalStream() {
57+
return this;
58+
}
5559
}
5660

5761
export { DecryptStream };

src/core/document.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ class Page {
178178
);
179179
}
180180

181-
#getBoundingBox(name) {
181+
getBoundingBox(name) {
182182
if (this.xfaData) {
183183
return this.xfaData.bbox;
184184
}
@@ -201,7 +201,7 @@ class Page {
201201
return shadow(
202202
this,
203203
"mediaBox",
204-
this.#getBoundingBox("MediaBox") || LETTER_SIZE_MEDIABOX
204+
this.getBoundingBox("MediaBox") || LETTER_SIZE_MEDIABOX
205205
);
206206
}
207207

@@ -210,7 +210,7 @@ class Page {
210210
return shadow(
211211
this,
212212
"cropBox",
213-
this.#getBoundingBox("CropBox") || this.mediaBox
213+
this.getBoundingBox("CropBox") || this.mediaBox
214214
);
215215
}
216216

0 commit comments

Comments
 (0)