1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 15:18:08 +02:00

[api-minor] Remove the disableCombineTextItems option

*Please note:* This parameter has never been used within the PDF.js library/viewer itself, and it was only ever added for backwards compatibility reasons.

This parameter was added in PR 7475, over six years ago, to try and optionally maintain the previous *default* text-extraction behaviour.
However as part of the general text-extraction improvements in PR 13257, almost two years ago, the `disableCombineTextItems` functionality was accidentally "broken" in various ways. Note how the only (very basic) unit-test was updated in a way that doesn't really make sense, since generally speaking you'd expect that using the option should result in *more* (or at least the same number of) text-items. Furthermore there's also the recent issue 16209, where the option causes almost all textContent to be concatenated together.

Hence this patch proposes that we simply remove the `disableCombineTextItems` option since it's essentially unused/untested functionality, as evident from the fact that it took almost two years for someone to notice that it's broken.
This commit is contained in:
Jonas Jenwald 2023-03-30 13:36:42 +02:00
parent 09da8026b6
commit 5063a6f2a9
6 changed files with 11 additions and 41 deletions

View file

@ -1010,7 +1010,6 @@ class Annotation {
task,
resources,
includeMarkedContent: true,
combineTextItems: true,
sink,
viewBox,
});

View file

@ -511,13 +511,7 @@ class Page {
});
}
extractTextContent({
handler,
task,
includeMarkedContent,
sink,
combineTextItems,
}) {
extractTextContent({ handler, task, includeMarkedContent, sink }) {
const contentStreamPromise = this.getContentStream();
const resourcesPromise = this.loadResources([
"ExtGState",
@ -545,7 +539,6 @@ class Page {
task,
resources: this.resources,
includeMarkedContent,
combineTextItems,
sink,
viewBox: this.view,
});

View file

@ -2236,7 +2236,6 @@ class PartialEvaluator {
task,
resources,
stateManager = null,
combineTextItems = false,
includeMarkedContent = false,
sink,
seenStyles = new Set(),
@ -2534,11 +2533,7 @@ class PartialEvaluator {
return false;
}
if (
!combineTextItems ||
!textState.font ||
!textContentItem.prevTransform
) {
if (!textState.font || !textContentItem.prevTransform) {
return true;
}
@ -3191,7 +3186,6 @@ class PartialEvaluator {
task,
resources: xobj.dict.get("Resources") || resources,
stateManager: xObjStateManager,
combineTextItems,
includeMarkedContent,
sink: sinkWrapper,
seenStyles,

View file

@ -741,7 +741,7 @@ class WorkerMessageHandler {
});
handler.on("GetTextContent", function (data, sink) {
const pageIndex = data.pageIndex;
const { pageIndex, includeMarkedContent } = data;
pdfManager.getPage(pageIndex).then(function (page) {
const task = new WorkerTask("GetTextContent: page " + pageIndex);
@ -755,8 +755,7 @@ class WorkerMessageHandler {
handler,
task,
sink,
includeMarkedContent: data.includeMarkedContent,
combineTextItems: data.combineTextItems,
includeMarkedContent,
})
.then(
function () {

View file

@ -1120,8 +1120,6 @@ class PDFDocumentProxy {
* Page getTextContent parameters.
*
* @typedef {Object} getTextContentParameters
* @property {boolean} disableCombineTextItems - Do not attempt to combine
* same line {@link TextItem}'s. The default value is `false`.
* @property {boolean} [includeMarkedContent] - When true include marked
* content items in the items array of TextContent. The default is `false`.
*/
@ -1602,17 +1600,13 @@ class PDFPageProxy {
* @param {getTextContentParameters} params - getTextContent parameters.
* @returns {ReadableStream} Stream for reading text content chunks.
*/
streamTextContent({
disableCombineTextItems = false,
includeMarkedContent = false,
} = {}) {
streamTextContent({ includeMarkedContent = false } = {}) {
const TEXT_CONTENT_CHUNK_SIZE = 100;
return this._transport.messageHandler.sendWithStream(
"GetTextContent",
{
pageIndex: this._pageIndex,
combineTextItems: disableCombineTextItems !== true,
includeMarkedContent: includeMarkedContent === true,
},
{