Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ directory `build/chromium`.

### PDF debugger

Browser the internal structure of a PDF document with https://mozilla.github.io/pdf.js/internal-viewer/web/pdf_internal_viewer.html
Browser the internal structure of a PDF document with https://mozilla.github.io/pdf.js/internal-viewer/web/debugger.html

## Getting the Code

Expand Down
8 changes: 4 additions & 4 deletions gulpfile.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2372,13 +2372,13 @@ gulp.task("check_l10n", function (done) {

function createInternalViewerBundle(defines) {
const viewerFileConfig = createWebpackConfig(defines, {
filename: "pdf_internal_viewer.mjs",
filename: "debugger.mjs",
library: {
type: "module",
},
});
return gulp
.src("./web/pdf_internal_viewer.js", { encoding: false })
.src("./web/internal/debugger.js", { encoding: false })
.pipe(webpack2Stream(viewerFileConfig));
}

Expand All @@ -2389,10 +2389,10 @@ function buildInternalViewer(defines, dir) {
createMainBundle(defines).pipe(gulp.dest(dir + "build")),
createWorkerBundle(defines).pipe(gulp.dest(dir + "build")),
createInternalViewerBundle(defines).pipe(gulp.dest(dir + "web")),
preprocessHTML("web/pdf_internal_viewer.html", defines).pipe(
preprocessHTML("web/internal/debugger.html", defines).pipe(
gulp.dest(dir + "web")
),
preprocessCSS("web/pdf_internal_viewer.css", defines)
preprocessCSS("web/internal/debugger.css", defines)
.pipe(
postcss([
postcssDirPseudoClass(),
Expand Down
21 changes: 3 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pdfjs.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"stableVersion": "5.5.207",
"baseVersion": "025d658a9c66d10825ce19bc830e52a8c6347e61",
"versionPrefix": "5.5."
"baseVersion": "315491dd3224d957f203f813f880b26cc3251bae",
"versionPrefix": "5.6."
}
10 changes: 2 additions & 8 deletions src/core/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ class WorkerMessageHandler {
password,
disableAutoFetch,
rangeChunkSize,
length,
docBaseUrl,
enableXfa,
evaluatorOptions,
Expand All @@ -209,7 +208,7 @@ class WorkerMessageHandler {
enableXfa,
evaluatorOptions,
handler,
length,
length: 0,
password,
rangeChunkSize,
};
Expand Down Expand Up @@ -287,14 +286,9 @@ class WorkerMessageHandler {
}

if (!newPdfManager) {
const pdfFile = arrayBuffersToBytes(cachedChunks);
pdfManagerArgs.source = arrayBuffersToBytes(cachedChunks);
cachedChunks = null;

if (length && pdfFile.length !== length) {
warn("reported HTTP length is different from actual");
}
pdfManagerArgs.source = pdfFile;

newPdfManager = new LocalPdfManager(pdfManagerArgs);
resolve(newPdfManager);
}
Expand Down
5 changes: 0 additions & 5 deletions src/display/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,6 @@ const RENDERING_CANCELLED_TIMEOUT = 100; // ms
* cross-site Access-Control requests should be made using credentials such
* as cookies or authorization headers. The default is `false`.
* @property {string} [password] - For decrypting password-protected PDFs.
* @property {number} [length] - The PDF file length. It's used for progress
* reports and range requests operations.
* @property {PDFDataRangeTransport} [range] - Allows for using a custom range
* transport implementation.
* @property {number} [rangeChunkSize] - Specify maximum number of bytes fetched
Expand Down Expand Up @@ -353,7 +351,6 @@ function getDocument(src = {}) {
const pagesMapper = src.pagesMapper || new PagesMapper();

// Parameters whose default values depend on other parameters.
const length = rangeTransport ? rangeTransport.length : (src.length ?? NaN);
const useSystemFonts =
typeof src.useSystemFonts === "boolean"
? src.useSystemFonts
Expand Down Expand Up @@ -425,7 +422,6 @@ function getDocument(src = {}) {
password,
disableAutoFetch,
rangeChunkSize,
length,
docBaseUrl,
enableXfa,
evaluatorOptions: {
Expand Down Expand Up @@ -497,7 +493,6 @@ function getDocument(src = {}) {

networkStream = new NetworkStream({
url,
length,
httpHeaders,
withCredentials,
rangeChunkSize,
Expand Down
7 changes: 1 addition & 6 deletions src/display/fetch_stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,12 @@ class PDFFetchStreamReader extends BasePDFStreamReader {
const {
disableRange,
disableStream,
length,
rangeChunkSize,
url,
withCredentials,
} = stream._source;

this._contentLength = length;
this._isStreamingSupported = !disableStream;
this._isRangeSupported = !disableRange;
// Always create a copy of the headers.
const headers = new Headers(stream.headers);

Expand All @@ -114,10 +111,8 @@ class PDFFetchStreamReader extends BasePDFStreamReader {
rangeChunkSize,
disableRange,
});

this._contentLength = contentLength;
this._isRangeSupported = isRangeSupported;
// Setting right content length.
this._contentLength = contentLength || this._contentLength;

this._filename = extractFilenameFromHeader(responseHeaders);

Expand Down
11 changes: 2 additions & 9 deletions src/display/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,6 @@ class PDFNetworkStreamReader extends BasePDFStreamReader {

constructor(stream) {
super(stream);
const { length } = stream._source;

this._contentLength = length;
// Note that `XMLHttpRequest` doesn't support streaming, and range requests
// will be enabled (if supported) in `this.#onHeadersReceived` below.

Expand Down Expand Up @@ -229,12 +226,8 @@ class PDFNetworkStreamReader extends BasePDFStreamReader {
rangeChunkSize,
disableRange,
});

if (isRangeSupported) {
this._isRangeSupported = true;
}
// Setting right content length.
this._contentLength = contentLength || this._contentLength;
this._contentLength = contentLength;
this._isRangeSupported = isRangeSupported;

this._filename = extractFilenameFromHeader(responseHeaders);

Expand Down
2 changes: 1 addition & 1 deletion src/display/network_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function validateRangeRequestCapabilities({
);
}
const rv = {
contentLength: undefined,
contentLength: 0,
isRangeSupported: false,
};

Expand Down
14 changes: 4 additions & 10 deletions src/display/node_stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,9 @@ class PDFNodeStreamReader extends BasePDFStreamReader {

constructor(stream) {
super(stream);
const { disableRange, disableStream, length, rangeChunkSize, url } =
stream._source;
const { disableRange, disableStream, rangeChunkSize, url } = stream._source;

this._contentLength = length;
this._isStreamingSupported = !disableStream;
this._isRangeSupported = !disableRange;

const fs = process.getBuiltinModule("fs");
fs.promises
Expand All @@ -79,13 +76,10 @@ class PDFNodeStreamReader extends BasePDFStreamReader {
this._reader = readableStream.getReader();

const { size } = stat;
if (size <= 2 * rangeChunkSize) {
// The file size is smaller than the size of two chunks, so it doesn't
// make any sense to abort the request and retry with a range request.
this._isRangeSupported = false;
}
// Setting right content length.
this._contentLength = size;
// When the file size is smaller than the size of two chunks, it doesn't
// make any sense to abort the request and retry with a range request.
this._isRangeSupported = !disableRange && size > 2 * rangeChunkSize;

// We need to stop reading when range is supported and streaming is
// disabled.
Expand Down
2 changes: 1 addition & 1 deletion test/unit/network_utils_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ describe("network_utils", function () {
})
).toEqual({
isRangeSupported: false,
contentLength: undefined,
contentLength: 0,
});
});

Expand Down
85 changes: 85 additions & 0 deletions web/internal/canvas_context_details_view.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/* Copyright 2026 Mozilla Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

.gfx-state-section {
padding-inline: 12px;
}

.gfx-state-section + .gfx-state-section {
margin-top: 8px;
padding-top: 8px;
border-top: 1px solid var(--border-color);
}

.gfx-state-title {
display: flex;
align-items: center;
justify-content: space-between;
gap: 4px;
color: var(--accent-color);
font-weight: bold;
margin-bottom: 4px;
}

.gfx-state-stack-nav {
display: flex;
align-items: center;
gap: 2px;
font-weight: normal;
font-size: 0.8em;
}

.gfx-state-stack-button {
padding: 0 3px;
border: 1px solid currentcolor;
border-radius: 2px;
background: transparent;
color: inherit;
cursor: pointer;
line-height: 1.3;

&:disabled {
cursor: default;
opacity: 0.35;
}
}

.gfx-state-stack-pos {
min-width: 4ch;
text-align: center;
font-variant-numeric: tabular-nums;
}

.gfx-state-row {
display: flex;
align-items: center;
gap: 8px;
padding: 1px 0;
}

.gfx-state-key {
color: var(--muted-color);
flex-shrink: 0;
min-width: 20ch;
}

.gfx-state-val {
color: var(--number-color);
flex: 1 1 0;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
Loading
Loading