box/box-content-preview

Some PDFs are not rendered correctly

stariqmi opened this issue · 3 comments

Environment:

  • Preview version: 1.35
  • Browser name and version: Chrome 64
  • Operating system and version:OS X 10
  1. Upload a PDF to Box (not all document will result in this problem)
  2. View the PDF in Box Content Preview
  3. Refresh the PDF in Box Content Preview, observe colors are off

On the left, the document shows as expected, on the right is after refreshing document.

different colors

I have narrowed this issue down to the DocLoader.js. Specifically the following code:

   /**
     * Chooses a representation. Assumes that there will be only
     * one specific representation. In other words we will not have
     * two png representation entries with different properties.
     *
     * @param {Object} file - Box file
     * @param {Object} viewer - Chosen Preview viewer
     * @return {Object} The representation to load
     */
    determineRepresentation(file, viewer) {
        let repOverride;

        // For PDF files, use original rep unless PDF rep is successful since it'll be faster
        const rep = super.determineRepresentation(file, viewer);
        const status = RepStatus.getStatus(rep);
        if (file.extension === 'pdf' && rep.representation === 'pdf' && status !== STATUS_SUCCESS) {
            repOverride = getRepresentation(file, ORIGINAL_REP_NAME);
        }

        return repOverride || rep;
    }

Load document the first time - code defaults to the ORIGINAL represenation since the PDF representation is PENDING. It seems like the PDF representation is always pending till we open the document the first time

// This always works
{
  "content": {
    "url_template": "https://dl.boxcloud.com/api/2.0/files/283946684422/content?preview=true&version=298749103078"
  },
  "representation": "ORIGINAL",
  "status": {
    "state": "success"
  }
}

Reload document and the PDF represenation is available i.e SUCCESS - code loads that and this is the representation that is wonky

// This doesn't always work
{
  "representation": "pdf",
  "properties": {},
  "info": {
    "url": "https://api.box.com/2.0/internal_files/283946684422/versions/298749103078/representations/pdf"
  },
  "status": {
    "state": "success"
  },
  "content": {
    "url_template": "https://dl.boxcloud.com/api/2.0/internal_files/283946684422/versions/298749103078/representations/pdf/content/{+asset_path}"
  }
}

Hey @stariqmi thanks for the report! Did this just recently start happening? Would you be able to provide a shared link to the pdf?

We observed this recently but could have been happening before and with other documents. Unfortunately I cannot share the document publicly. This seems more of an issue with the processing of the document and using the original representation over the PDF representation fixes it.

Hey @stariqmi this should be resolved now, so closing the issue