Search code examples
androidmupdf

mupdf cannot recognize version marker


When opening and decrypting a file into a buffer in Android, and trying to open the file using Mupdf OpenBuffer method, it fails with the following message:

cannot recognize version marker

The viewer shows all the pages blank, although it gets number of pages in document correctly.

The same buffer when saved to a file and opening that file, it works perfectly.

I have compared the code I use to the Mupdf sample, and didn't find anything significant difference.

What might be the cause of this ? Thanks in advance ...


Solution

  • That error means:

    the first 5 bytes of the file were not %PDF-

    You could try adding:

    printf("first bytes are: %d, %d, %d, %d, %d", buf[0], buf[1], buf[2], buf[3], buf[4]);
    

    to the file pdf-xref.c in function pdf_load_version() - the line before the memcmp. This might reveal what's actually in the buffer, perhaps it has somehow gone through a string conversion of something?