shouldUseMinimumDownloads on UI vs. Core LoadDocumentOptions

WebViewer Version: 11

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

Please give a brief summary of your issue:
shouldUseMinimumDownloads does not exist on UI.LoadDocumentOptions

Please describe your issue and provide steps to reproduce it:
shouldUseMinimumDownloads does not exist on UI.LoadDocumentOptions which is the type expected to load documents (instance.UI.LoadDocument()). Although the type.d.ts file indicates via comment that the UI Options class inherits from Core Options class, Typescript apparently does not see this. I am unsure if the expected workflow is to simply cast “as any” or if the inheritance is not properly set.

In order to use the shouldUseMinimumDownloads flag, I am creating a Core.LoadDocumentOptions object, but without “as any” we receive the following error:

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

// boilerplate webviewer setup before and after snippet
const loadOptions: Core.LoadDocumentOptions = {
        extension: docExtension,
        docId,
        filename: 'document',
        customHeaders,
        shouldUseMinimumDownloads: true,
      };

      instance.UI.loadDocument(docFullUrl, loadOptions);
1 Like

Hello George,

Thank you for contacting WebViewer Forums.

The shouldUseMinimumDownloads parameter does exist as part of the LoadDocumentOptions type definition but is not necessary to declare the const loadOptions with LoadDocumentOptions. It is also recommended to have a value for each of the parameters. For example:

const loadOptions= {
    extension: docExtension,
    docId: 'placeholder',
    filename: 'document',
    customHeaders: 'placeholder',
    shouldUseMinimumDownloads: true,
  };

Regards,
Luke

1 Like

Thanks, Luke. Understood. We actually do have values set further up for those “missing” properties, apologies for the omission.

So, essentially we’re relying on this being an anonymous/any object? I prefer to “type” things in typescript. loadDocument expects an option type of UI.loadDocumentOptions yet when you enforce that type, you get errors. If it works without typing, then cool, but still IMO not a best practice.

image

Edit: To be clear, I do see no errors without typing, as indicated, so we should at least have a path forward:
image

1 Like

Hello George,

Thank you for your reply.

I see the issue now and apologies for not noticing it earlier. Using instance.UI.loadDocument() which takes in UI.loadDocumentOptions but in that type definition shouldUseMinimumDownloads does not exist.

I would advise changing it to instance.Core.documentViewer.loadDocument() which takes in Core.LoadDocumentOptions where that parameter does exist. For example:

const loadOptions: Core.LoadDocumentOptions  = {
    shouldUseMinimumDownloads: true,
  };

  instance.Core.documentViewer.loadDocument(
    'https://pdftron.s3.amazonaws.com/downloads/pl/demo-annotated.pdf',
    loadOptions
  );

This should fix the issue. For more information, see our API guide here: Apryse WebViewer Namespace: Core

Regards,
Luke

1 Like

Ahh! Thanks, I didn’t know there was a different loadDocument function to use. Will give that a shot.

1 Like