Pdftron webviewer performance help

Product: Webviewer

Product Version: 7.3.0

Please give a brief summary of your issue:

I am having issues with regards to the performance of pdftron viewer. Specifically when navigating through a pdf file with many pages, I try to navigate to an arbitrary page in the middle of the file and wait for the page to load, But it takes more than a minute to show up.


In the video above, I am first supplying an api endpoint to provide the pdf to be loaded. in the 2nd half of the video, I am using a direct link to a pdf file in the server. As you can see, supplying the direct pdf file is faster to load.

Here is the endpoint in question

    public async Task<ActionResult> AttachmentPartial(int id, bool? verbose = true)

      var pathSession = this.Session[$"AttachmentPath{id}"];
      var fileNameSession = this.Session[$"AttachmentPathFileName{id}"];
      var fileContentSession = this.Session[$"AttachmentPathContent{id}"];

      var path = string.Empty;
      var fileName = string.Empty;
      byte[] fileContent = null;
      DateTime dateModified;
      var mimeType = string.Empty;

      if (pathSession != null)
        path = pathSession.ToString();

      if (fileNameSession != null)
        fileName = fileNameSession.ToString();

      if (fileContentSession != null)
        fileContent = (byte[])fileContentSession;

      var willLog = false;
      if (verbose.HasValue)
        willLog = verbose.Value;

      if (pathSession != null && fileNameSession != null && willLog)
        AuditLog.Log(false, $"Cache for AttachmentPartial is hit: (AttachmentPath{id})", Shell.User, this.PageCode, EventType.Info, this.PageCode);          
      if (string.IsNullOrEmpty(path) || string.IsNullOrEmpty(fileName) || fileContent == null)
        path = GetAttachment(id, verbose ?? true, out fileName);
        this.Session[$"AttachmentPath{id}"] = path;
        this.Session[$"AttachmentPathFileName{id}"] = fileName;

        if (!System.IO.File.Exists(path))
          return Redirect(WebHelper.ContentUrl("Error/FileNotFound"));
        fileContent = await Task.Run(() =>
          var file = System.IO.File.ReadAllBytes(path);
          this.Session[$"AttachmentPathContent{id}"] = file;
          return file;

      if (!System.IO.File.Exists(path))
        return Redirect(WebHelper.ContentUrl("Error/FileNotFound"));

      dateModified = System.IO.File.GetLastWriteTime(path);
      mimeType = MimeMapping.GetMimeMapping(path);

      return new RangeFileContentResult(fileContent, mimeType, fileName.Replace("%", "% "), dateModified);      


In the above code, basically read the contents of the file and output the byte range based on what the webviewer requests.
Subsequent requests doesn’t access the database because the data is already stored in session.

What I am asking is how can I improve the performance of my api endpoint? Is there any other configuration I can toggle to improve the webviewer’s performance?

Some additional information:
1.) The pdf file(s) are linearized.
2.) SharedArrayBuffer is enabled
3.) Byte Range Requests are enable

I can provide access to the site in question via email or any other private way.

Also in the video you can see that there are certain parts of the download where it struggles, would you be able to point out why this is? And is there something I can do to fix this?


Hello Adrianm
Thanks for contacting us for support. To better know what’s the issue you have, I need more information

  1. Is there any specific file are you using? (regarding the file size)
  2. Can you provide the code for us to config?
    If you can provide the site, you can send this to jhou@pdftron.com.
    Maybe you can check https://www.pdftron.com/documentation/web/guides/viewer-optimized-pdf/ and https://www.pdftron.com/documentation/web/guides/best-practices/ to get more information about how to optimize your webviewer

Best Regards

Hi jhou,

I already implemented the best practices stated in https://www.pdftron.com/documentation/web/guides/best-practices/ specifically:

  1. Loading documents with loadDocument
  2. Linearize PDF files
  3. Support range requests
  4. Support serving with Content-Encoding


  1. Keep original files
  2. Storing annotations

are not applicable to the page in question so they were not implemented

As for using docpub to optimize the file, I already tried it but it did not have an effect on the viewing experience.

I will send you the details to access the site via email.

Hi Adrian
Got your information from your email, if I need more information, I will let you know.


Hi Adrian
After checking back your video. It seems you are loading the same file two times. Can I know what’s the difference between you first time select the file and the second time you select the file? And can you provide a complete project setup with your server too? It seems I load my file from local, it quick. So I am not sure if there is a problem with your server.


Hi Andrian
I used the pdf from what you have shown in your video. I can reproduce the issue now it is indeed too slow. Just need more information so that we can handle it better


Hi Jack,

I loaded the same file two times in two different ways.
1st time - I loaded it using our api url “AttachmentPartial”. I would like to emphasize that this is done on a server and not locally.
2nd time - I loaded it using a direct link to a pdf file in the server

As you can see in the video, loading it via direct pdf file loads faster than the 1st method.

Hi Andrian
There is a possible solution to your issue. You can use useDownloader: false to load the file when there is a large linearized document with lots of pages. It will load the file once then it should perform better once it is loaded so the downside is you have to download everything up front. You can check this reference https://www.pdftron.com/documentation/web/guides/usedownloader-option/


Ok I will try this and get back to you

I already tried it it seems to work but, Is there any solution, where I still use the viewer’s downloader?
Disabling downloader is not ideal for us because we were hoping that by supporting byte range downloads we will prevent “download failed” issues that have happened to us in the past.

Hi Adrian
Sorry for the delay. For linearized documents with many pages it actually doesn’t work very well right now. That’s the reason I would like to suggest you to useDownloader: false. So please give me more time to figure out some other solution