Skip to content

Commit 0bd50c3

Browse files
committed
upload v1.18.4
1 parent d8fab0b commit 0bd50c3

File tree

5 files changed

+22
-18
lines changed

5 files changed

+22
-18
lines changed

docs/annot.rst

+1-2
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,7 @@ There is a parent-child relationship between an annotation and its page. If the
315315
:arg sequence,float text_color: change the text color. 'FreeText' annotations only.
316316
:arg sequence,float border_color: change the border color. 'FreeText' annotations only.
317317
:arg sequence,float fill_color: the fill color.
318-
319-
* 'FreeText' annotations: If you set (or leave) this to *None*, then **no rectangle at all** will be drawn around the text, and the border color will be ignored. This will leave anything "under" the text visible.
318+
320319
* 'Line', 'Polyline', 'Polygon' annotations: use it to give applicable line end symbols a fill color other than that of the annotation *(changed in v1.16.16)*.
321320

322321
:arg bool cross_out: *(new in v1.17.2)* add two diagonal lines to the annotation rectangle. 'Redact' annotations only. If not desired, *False* must be specified even if the annotation was created with *False*.

docs/changes.rst

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ Changes in Version 1.18.4
55
---------------------------
66
This version adds several features to support PDF Optional Content. Among other things, this includes OCMDs (Optional Content Membership Dictionaries) with the full scope of *"visibility expressions"* (PDF key ``/VE``), text insertions (including the :ref:`TextWriter` class) and drawings.
77

8+
* **Fixed** issue `#727 <https://github.com/pymupdf/PyMuPDF/issues/727>`_. Freetext annotations now support an uncolored rectangle when ``fill_color=None``.
9+
* **Fixed** issue `#726 <https://github.com/pymupdf/PyMuPDF/issues/726>`_. UTF-8 encoding errors are now handled for HTML / XML :meth:`Page.getText` output.
810
* **Fixed** issue `#724 <https://github.com/pymupdf/PyMuPDF/issues/724>`_. Empty values are no longer stored in the PDF /Info metadata dictionary.
911
* **Added** new methods :meth:`Document.set_oc` and :meth:`Document.get_oc` to set or get optional content references for **existing** image and form XObjects. These methods are similar to the same-named methods of :ref:`Annot`.
1012
* **Added** :meth:`Document.set_ocmd`, :meth:`Document.get_ocmd` for handling OCMDs.
@@ -25,7 +27,7 @@ As a major new feature, this version introduces support for PDF's **Optional Con
2527

2628
* **Fixed** issue `#714 <https://github.com/pymupdf/PyMuPDF/issues/714>`_.
2729
* **Fixed** issue `#711 <https://github.com/pymupdf/PyMuPDF/issues/711>`_.
28-
* **Fixed** issue `#707 <https://github.com/pymupdf/PyMuPDF/issues/707>`_: if a PDF user password is supplied but no owner password is supplied nor present, then the user password is also used as the owner password.
30+
* **Fixed** issue `#707 <https://github.com/pymupdf/PyMuPDF/issues/707>`_: if a PDF user password, but no owner password is supplied nor present, then the user password is also used as the owner password.
2931
* **Fixed** ``expand`` and ``deflate`` parameters of methods :meth:`Document.save` and :meth:`Document.write`. Individual image and font compression should now finally work. Addresses issue `#713 <https://github.com/pymupdf/PyMuPDF/issues/713>`_.
3032
* **Added** a support of PDF optional content. This includes several new :ref:`Document` methods for inquiring and setting optional content status and adding optional content configurations and groups. In addition, images, form XObjects and annotations now can be bound to optional content specifications. **Resolved** issue `#709 <https://github.com/pymupdf/PyMuPDF/issues/709>`_.
3133

fitz/fitz.i

+15-12
Original file line numberDiff line numberDiff line change
@@ -7609,7 +7609,6 @@ struct Annot
76097609
}
76107610
return Py_BuildValue("i", oc);
76117611
}
7612-
%pythoncode %{optional_content = property(getOC, doc="optional content xref")%}
76137612
76147613
76157614
//----------------------------------------------------------------
@@ -7751,7 +7750,7 @@ struct Annot
77517750
FITZEXCEPTION(set_oc, !result)
77527751
PARENTCHECK(set_oc, """Set annotation optional content xref.""")
77537752
PyObject *
7754-
set_optional_content(int oc=0)
7753+
set_oc(int oc=0)
77557754
{
77567755
fz_try(gctx) {
77577756
pdf_annot *annot = (pdf_annot *) $self;
@@ -8125,8 +8124,13 @@ struct Annot
81258124
JM_color_FromSequence(fill_color, &nfcol, fcol);
81268125
fz_try(gctx) {
81278126
pdf_dirty_annot(gctx, annot); // enforce MuPDF /AP formatting
8128-
if (type == PDF_ANNOT_FREE_TEXT && EXISTS(fill_color))
8129-
pdf_set_annot_color(gctx, annot, nfcol, fcol);
8127+
if (type == PDF_ANNOT_FREE_TEXT) {
8128+
if (EXISTS(fill_color)) {
8129+
pdf_set_annot_color(gctx, annot, nfcol, fcol);
8130+
} else{
8131+
pdf_dict_del(gctx, annot->obj, PDF_NAME(IC));
8132+
}
8133+
}
81308134
81318135
int insert_rot = (rotate >= 0) ? 1 : 0;
81328136
switch (type) {
@@ -8369,15 +8373,17 @@ struct Annot
83698373
TOOLS._update_da(self, da_str)
83708374
83718375
for i, item in enumerate(ap_tab):
8372-
if (item.endswith(b" w")
8373-
and bwidth > 0
8374-
and border_color is not None
8375-
): # update border color
8376+
if (
8377+
item.endswith(b" w") and bwidth > 0 and border_color is not None
8378+
): # update border color
83768379
ap_tab[i + 1] = color_string(border_color, "s")
83778380
continue
83788381
if item == b"BT": # update text color
83798382
ap_tab[i + 1] = color_string(tcol, "f")
83808383
continue
8384+
if fill is None:
8385+
if item.endswith((b" re")) and ap_tab[i + 1] == b"f":
8386+
ap_tab[i + 1] = b"n"
83818387
83828388
if dashes is not None: # handle dashes
83838389
ap_tab.insert(0, dashes)
@@ -9744,21 +9750,18 @@ struct TextPage {
97449750
fz_stext_page *this_tpage = (fz_stext_page *) $self;
97459751
fz_try(gctx) {
97469752
res = fz_new_buffer(gctx, 1024);
9753+
out = fz_new_output_with_buffer(gctx, res);
97479754
switch(format) {
97489755
case(1):
9749-
out = fz_new_output_with_buffer(gctx, res);
97509756
fz_print_stext_page_as_html(gctx, out, this_tpage, 0);
97519757
break;
97529758
case(3):
9753-
out = fz_new_output_with_buffer(gctx, res);
97549759
fz_print_stext_page_as_xml(gctx, out, this_tpage, 0);
97559760
break;
97569761
case(4):
9757-
out = fz_new_output_with_buffer(gctx, res);
97589762
fz_print_stext_page_as_xhtml(gctx, out, this_tpage, 0);
97599763
break;
97609764
default:
9761-
out = fz_new_output_with_buffer(gctx, res);
97629765
JM_print_stext_page_as_text(gctx, out, this_tpage);
97639766
break;
97649767
}

fitz/helper-other.i

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ PyObject *JM_EscapeStrFromBuffer(fz_context *ctx, fz_buffer *buff)
4141
PyObject *JM_UnicodeFromBuffer(fz_context *ctx, fz_buffer *buff)
4242
{
4343
unsigned char *s = NULL;
44-
size_t len = fz_buffer_storage(ctx, buff, &s);
45-
PyObject *val = PyUnicode_FromStringAndSize((const char *) s, (Py_ssize_t) len);
44+
Py_ssize_t len = (Py_ssize_t) fz_buffer_storage(ctx, buff, &s);
45+
PyObject *val = PyUnicode_DecodeUTF8((const char *) s, len, "replace");
4646
if (!val) {
4747
val = EMPTY_STRING;
4848
PyErr_Clear();

fitz/helper-stext.i

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fz_stext_page *JM_new_stext_page_from_page(fz_context *ctx, fz_page *page, fz_re
1414
fz_try(ctx) {
1515
tp = fz_new_stext_page(ctx, rect);
1616
dev = fz_new_stext_device(ctx, tp, &options);
17-
fz_run_page_contents(ctx, page, dev, fz_identity, NULL);
17+
fz_run_page(ctx, page, dev, fz_identity, NULL);
1818
fz_close_device(ctx, dev);
1919
}
2020
fz_always(ctx) {

0 commit comments

Comments
 (0)