2

I need to use Mupdf insert some chinese text annotation. so I tested like this:

pdf_document *idoc;
struct fz_point_s sp = {200.0,200.0};
idoc = pdf_specifics(ctx, doc);
if (!idoc)
    return;

fz_try(ctx)
{
    float color[] = {0,0,0};
    pdf_annot *annot = pdf_create_annot(ctx, idoc, (pdf_page *)page, FZ_ANNOT_TEXT);
    pdf_set_free_text_details(ctx, idoc, annot, &sp,
                              "ABCDEF 中文注解" ,
                              "Helvetica",
                              24.0,
                              color);
   /*pdf_set_annot_contents(ctx, idoc, annot, c);*/
   pdf_update_annot(ctx, idoc, annot);
   pdf_update_text_annot_appearance(ctx, idoc, annot);
   pdf_update_free_text_annot_appearance(ctx, idoc, annot); 
}

After running the result is not correct: image here

here is the annotation function:

void pdf_set_free_text_details(fz_context *ctx, pdf_document *doc, pdf_annot *annot, fz_point *pos, char *text, char *font_name, float font_size, float color[3]);

so someone can help me with this?

  • this code is not working in my mupdf .c library. i have added it in mupdf.c after saving ink annotation for saving text. app is crashing – Ninad Kambli Aug 25 '16 at 11:35

1 Answers1

0

I know this answer is very late, but only just recently (in version 1.17.0, May 2020) MuPDF has added CJK support. Now you can do what you want. Also implemented in the Python bindings PyMuPDF for MuPDF.

Jorj McKie
  • 2,062
  • 1
  • 13
  • 17