Performace of Webviewer for large PDF file is very slow and many times it fails to open or save comments.

WebViewer Version: 2.2.3

Do you have an issue with a specific file(s)?
No, all Large PDF (>2 GB) files have this performance issues.
Can you reproduce using one of our samples or online demos?
Yes, it is same low performance in all the environments.
Are you using the WebViewer server?
Yes
Does the issue only happen on certain browsers?
No All browser
Is your issue related to a front-end framework?
N/A
Is your issue related to annotations?
N/A

Please give a brief summary of your issue:
(Think of this as an email subject)
Web Viewer performace is very low on Large PDF files (>2 GB).

Please describe your issue and provide steps to reproduce it:
(The more descriptive your answer, the faster we are able to help you)
Web Viewer performace is very low on Large PDF files (>2 GB). Have to re-try multiple times to load PDF in viewer from web application. After opening while saving Comments it fails , have to re-try multiple times. I have requirement to load and save comments on PDF files up to 15GB. I have tried optional like Linerising when svaing,it dosent make any difference.

Please provide a link to a minimal sample where the issue is reproducible:
N/A

1 Like

Hello, I’m AiRon, an automated tech support bot :robot:
While you wait for one of our customer support representatives, I can help you with your question.


Handling large PDF files in WebViewer can indeed present performance challenges, especially when dealing with files as large as 2 GB or more. Here are a few strategies to optimize and improve performance for such scenarios.

Some things you can try:

  • Use WebViewer Server: Ensure that you are using the WebViewer Server to offload processing from the client to the server. This can greatly enhance performance with large files.

  • Optimize PDF Files: Consider optimizing your PDF files to reduce their size and complexity. This can involve compressing images, removing redundant data, and linearizing the PDF for faster streaming.

  • Ensure Network Proximity: Place your WebViewer Server as close as possible to the file source to minimize network latency and improve file retrieval speeds.

  • Use the Downloader Option: Enable the downloader option for efficient streaming of linearized PDF files. This can help in reducing the time taken to load the initial pages of the PDF.

  • Preload Worker Files: Preload necessary worker files to ensure that the WebViewer is ready to handle large files without delay.



Here are some resources that might help you:


Hopefully, this helps you solve your problem while you wait for a human to get back to you.

1 Like

Hello Keerthinath,

If you are loading files as large as 15GB, it is very likely and expected that the document will load very slowly. We are limited by the browser and that does all the rendering. If you try loading the PDF in Chrome, do you see the same performance issues?

Please provide the following:

  1. WebViewer code for the constructor and how you’re loading the file
  2. A download link to a sample file and HAR file for the issue

Best Regards,
Darian

1 Like

I am using chrome only for viewing. I can understand that the performance will be low, but many a times it even fail to open the file in viewer, i have to close and re-initiate it. if you are luckey it works. Currently i am attaching 3 GB file where this is a issue as well. We have requirement to load upto 15GB file.

Please find the requested details below.

  1. WebViewer code for the constructor and how you’re loading the file

function initializeWebviewer(options) {
let { siteId, licenseKey, isPasswordProtected } = options;
const useWebviewerClient = isPasswordProtected == “True”;
$(function () {
dssSigninCallback(siteId, function (user) {
WebViewer.Iframe(
{
path: “/Scripts/webviewer/lib”,
webviewerServerURL:
useWebviewerClient
? null : ${window.location.origin}/webviewer,
licenseKey,
fullAPI: true,
disabledElements: [
“downloadButton”,
“printButton”,
“thumbnailControl”,
“documentControl”,
],
disableLogs: true,
css: “/Scripts/webviewer.css”,
ui: “legacy”
},
document.getElementById(“webviewerContainer”)
).then((instance) => renderWebviewer(instance, user, options));
});
});
}

function render() {
window.top.webviewer = instance;
configureWebviewer();
loadFileInWebviewer();
configureWebviewerMode();
}

function configureWebviewer() {
    const userId = user.profile["http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier"].toLowerCase();
    const { fileName } = options;
    const isPdfFile = fileName.toLowerCase().indexOf(".pdf") + 4 == fileName.length;
    UI.setLanguage(navigator.language.substring(0, 2));
    annotationManager.setCurrentUser(userId);
    annotationManager.enableReadOnlyMode();
    if (isPdfFile) {
        documentViewer.setFitMode(documentViewer.FitMode.FitWidth);
        UI.openElements(["leftPanel", "notesPanel"]);
    } else {
        documentViewer.setFitMode(documentViewer.FitMode.FitPage);
        UI.openElements(["leftPanel"]);
    }
};

function loadFileInWebviewer() {
    const { fileName, fileUrl, cacheKey, xfdfUrl } = options;
    const isTiffFile =
        fileName.toLowerCase().indexOf(".tif") + 4 == fileName.length ||
        fileName.toLowerCase().indexOf(".tiff") + 5 == fileName.length;
    if (isTiffFile) {
        loadTiffFileInWebviewer(fileUrl);
    } else {
        showStatusDialog(getLocalizedText("59AE4BE7-9563-4960-9837-75AF40BD0E9C"), false);
        instance.UI.loadDocument(fileUrl, {
            filename: fileName,
            cacheKey: (btoa(window.location.origin) + "_" + btoa(cacheKey)).padEnd(40, "_"),
            customHeaders: { Authorization: `Bearer ${user.access_token}` },
        });
        if (xfdfUrl) {
            documentViewer.addEventListener("annotationsLoaded", async () => {
                showStatusDialog(getLocalizedText("D5ECDCC3-C49B-4305-81B0-2B0ECD45779E"), false);
                const xfdfString = await getXfdfString(xfdfUrl, user.access_token);
                const existingAnnotations = annotationManager.getAnnotationsList();
                annotationManager.deleteAnnotations(existingAnnotations, { force: true });
                annotationManager.importAnnotations(xfdfString);
                annotationManager.setPermissionCheckCallback((author) => {
                    return author.toLowerCase() == annotationManager.getCurrentUser().toLowerCase();
                });
                await SetUserDisplayName();
                UI.closeElements(["SaveCommentsStatusModal"]);
                registerEvents();
            });
        } else {
            UI.closeElements(["SaveCommentsStatusModal"]);
        }
    }
}

function configureWebviewerMode() {
    const { fileRno, mode, canComment } = options;

    if (mode == "comment") {
        if (canComment === "False") {
            alert(getLocalizedText("08736852-1a44-433b-a508-ac28e5302ffc"));
        } else {
            addSaveButtonToWebviewer(fileRno);
            annotationManager.disableReadOnlyMode();
            UI.disableElements([
                "toolbarGroup-FillAndSign",
                "toolbarGroup-Forms",
                "toolbarGroup-Edit",
            ]);
            setStandardStamps();

            annotationManager.addEventListener("annotationChanged", (annotations, action, { imported }) => {
                if (!imported && annotations.length == 1) {
                    const annot = annotations[0];
                    if (annot instanceof instance.Core.Annotations.StampAnnotation && action === 'add') {
                        const selectedStampDetails = stampDetailsList.find(item => item.pngBase64 === annot.image.src);
                        if (selectedStampDetails != null) {
                            annot.setCustomData('StampName', selectedStampDetails.name);

                            const annotationWidth = annot.Width;
                            const annotationHeight = annot.Height;
                            annot.Width = 100;
                            annot.Height = (annot.Width * annotationHeight) / annotationWidth;
                            instance.Core.annotationManager.redrawAnnotation(annot);
                        }
                    }
                }
            });

            annotationManager.addEventListener("annotationSelected", async (annotations, action) => {
                if (annotations.length == 1) {
                    const annot = annotations[0];
                    const originalStampDetails = stampDetailsList.find(item => item.name === annot.getCustomData('StampName'));
                    if (annot instanceof instance.Core.Annotations.StampAnnotation && action === 'selected' && originalStampDetails != null) {
                        const svgWithSystemAttributes = annot.getCustomData('SvgWithSystemAttributes');
                        let svgToReplaceAttributes = svgWithSystemAttributes != "" ? svgWithSystemAttributes : originalStampDetails.svg;

                        //replace system attributes if any
                        const systemAttributePlaceholders = getMatchingAttributes(svgToReplaceAttributes, false);
                        if (systemAttributePlaceholders.length > 0 && svgWithSystemAttributes == "") {
                            svgToReplaceAttributes = await replaceSystemAttributes(annot, fileRno, originalStampDetails.stampRno);
                        }
                        //replace custom attributes if any
                        const customAttributePlaceholders = getMatchingAttributes(svgToReplaceAttributes);
                        if (customAttributePlaceholders.length > 0) {
                            replaceCustomAttributes(annot, svgToReplaceAttributes, customAttributePlaceholders);
                        }
                    }
                }
            });
        }
    }
}

  1. A download link to a sample file and HAR file for the issue

(Microsoft OneDrive)

Hello Keerthinath,

I don’t seem to have access to that drive. Can you give darian.chen@apryse.com access?