Document Embed Inline API: How to share adobeDCView for multiples PDFs

Community Beginner ,
Jan 27, 2021 Jan 27, 2021

Copy link to clipboard

Copied

Hi, I have multiples PDFs which have to show on a web page. I load next PDF when user click on next button using Ajax, but it take a lot of time 4-5 seconds for each PDF (each PDF has single page). When I declare adobeDCView as global variable then it does not load next PDF on adobe-dc-view. 

There is one solution, create multiple div like adobe-dc-view1, adobe-dc-view2, adobe-dc-view3 on runtime and load PDF in div in background and when user click on next button then hide current div and show next div, but I wonder if there is already available something in SDK. 

 

 

var currPage = 1;

document.addEventListener("adobe_dc_view_sdk.ready", function() {
        window.adobeDCView = new AdobeDC.View({clientId: "id", divId: "adobe-dc-view"});
        getNextPage(id, currPage);
    });

    function loadPdf(pdfPath) {
        adobeDCView.previewFile({
            content:{location: {url: pdfPath }},
            metaData:{fileName: "Test.pdf"}
        }, viewerConfig);
    }

   function getNextPage(cId,pageNumber) {
        console.log("id:" + id + ", pageNumber: " + pageNumber);
        $.ajax({
            type: 'GET',
            url: 'https://www.domain.com/get-pdf-next-page',
            data: {id: cId, page_number: pageNumber},
            success: function(responsedata, status, xhr) {
                loadPdf(responsedata);
                $('#page_num').html(pageNumber);
                if (pageNumber == 1) { $("#prev").prop('disabled', true); } else { $("#prev").prop('disabled', false); }
            },
            error: function(responsedata) {
                console.log(responsedata);
            },
        });
    }

 

 

TOPICS
How to, PDF Embed API, PDF Services API

Views

68

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
no replies

Have something to add?

Join the conversation