Reflect Python object in the PDF.
(self, sync_flags=False)
| 9305 | TOOLS._reset_widget(self._annot) |
| 9306 | |
| 9307 | def update(self, sync_flags=False): |
| 9308 | """Reflect Python object in the PDF.""" |
| 9309 | self._validate() |
| 9310 | |
| 9311 | self._adjust_font() # ensure valid text_font name |
| 9312 | |
| 9313 | # now create the /DA string |
| 9314 | self._text_da = "" |
| 9315 | if len(self.text_color) == 3: |
| 9316 | fmt = "{:g} {:g} {:g} rg /{f:s} {s:g} Tf" + self._text_da |
| 9317 | elif len(self.text_color) == 1: |
| 9318 | fmt = "{:g} g /{f:s} {s:g} Tf" + self._text_da |
| 9319 | elif len(self.text_color) == 4: |
| 9320 | fmt = "{:g} {:g} {:g} {:g} k /{f:s} {s:g} Tf" + self._text_da |
| 9321 | self._text_da = fmt.format(*self.text_color, f=self.text_font, |
| 9322 | s=self.text_fontsize) |
| 9323 | # finally update the widget |
| 9324 | |
| 9325 | # if widget has a '/AA/C' script, make sure it is in the '/CO' |
| 9326 | # array of the '/AcroForm' dictionary. |
| 9327 | if self.script_calc: # there is a "calculation" script: |
| 9328 | # make sure we are in the /CO array |
| 9329 | util_ensure_widget_calc(self._annot) |
| 9330 | |
| 9331 | # finally update the widget |
| 9332 | TOOLS._save_widget(self._annot, self) |
| 9333 | self._text_da = "" |
| 9334 | if sync_flags: |
| 9335 | self._sync_flags() # propagate field flags to parent and kids |
| 9336 | |
| 9337 | |
| 9338 | from . import _extra |