Search code examples
androidpdfannotationsmupdf

Annotations of pdf using MuPDF on Android


I am developing an android application which should help users to annotate the PDF file. I am using MuPDF to parse the PDF on android device. I am able to read the PDF but unable to figure out a way which will help me implement annotations features for the PDF. I couldn't find any sample core nor could I find any manuals that explains what I am looking for. Anyone have any sample code, any other material or any links which will give me an idea on how can I support simple annotations (say draw a rectangle or write freely) on PDF files.

Any kind of help in this regard is much appreciated.

Thanks in advance.


Solution

  • Do you want to store the annotations in the PDF file or separately?

    The former is not possible with muPDF.

    However, if you intend to store the annotations separately, then you could conceivably render the PDF to a canvas as background and then draw over it. You'll still have to write the equivalent of a drawing app. There's "FingerPaint" in the Android samples, and also Android Paint in open source.

    If you want to highlight specific text in the PDF, things will get quite complex. You'd have to extract the character dimensions from fitz and manage a cursor of sorts in your touch handlers. This isn't impossible, but far from trivial.