Log of #mupdf at irc.freenode.net.

Search:
 <<<Back 1 day (to 2020/04/01)Fwd 1 day (to 2020/04/03)>>>20200402 
scottschafer Morning.So I've been trying to extend the WASM build to return a the list of annotations for a page. Really not sure of the best way to do this.16:14.40 
  I tried something along these lines:16:14.40 
  EMSCRIPTEN_KEEPALIVE16:14.40 
  char getAnnotations(fz_document doc, int page)16:14.40 
  But pdf_annot isn't defined in fitz. I tried adding this to wrap.c, but had a lot of compile errors. So I'm thinking I can't use it.16:15.18 
  #include "mupdf/pdf/document.h"16:15.19 
Robin_Watts_ Hi scott.16:16.02 
scottschafer Anyway…wondering what the best approach is here. Also if there's a generic way of dumping annotations into XML (or JSON preferably) or if I will need to handle each annotation type individually16:16.46 
ator scottschafer: #include "mupdf/pdf.h" should be enough to get all the public (and more) PDF functions and structs16:16.54 
Robin_Watts_ This is what scott was trying to paste: https://pastebin.com/mp9vSxTf16:17.06 
scottschafer ah, thanks Robin. So the limit is really small on IRC ;)16:17.49 
Robin_Watts_ Unless you put a delay between each line, yes :)16:18.17 
  So, what you have there is the correct way to enumerate pdf_annot's.16:18.37 
  We have no inbuilt function for converting a pdf_annot to json.16:18.54 
  You'd need to write that.16:18.57 
  I have no idea what fields/methods a pdf.js annotation annot would have in it.16:19.35 
scottschafer would pdf_new_stext_page_from_annot be of any help here?16:19.36 
ator scottschafer: that only extracts the text from an annot for "search and highlight" purposes. so no, not really, I think.16:20.08 
Robin_Watts_ That gets you a structure that contains text/chars/optionally-images from inside an annotation, so no, I don't think so.16:20.30 
  I'd imagine you need to populate annots with stuff like type, position, size.16:20.49 
  and maybe a 'render' function.16:20.58 
ator scottschafer: include/mupdf/pdf/annot.h has C accessors for the important/useful annotation properties16:21.12 
scottschafer ok, this was helpful. Switching to #include "mupdf/pdf.h" fixed the compile issues16:21.43 
ator the way our code works is using the pdf_annot object, you can query and set various properties, then call pdf_update_annot() and that will recreate the appearance from the new properties16:21.50 
  pdf_update_page() is a helper that updates all the annotations on a page and returns whether anything actually changed16:22.17 
scottschafer So basically, I'm going to need to call all the functions like "pdf_annot_color" etc on each annotation to get its properties?16:23.00 
ator scottschafer: yes... but note that not all annotations have all the same properties16:23.36 
scottschafer ok, that's what I was thinking. Just wanted to make sure I wasn't missing something obivious16:24.11 
ator pdf_annot_has_XXX should tell you if a given property is valid for the annotation type16:24.26 
scottschafer Cool, I saw that16:24.36 
  Alright, it's been a long time since I wrote C code, but once more into the breach16:25.17 
Robin_Watts_ scottschafer: Presumably you only need to copy the annotation information out that callers of annoation_layer.js expect to be there.16:25.33 
ator platform/gl/gl-annotate.c has a bunch of C code that exercises this (might be a bit much if your C is rusty, it's not the most obvious code given how much is going on with the UI etc)16:26.00 
scottschafer yeah, hard when making an API-compatible interface. Not sure how compatible this needs to be (in terms of returning the same results as pdf.js). Anyway, I will look at gl-annotate.c. Thanks!16:27.28 
  l8r16:27.37 
  oh, also…any tips on debugging the WASM build?16:38.45 
  the C code itself16:39.09 
Robin_Watts_ Do printf's work?16:39.30 
 <<<Back 1 day (to 2020/04/01)Forward 1 day (to 2020/04/03)>>> 
ghostscript.com #ghostscript
Search: