Could not use incremental download , Reason: Could not retrieve Content-Range header

Product: WebViewer

Product Version: 8.0.1

Please give a brief summary of your issue:
(Think of this as an email subject)
Pdf pages are not loading incrementally, instead whole pdf is getting loaded and that is taking a lot of time

Please describe your issue and provide steps to reproduce it:
(The more descriptive your answer, the faster we are able to help you)
Whenever I am opening pdf’s in client side, I am getting this message in console that says Could not use incremental download , Reason: Could not retrieve Content-Range header.
Even after setting the Access-Control-Expose-Headers: Content-Range in server side the issue still persist.
We are using amazon aws s3 for storing the pdf

Please provide a link to a minimal sample where the issue is reproducible:
This is how I am setting CORS in node app

    private config(): void {
      const options: cors.CorsOptions = {
        allowedHeaders: [
          'Origin',
          'X-Requested-With',
          'Content-Type',
          'Accept',
          'X-Access-Token',
          'Authorization',
        ],
        exposedHeaders:[
          'Content-Range'
        ],
        credentials: true,
        methods: 'GET,HEAD,OPTIONS,PUT,PATCH,POST,DELETE',
        origin: '*',
        preflightContinue: false,
        
      };
      this.app.use(cors(options));
      this.app.options('*', cors(options));
      this.app.use(bodyParser.json({ limit: '50mb', type: 'application/json' }));
      this.app.use(bodyParser.urlencoded({ limit: '50mb', extended: true, parameterLimit: 50000 }));
      this.app.use(Morgan(':method :url :status :res[content-length] - :response-time ms'));
    }`Preformatted text`

This is the message i am getting and that is stopping me from testing my linearized pdf for fast loading of pages:

Hi,

The issue seems to be related to your server configuration. I just found a post regarding this , please take a look and make sure the server is returning the correct response header parameters.

Wanbo

The thing is I am serving pdf from aws s3 bucket and even when It is a linearized pdf (as mentioned in above attachment of documentation of pdftron) the incremental download is not working, it just says could not retrieve content-range header .
I am stuck at this point, any suggestions would be really helpful.
Thanks!!

Could you provide a sample link to your file on s3? I can help try on my side. Thanks.

Wanbo

Here is one of the link to s3 file:
https://slate-dev-blob.s3.amazonaws.com/tenant/6/project/1317/feature/5/fac8b1fe-5308-45a9-97d8-399aaa8179bf.pdf?AWSAccessKeyId=AKIAQK4RE22TAD32KED6&Expires=1661756064&Signature=JZG4vSNGjMJM0y0gfxCGrEhsCes%3D&response-content-disposition=attachment%3B%20filename%3DHennepin%2520County%2520Medina%2520Public%2520Works%2520Facility%2520Welding%2520Shop%2520Expansion%2520drawings%2520(1)%2520(1)%2520(1).pdf

Thanks!!

Hi,

I tried loading the test file with our online sample - JavaScript PDF Viewer Demo . And I got error saying that the file is not linearized, as shown below.

Also the instance.docViewer.getDocument().isLinearized() returns false.

Could you double check that if this test file is linearized? Thanks.

Wanbo

Hi @Wanbo_Li How can I make this pdf linearize, I am storing these pdf’s in s3 bucket so is their any way I could write a lamda function to linearize this pdf’s

Hi,

You can try the getFileData API and pass in options with Core.SaveOptions.LINEARIZED flag. Code sample as below:

var doc = await instance.docViewer.getDocument().getFileData({flags: instance.Core.SaveOptions.LINEARIZED});

Thanks.

Wanbo

Thankyou @Wanbo_Li I am able to solve this issue and it is working fine for me

Great! No problem.

Wanbo