WebViewer v11.2.0 not opening offline document in mobile apps

WebViewer Version: 11.2.0

Do you have an issue with a specific file(s)? No
Can you reproduce using one of our samples or online demos? No
Are you using the WebViewer server? No
Does the issue only happen on certain browsers? No
Is your issue related to a front-end framework? Yes
Is your issue related to annotations? No

Please give a brief summary of your issue:
(Think of this as an email subject)
WebViewer v11.2.0 not opening offline document in mobile apps

Please describe your issue and provide steps to reproduce it:
(The more descriptive your answer, the faster we are able to help you)
In Mobile apps if the mobile is offline we allow user to load document in offline mode for that we are using PartRetriver which is not working and throwing error while reading document data.

Code for PartRetriver:

/** Generates a part retriever using PDFTron API */
            this.generateLocalPartRetriever(this.item).then(
                async (partRetriever: any) => {
                    console.log('partRetriever', partRetriever);
                    /** Load the XOD file */
                    const { documentViewer } = Core;
                    await documentViewer.loadDocument(partRetriever, {
                        docId: this.item.distributionContentId,
                        extension: 'xod',
                        filename: this.item.fileNameWithoutExtension + '.xod',
                    });
                },
                this.fail.bind(this),
            );
private generateLocalPartRetriever(item: IContent) {
        console.log('path', this.offline.generateFileName(this.item));
        console.log('directory', Directory.Data);
        return new Promise(async (resolve, reject) => {
            Filesystem.readFile({
                path: this.offline.generateFileName(this.item),
                directory: Directory.Data
            }).then(async (file) => {
                console.log('file', file);
                const blob: any = this.offline.b64toBlob(file.data,
                    'application/octet-stream',
                    this.offline.generateFileName(this.item));
                let partRetriever;
                try {
                    const { PartRetrievers } = this.viewerInstance.Core;
                    partRetriever = await PartRetrievers
                        .getPartRetriever(PartRetrievers.Types.LocalPartRetriever, blob);
                    resolve(partRetriever);
                } catch (err) {
                    console.log('Error generating part retriever', err);
                    reject();
                    return;
                }
            });
        });
    }

Need help to solve this issue as its giving below error in logs.

Unhandled Promise Rejection: TypeError: undefined is not an object (evaluating '(y.slice||y.webkitSlice||y.mozSlice||y.uRa).call')

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

1 Like

Hi there,

It looks like you are loading the document as a XOD file, has this method worked for you in the past? Can you confirm that you are loading a blob in the loadDocument API as suggested here?

You can also use our offline WebViewer sample project suggested here for reference:

Best regards,
Kevin

1 Like

Yes,

Before v11.2.0 it was working fine with Offline in both Web & Mobile Apps but after upgrading it its not working and throwing JS error.

Note: I am using PartRetriver logic here given by PDFTron but some how its not working in latest version.

1 Like

Hi there,

Which guide did you follow for the partretriever logic?
Could you also share a minimal runnable sample project to reproduce this issue?

Best regards,
Kevin

1 Like

I am using below method for PartRetriver

https://sdk.apryse.com/api/web/Core.PartRetrievers.html#.getPartRetriever

1 Like

Hi there,

Could you please check the network panel and see if the requests are being made from the usage of the API?

best regards,
Kevin

1 Like

Hey Kevin,

Thanks for the reply but I m not getting what do you mean by Usage API? is it document cache through URL ? or something else need to check? Let me know more details so I can check.

Thanks

1 Like

Hi there,

To clarify, when you use the part retriever APIs, do you see anything in the network panel such as a fetch going through?

For example, if I use the following snippet:

const newDocument = new instance.Core.Document('1', 'pdf')
const newPartRetriever = await instance.Core.PartRetrievers.getPartRetriever(
  'ExternalPdfPartRetriever',
  'https://pdftron.s3.amazonaws.com/downloads/pl/demo-annotated.pdf',
  {
    filename: "demo-annotated.pdf",
    withCredentials: false,
    useDownloader: true,
  });

newDocument.loadAsync(
  newPartRetriever,
  (e) => { e ? console.log("Error", e) : console.log("Loaded") },
  {
    extension: 'pdf',
  }
)

This is what I would see in the network panel:

best regards,
Kevin

2 Likes

Yes Download is working fine.

But when I try to open download xod its not opening and throwing above JS error which I mention in my query.

Let me know if you need any other details.

Thanks,
Dgosai

1 Like

Thank you for your reply,

Can you share both original and the downloaded XOD file that you are attempting to open on WebViewer?

best regards,
Kevin

1 Like