Skip to content

Issue with text layer rendering: pdfjs v3.3.122 #18261

@marija-popovic

Description

@marija-popovic

Since upgrading from pdfjs v2.5.207 to pdfjs v3.3.122 I have had issues with rendering a text layer of pdfs. Previously, for this purpose, class TextLayerBuilder was used and it was working correctly.

This is the code that was used:

const textLayer = new TextLayerBuilder({
        eventBus: new Proxy({}, { get: () => () => {} }),
        textLayerDiv: this.textLayerElement.nativeElement,
        pageIndex: this.page.pageIndex,
        viewport,
});

textLayer.setTextContent(this.textContent);
textLayer.render();

Now, the constructor of TextLayerBuilder doesn't accept the same parameters as before and it is not clear how the same behavior should be achieved with these changes. Instead, I tried to use renderTextLayer function:

const renderTextLayerTask = renderTextLayer({
        textContentSource: this.textContent,
        container: this.textLayerElement.nativeElement,
        viewport,
        textDivs: [],
});

but it resulted in having issues with the alignment and font size of the pdf text, for example:

small-pdf

I would appreciate if some instructions for overcoming this issue could be provided, either with the usage of TextLayerBuilder or renderTextLayer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions