Skip to content

Commit 5bf158c

Browse files
committed
Fixing #176
1 parent ee19160 commit 5bf158c

File tree

10 files changed

+105
-13
lines changed

10 files changed

+105
-13
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# PyMuPDF 1.13.8 [![Build Status](https://travis-ci.org/rk700/PyMuPDF.svg?branch=master)](https://travis-ci.org/rk700/PyMuPDF)
1+
# PyMuPDF 1.13.9 [![Build Status](https://travis-ci.org/rk700/PyMuPDF.svg?branch=master)](https://travis-ci.org/rk700/PyMuPDF)
22

33
![logo](https://github.com/rk700/PyMuPDF/blob/master/demo/pymupdf.jpg)
44

@@ -10,7 +10,7 @@ Release date: June 7, 2018
1010

1111
# Introduction
1212

13-
This is **version 1.13.8 of PyMuPDF (formerly python-fitz)**, a Python binding with support for [MuPDF 1.13.0](http://mupdf.com/) - "a lightweight PDF and XPS viewer".
13+
This is **version 1.13.9 of PyMuPDF (formerly python-fitz)**, a Python binding with support for [MuPDF 1.13.0](http://mupdf.com/) - "a lightweight PDF and XPS viewer".
1414

1515
MuPDF can access files in PDF, XPS, OpenXPS, CBZ, EPUB and FB2 (e-books) formats, and it is known for its top performance and high rendering quality.
1616

doc/PyMuPDF.pdf

-2.97 KB
Binary file not shown.

doc/html.zip

-229 Bytes
Binary file not shown.

fitz/fitz.i

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,7 @@ struct fz_document_s
711711
if ((incremental) && (fz_needs_password(gctx, $self)))
712712
THROWMSG("decrypted file - save to new");
713713
pdf_finish_edit(gctx, pdf);
714+
JM_embedded_clean(gctx, pdf);
714715
pdf_save_document(gctx, pdf, filename, &opts);
715716
pdf->dirty = 0;
716717
}
@@ -757,6 +758,7 @@ struct fz_document_s
757758
if (fz_count_pages(gctx, $self) < 1)
758759
THROWMSG("document has zero pages");
759760
pdf_finish_edit(gctx, pdf);
761+
JM_embedded_clean(gctx, pdf);
760762
res = fz_new_buffer(gctx, 1024);
761763
out = fz_new_output_with_buffer(gctx, res);
762764
pdf_write_document(gctx, pdf, out, &opts);

fitz/fitz.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ class _object:
102102

103103

104104
VersionFitz = "1.13.0"
105-
VersionBind = "1.13.8"
106-
VersionDate = "2018-06-07 17:10:40"
107-
version = (VersionBind, VersionFitz, "20180607171040")
105+
VersionBind = "1.13.9"
106+
VersionDate = "2018-06-09 15:14:41"
107+
version = (VersionBind, VersionFitz, "20180609151441")
108108

109109

110110
#------------------------------------------------------------------------------

fitz/fitz_wrap.c

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3150,7 +3150,28 @@ void refresh_link_table(fz_context *ctx, pdf_page *page)
31503150
#define ANNOT_LE_Slash 9
31513151

31523152
//----------------------------------------------------------------------------
3153-
// return character string for line end style
3153+
// annotation field (widget) types
3154+
//----------------------------------------------------------------------------
3155+
#define ANNOT_WG_NOT_WIDGET -1
3156+
#define ANNOT_WG_PUSHBUTTON 0
3157+
#define ANNOT_WG_CHECKBOX 1
3158+
#define ANNOT_WG_RADIOBUTTON 2
3159+
#define ANNOT_WG_TEXT 3
3160+
#define ANNOT_WG_LISTBOX 4
3161+
#define ANNOT_WG_COMBOBOX 5
3162+
#define ANNOT_WG_SIGNATURE 6
3163+
3164+
//----------------------------------------------------------------------------
3165+
// annotation text widget subtypes
3166+
//----------------------------------------------------------------------------
3167+
#define ANNOT_WG_TEXT_UNRESTRAINED 0
3168+
#define ANNOT_WG_TEXT_NUMBER 1
3169+
#define ANNOT_WG_TEXT_SPECIAL 2
3170+
#define ANNOT_WG_TEXT_DATE 3
3171+
#define ANNOT_WG_TEXT_TIME 4
3172+
3173+
//----------------------------------------------------------------------------
3174+
// return string for line end style
31543175
//----------------------------------------------------------------------------
31553176
char *annot_le_style_str(int type)
31563177
{
@@ -3171,7 +3192,7 @@ char *annot_le_style_str(int type)
31713192
}
31723193

31733194
//----------------------------------------------------------------------------
3174-
// return character name of annotation type
3195+
// return string name of annotation type
31753196
//----------------------------------------------------------------------------
31763197
char *annot_type_str(int type)
31773198
{
@@ -4265,6 +4286,29 @@ int JM_FindEmbedded(fz_context *ctx, PyObject *id, pdf_document *pdf)
42654286
return i;
42664287
}
42674288

4289+
//-----------------------------------------------------------------------------
4290+
// perform some cleaning if we have embeddedfiles
4291+
//-----------------------------------------------------------------------------
4292+
void JM_embedded_clean(fz_context *ctx, pdf_document *pdf)
4293+
{
4294+
pdf_obj *root = pdf_dict_get(ctx, pdf_trailer(ctx, pdf), PDF_NAME_Root);
4295+
pdf_obj *efiles = pdf_dict_getl(ctx, root, PDF_NAME_Names,
4296+
PDF_NAME_EmbeddedFiles, NULL);
4297+
if (efiles) // we have embedded files
4298+
{ // make sure they are displayed
4299+
pdf_dict_put_name(ctx, root, PDF_NAME_PageMode, "UseAttachments");
4300+
// remove the limits entry: seems to be a MuPDF bug
4301+
pdf_dict_del(ctx, efiles, PDF_NAME_Limits);
4302+
}
4303+
4304+
// also remove an empty /Collection entry
4305+
pdf_obj *coll = pdf_dict_get(ctx, root, PDF_NAME_Collection);
4306+
if (coll && pdf_dict_len(ctx, coll) == 0)
4307+
pdf_dict_del(ctx, root, PDF_NAME_Collection);
4308+
return;
4309+
4310+
}
4311+
42684312

42694313
//----------------------------------------------------------------------------
42704314
// Helpers for document page selection - main logic was imported
@@ -5795,6 +5839,7 @@ SWIGINTERN PyObject *fz_document_s_save(struct fz_document_s *self,char *filenam
57955839
if ((incremental) && (fz_needs_password(gctx, self)))
57965840
THROWMSG("decrypted file - save to new");
57975841
pdf_finish_edit(gctx, pdf);
5842+
JM_embedded_clean(gctx, pdf);
57985843
pdf_save_document(gctx, pdf, filename, &opts);
57995844
pdf->dirty = 0;
58005845
}
@@ -5829,6 +5874,7 @@ SWIGINTERN PyObject *fz_document_s_write(struct fz_document_s *self,int garbage,
58295874
if (fz_count_pages(gctx, self) < 1)
58305875
THROWMSG("document has zero pages");
58315876
pdf_finish_edit(gctx, pdf);
5877+
JM_embedded_clean(gctx, pdf);
58325878
res = fz_new_buffer(gctx, 1024);
58335879
out = fz_new_output_with_buffer(gctx, res);
58345880
pdf_write_document(gctx, pdf, out, &opts);

fitz/helper-annot.i

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,28 @@ void refresh_link_table(fz_context *ctx, pdf_page *page)
7575
#define ANNOT_LE_Slash 9
7676

7777
//----------------------------------------------------------------------------
78-
// return character string for line end style
78+
// annotation field (widget) types
79+
//----------------------------------------------------------------------------
80+
#define ANNOT_WG_NOT_WIDGET -1
81+
#define ANNOT_WG_PUSHBUTTON 0
82+
#define ANNOT_WG_CHECKBOX 1
83+
#define ANNOT_WG_RADIOBUTTON 2
84+
#define ANNOT_WG_TEXT 3
85+
#define ANNOT_WG_LISTBOX 4
86+
#define ANNOT_WG_COMBOBOX 5
87+
#define ANNOT_WG_SIGNATURE 6
88+
89+
//----------------------------------------------------------------------------
90+
// annotation text widget subtypes
91+
//----------------------------------------------------------------------------
92+
#define ANNOT_WG_TEXT_UNRESTRAINED 0
93+
#define ANNOT_WG_TEXT_NUMBER 1
94+
#define ANNOT_WG_TEXT_SPECIAL 2
95+
#define ANNOT_WG_TEXT_DATE 3
96+
#define ANNOT_WG_TEXT_TIME 4
97+
98+
//----------------------------------------------------------------------------
99+
// return string for line end style
79100
//----------------------------------------------------------------------------
80101
char *annot_le_style_str(int type)
81102
{
@@ -96,7 +117,7 @@ char *annot_le_style_str(int type)
96117
}
97118

98119
//----------------------------------------------------------------------------
99-
// return character name of annotation type
120+
// return string name of annotation type
100121
//----------------------------------------------------------------------------
101122
char *annot_type_str(int type)
102123
{

fitz/helper-portfolio.i

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,27 @@ int JM_FindEmbedded(fz_context *ctx, PyObject *id, pdf_document *pdf)
4545
JM_Python_str_DelForPy3(name);
4646
return i;
4747
}
48+
49+
//-----------------------------------------------------------------------------
50+
// perform some cleaning if we have embeddedfiles
51+
//-----------------------------------------------------------------------------
52+
void JM_embedded_clean(fz_context *ctx, pdf_document *pdf)
53+
{
54+
pdf_obj *root = pdf_dict_get(ctx, pdf_trailer(ctx, pdf), PDF_NAME_Root);
55+
pdf_obj *efiles = pdf_dict_getl(ctx, root, PDF_NAME_Names,
56+
PDF_NAME_EmbeddedFiles, NULL);
57+
if (efiles) // we have embedded files
58+
{ // make sure they are displayed
59+
pdf_dict_put_name(ctx, root, PDF_NAME_PageMode, "UseAttachments");
60+
// remove the limits entry: seems to be a MuPDF bug
61+
pdf_dict_del(ctx, efiles, PDF_NAME_Limits);
62+
}
63+
64+
// also remove an empty /Collection entry
65+
pdf_obj *coll = pdf_dict_get(ctx, root, PDF_NAME_Collection);
66+
if (coll && pdf_dict_len(ctx, coll) == 0)
67+
pdf_dict_del(ctx, root, PDF_NAME_Collection);
68+
return;
69+
70+
}
4871
%}

fitz/version.i

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
%pythoncode %{
22
VersionFitz = "1.13.0"
3-
VersionBind = "1.13.8"
4-
VersionDate = "2018-06-07 17:10:40"
5-
version = (VersionBind, VersionFitz, "20180607171040")
3+
VersionBind = "1.13.9"
4+
VersionDate = "2018-06-09 15:14:41"
5+
version = (VersionBind, VersionFitz, "20180609151441")
66
%}

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
sources=['./fitz/fitz_wrap.c',])
5151

5252
setup(name = 'PyMuPDF',
53-
version = "1.13.8",
53+
version = "1.13.9",
5454
description = 'Python bindings for the PDF rendering library MuPDF',
5555
classifiers = ['Development Status :: 5 - Production/Stable',
5656
'Environment :: Console',

0 commit comments

Comments
 (0)