<dt>PDFAnnotation#getColor(), #setColor(color)
<dt>PDFAnnotation#getQuadPoints(), #setQuadPoints(quadPoints)
<dt>PDFAnnotation#getInkList(), #setInkList(inkList)
-<dt>PDFAnnotation#updateAppearance()
+<dt>PDFAnnotation#update()
<dd>Update the appearance stream to account for changes in the annotation.
</dl>
Recreate the appearance stream for an annotation, if necessary.
*/
fz_text *pdf_layout_fit_text(fz_context *ctx, fz_font *font, fz_text_language lang, const char *str, fz_rect bounds);
-void pdf_update_appearance(fz_context *ctx, pdf_annot *annot);
/*
Start/Stop using the annotation-local xref. This allows us to
Returns true if the annotation appearance has changed since the last time
pdf_update_annot was called or the annotation was first loaded.
+
+ Note that if you update an annotation and it causes a change (due to the
+ appearance stream being updated), that may invalidate the appearance stream
+ for other (earlier) annotations (specifically for those that have a
+ 'local' appearance stream that has not been written back to the document
+ proper - such as unsigned signature fields). In order to work properly
+ therefore, if you get informed of a change to an annotation, you should
+ "reupdate" the previous annotations in a list. In practice it's probably
+ simplest to completely run the loop over the annotations and reupdate a
+ second time.
+
+ This may seem like it might go into an infinite loop of needing to update
+ multiple times, but in practice at worst every annotation needs to be
+ updated twice. The second pass through calling pdf_update_annot may have
+ calls returning true, but a third pass through would never have any calls
+ return true.
*/
int pdf_update_annot(fz_context *ctx, pdf_annot *annot);
jni_rethrow_void(env, ctx);
}
-JNIEXPORT void JNICALL
-FUN(PDFAnnotation_updateAppearance)(JNIEnv *env, jobject self)
-{
- fz_context *ctx = get_context(env);
- pdf_annot *annot = from_PDFAnnotation(env, self);
-
- if (!ctx || !annot) return;
-
- fz_try(ctx)
- pdf_update_appearance(ctx, annot);
- fz_catch(ctx)
- jni_rethrow_void(env, ctx);
-}
-
JNIEXPORT jobject JNICALL
FUN(PDFAnnotation_getDefaultAppearance)(JNIEnv *env, jobject self)
{
JNIEXPORT void JNICALL Java_com_artifex_mupdf_fitz_PDFAnnotation_eventBlur
(JNIEnv *, jobject);
-/*
- * Class: com_artifex_mupdf_fitz_PDFAnnotation
- * Method: updateAppearance
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_com_artifex_mupdf_fitz_PDFAnnotation_updateAppearance
- (JNIEnv *, jobject);
-
/*
* Class: com_artifex_mupdf_fitz_PDFAnnotation
* Method: update
public native void eventFocus();
public native void eventBlur();
- public native void updateAppearance();
public native boolean update();
public native PDFObject getObject();
doc->local_xref = NULL;
}
-void pdf_update_appearance(fz_context *ctx, pdf_annot *annot)
+static void pdf_update_appearance(fz_context *ctx, pdf_annot *annot)
{
pdf_obj *subtype;
pdf_obj *ft = NULL;
for (widget = page->widgets; widget; widget = widget->next)
if (pdf_update_annot(ctx, widget))
changed = 1;
+ if (changed)
+ {
+ for (annot = page->annots; annot; annot = annot->next)
+ pdf_update_annot(ctx, annot);
+ for (widget = page->widgets; widget; widget = widget->next)
+ pdf_update_annot(ctx, widget);
+ /* These pdf_update_annots may return true (but only if they
+ * did the first time, and a third run through will never
+ * get any changes. */
+ }
}
fz_always(ctx)
{
js_throw(J);
}
-static void ffi_PDFAnnotation_updateAppearance(js_State *J)
-{
- fz_context *ctx = js_getcontext(J);
- pdf_annot *annot = js_touserdata(J, 0, "pdf_annot");
- fz_try(ctx)
- pdf_update_appearance(ctx, annot);
- fz_catch(ctx)
- rethrow(J);
-}
-
static void ffi_PDFAnnotation_update(js_State *J)
{
fz_context *ctx = js_getcontext(J);
jsB_propfun(J, "PDFAnnotation.clearVertices", ffi_PDFAnnotation_clearVertices, 0);
jsB_propfun(J, "PDFAnnotation.addVertex", ffi_PDFAnnotation_addVertex, 2);
- jsB_propfun(J, "PDFAnnotation.updateAppearance", ffi_PDFAnnotation_updateAppearance, 0);
jsB_propfun(J, "PDFAnnotation.update", ffi_PDFAnnotation_update, 0);
jsB_propfun(J, "PDFAnnotation.getHot", ffi_PDFAnnotation_getHot, 0);