Skip to content

Text overlay is positioned incorrectly #6465

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Pixelworlds opened this issue Sep 21, 2015 · 1 comment
Closed

Text overlay is positioned incorrectly #6465

Pixelworlds opened this issue Sep 21, 2015 · 1 comment

Comments

@Pixelworlds
Copy link

It appears that the text overlay for a converted pdf document is misaligned. The PDF I used is available here

My current code is as follows (where PDFDOC is the url provided above):

var PAGE_TO_VIEW = 1;
var SCALE = 1.0;

var pdfDoc = null;
var pageNum = 1;
var pageRendering = false;
var pageNumPending = null;

var container = document.getElementById('viewerContainer');
var pdfLinkService = new PDFJS.PDFLinkService();
var pdfViewer = new PDFJS.PDFViewer({
    container: container,
    linkService: pdfLinkService,
});

var getPDF = function() {
    PDFJS.getDocument(PDFDOC).then(function(pdf) {
        pdfDoc = pdf;

        document.getElementById('total-pg-num').textContent = pdfDoc.numPages;
        document.getElementById('current-pg-num').textContent = pageNum;

        pdfViewer.setDocument(pdfDoc);
        pdfLinkService.setDocument(pdfDoc, null);
    });
}

function onNextPage() {
    if (pageNum >= pdfDoc.numPages) return;

    pageNum++;
    $('#page' + pageNum).goTo(70);
    document.getElementById('current-pg-num').textContent = pageNum;
}

function onPrevPage() {
    if (pageNum <= 1) return;

    pageNum--;
    $('#page' + pageNum).goTo(70);
    document.getElementById('current-pg-num').textContent = pageNum;
}

$(document).ready(function() {
    pdfLinkService.setViewer(pdfViewer);

    document.getElementById('doc-next').addEventListener('click', onNextPage);
    document.getElementById('doc-prev').addEventListener('click', onPrevPage);

    container.addEventListener('pagesinit', function () {
        pdfViewer.currentScale = SCALE;
    });

    getPDF();
});
@timvandermeij
Copy link
Contributor

Closing since this is fixed by #12896 and other work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants