4

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 ...

Muotaz
  • 53
  • 1
  • 4

1 Answers1

4

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?

JosephH
  • 37,173
  • 19
  • 130
  • 154
  • Yes indeed, there were some garbage before the PDF header, but what is even weirder is that when the same buffer is saved to a file it is opened by what ever viewer without problems. Thanks! – Muotaz Aug 28 '15 at 15:32