mirror of
https://github.com/michaelrsweet/pdfio.git
synced 2024-12-27 05:48:20 +01:00
Merge branch 'master' into crypto
This commit is contained in:
commit
e2b33a6cbb
@ -7,6 +7,9 @@ v1.0.0 (TBD)
|
|||||||
|
|
||||||
- Added `pdfioFileCreateOutput` API to support streaming output of PDF
|
- Added `pdfioFileCreateOutput` API to support streaming output of PDF
|
||||||
(Issue #21)
|
(Issue #21)
|
||||||
|
- Fixed `all-shared` target (Issue #22)
|
||||||
|
- Fixed memory leaks (Issue #23)
|
||||||
|
- Updated `pdfioContentSetDashPattern` to accept `double` values (Issue #25)
|
||||||
- Fixed some issues identified by a Coverity scan.
|
- Fixed some issues identified by a Coverity scan.
|
||||||
|
|
||||||
|
|
||||||
|
9
Makefile
9
Makefile
@ -75,8 +75,8 @@ all: $(TARGETS)
|
|||||||
all-shared:
|
all-shared:
|
||||||
if test `uname` = Darwin; then \
|
if test `uname` = Darwin; then \
|
||||||
$(MAKE) DSONAME="libpdfio.1.dylib" -$(MAKEFLAGS) all; \
|
$(MAKE) DSONAME="libpdfio.1.dylib" -$(MAKEFLAGS) all; \
|
||||||
else
|
else \
|
||||||
$(MAKE) DSONAME="libpdfio.so.1" -$(MAKEFLAGS) all; \
|
$(MAKE) COMMONFLAGS="-g -Os -fPIC" DSONAME="libpdfio.so.1" -$(MAKEFLAGS) all; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
debug:
|
debug:
|
||||||
@ -124,6 +124,9 @@ install-shared:
|
|||||||
test: testpdfio
|
test: testpdfio
|
||||||
./testpdfio
|
./testpdfio
|
||||||
|
|
||||||
|
valgrind: testpdfio
|
||||||
|
valgrind --leak-check=full ./testpdfio
|
||||||
|
|
||||||
|
|
||||||
# pdfio library
|
# pdfio library
|
||||||
libpdfio.a: $(LIBOBJS)
|
libpdfio.a: $(LIBOBJS)
|
||||||
@ -131,7 +134,7 @@ libpdfio.a: $(LIBOBJS)
|
|||||||
$(RANLIB) $@
|
$(RANLIB) $@
|
||||||
|
|
||||||
libpdfio.so.1: $(LIBOBJS)
|
libpdfio.so.1: $(LIBOBJS)
|
||||||
$(CC) $(DSOFLAGS) $(COMMONFLAGS) -shared -o $@ -Wl,soname,$@ $(LIBOBJS) $(LIBS)
|
$(CC) $(DSOFLAGS) $(COMMONFLAGS) -shared -o $@ -Wl,-soname,$@ $(LIBOBJS) $(LIBS)
|
||||||
|
|
||||||
libpdfio.1.dylib: $(LIBOBJS)
|
libpdfio.1.dylib: $(LIBOBJS)
|
||||||
$(CC) $(DSOFLAGS) $(COMMONFLAGS) -dynamiclib -o $@ -install_name $(prefix)/lib/$@ -current_version $(VERSION) -compatibility_version 1.0 $(LIBOBJS) $(LIBS)
|
$(CC) $(DSOFLAGS) $(COMMONFLAGS) -dynamiclib -o $@ -install_name $(prefix)/lib/$@ -current_version $(VERSION) -compatibility_version 1.0 $(LIBOBJS) $(LIBS)
|
||||||
|
10
doc/pdfio.3
10
doc/pdfio.3
@ -1,4 +1,4 @@
|
|||||||
.TH pdfio 3 "pdf read/write library" "2021-09-27" "pdf read/write library"
|
.TH pdfio 3 "pdf read/write library" "2021-10-18" "pdf read/write library"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
pdfio \- pdf read/write library
|
pdfio \- pdf read/write library
|
||||||
.SH Introduction
|
.SH Introduction
|
||||||
@ -152,7 +152,7 @@ There is also an Xcode project ("pdfio.xcodeproj") you can use on macOS which ge
|
|||||||
You can reproduce this with the makefile using:
|
You can reproduce this with the makefile using:
|
||||||
.nf
|
.nf
|
||||||
|
|
||||||
sudo make 'COMMONFLAGS="\-Os \-mmacosx\-version\-min=10.14 \-arch x86_64 \-arch arm64"' install
|
sudo make COMMONFLAGS="\-Os \-mmacosx\-version\-min=10.14 \-arch x86_64 \-arch arm64" install
|
||||||
.fi
|
.fi
|
||||||
.SS Detecting PDFio
|
.SS Detecting PDFio
|
||||||
.PP
|
.PP
|
||||||
@ -1406,9 +1406,9 @@ Set the stroke pattern.
|
|||||||
.nf
|
.nf
|
||||||
bool pdfioContentSetDashPattern (
|
bool pdfioContentSetDashPattern (
|
||||||
pdfio_stream_t *st,
|
pdfio_stream_t *st,
|
||||||
int phase,
|
double phase,
|
||||||
int on,
|
double on,
|
||||||
int off
|
double off
|
||||||
);
|
);
|
||||||
.fi
|
.fi
|
||||||
.SS pdfioContentSetFillColorDeviceCMYK
|
.SS pdfioContentSetFillColorDeviceCMYK
|
||||||
|
@ -548,7 +548,7 @@ make install-shared
|
|||||||
<pre><code>sudo xcodebuild install
|
<pre><code>sudo xcodebuild install
|
||||||
</code></pre>
|
</code></pre>
|
||||||
<p>You can reproduce this with the makefile using:</p>
|
<p>You can reproduce this with the makefile using:</p>
|
||||||
<pre><code>sudo make 'COMMONFLAGS="-Os -mmacosx-version-min=10.14 -arch x86_64 -arch arm64"' install
|
<pre><code>sudo make COMMONFLAGS="-Os -mmacosx-version-min=10.14 -arch x86_64 -arch arm64" install
|
||||||
</code></pre>
|
</code></pre>
|
||||||
<h3 class="title" id="detecting-pdfio">Detecting PDFio</h3>
|
<h3 class="title" id="detecting-pdfio">Detecting PDFio</h3>
|
||||||
<p>PDFio can be detected using the <code>pkg-config</code> command, for example:</p>
|
<p>PDFio can be detected using the <code>pkg-config</code> command, for example:</p>
|
||||||
@ -1563,7 +1563,7 @@ bool pdfioContentSave(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st);</p>
|
|||||||
<h3 class="function"><a id="pdfioContentSetDashPattern">pdfioContentSetDashPattern</a></h3>
|
<h3 class="function"><a id="pdfioContentSetDashPattern">pdfioContentSetDashPattern</a></h3>
|
||||||
<p class="description">Set the stroke pattern.</p>
|
<p class="description">Set the stroke pattern.</p>
|
||||||
<p class="code">
|
<p class="code">
|
||||||
bool pdfioContentSetDashPattern(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, int phase, int on, int off);</p>
|
bool pdfioContentSetDashPattern(<a href="#pdfio_stream_t">pdfio_stream_t</a> *st, double phase, double on, double off);</p>
|
||||||
<h4 class="parameters">Parameters</h4>
|
<h4 class="parameters">Parameters</h4>
|
||||||
<table class="list"><tbody>
|
<table class="list"><tbody>
|
||||||
<tr><th>st</th>
|
<tr><th>st</th>
|
||||||
|
@ -357,6 +357,15 @@ _pdfioArrayDebug(pdfio_array_t *a, // I - Array
|
|||||||
void
|
void
|
||||||
_pdfioArrayDelete(pdfio_array_t *a) // I - Array
|
_pdfioArrayDelete(pdfio_array_t *a) // I - Array
|
||||||
{
|
{
|
||||||
|
size_t i; // Looping var
|
||||||
|
|
||||||
|
|
||||||
|
for (i = 0; i < a->num_values; i ++)
|
||||||
|
{
|
||||||
|
if (a->values[i].type == PDFIO_VALTYPE_BINARY)
|
||||||
|
free(a->values[i].value.binary.data);
|
||||||
|
}
|
||||||
|
|
||||||
if (a)
|
if (a)
|
||||||
free(a->values);
|
free(a->values);
|
||||||
|
|
||||||
|
@ -660,11 +660,11 @@ pdfioContentSave(pdfio_stream_t *st) // I - Stream
|
|||||||
bool // O - `true` on success, `false` on failure
|
bool // O - `true` on success, `false` on failure
|
||||||
pdfioContentSetDashPattern(
|
pdfioContentSetDashPattern(
|
||||||
pdfio_stream_t *st, // I - Stream
|
pdfio_stream_t *st, // I - Stream
|
||||||
int phase, // I - Phase (offset within pattern)
|
double phase, // I - Phase (offset within pattern)
|
||||||
int on, // I - On length
|
double on, // I - On length
|
||||||
int off) // I - Off length
|
double off) // I - Off length
|
||||||
{
|
{
|
||||||
return (pdfioStreamPrintf(st, "[%d %d] %d d\n", on, off, phase));
|
return (pdfioStreamPrintf(st, "[%g %g] %g d\n", on, off, phase));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ extern bool pdfioContentPathMoveTo(pdfio_stream_t *st, double x, double y) _PDF
|
|||||||
extern bool pdfioContentPathRect(pdfio_stream_t *st, double x, double y, double width, double height) _PDFIO_PUBLIC;
|
extern bool pdfioContentPathRect(pdfio_stream_t *st, double x, double y, double width, double height) _PDFIO_PUBLIC;
|
||||||
extern bool pdfioContentRestore(pdfio_stream_t *st) _PDFIO_PUBLIC;
|
extern bool pdfioContentRestore(pdfio_stream_t *st) _PDFIO_PUBLIC;
|
||||||
extern bool pdfioContentSave(pdfio_stream_t *st) _PDFIO_PUBLIC;
|
extern bool pdfioContentSave(pdfio_stream_t *st) _PDFIO_PUBLIC;
|
||||||
extern bool pdfioContentSetDashPattern(pdfio_stream_t *st, int phase, int on, int off) _PDFIO_PUBLIC;
|
extern bool pdfioContentSetDashPattern(pdfio_stream_t *st, double phase, double on, double off) _PDFIO_PUBLIC;
|
||||||
extern bool pdfioContentSetFillColorDeviceCMYK(pdfio_stream_t *st, double c, double m, double y, double k) _PDFIO_PUBLIC;
|
extern bool pdfioContentSetFillColorDeviceCMYK(pdfio_stream_t *st, double c, double m, double y, double k) _PDFIO_PUBLIC;
|
||||||
extern bool pdfioContentSetFillColorDeviceGray(pdfio_stream_t *st, double g) _PDFIO_PUBLIC;
|
extern bool pdfioContentSetFillColorDeviceGray(pdfio_stream_t *st, double g) _PDFIO_PUBLIC;
|
||||||
extern bool pdfioContentSetFillColorDeviceRGB(pdfio_stream_t *st, double r, double g, double b) _PDFIO_PUBLIC;
|
extern bool pdfioContentSetFillColorDeviceRGB(pdfio_stream_t *st, double r, double g, double b) _PDFIO_PUBLIC;
|
||||||
|
@ -114,6 +114,8 @@ pdfioStreamClose(pdfio_stream_t *st) // I - Stream
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deflateEnd(&st->flate);
|
||||||
}
|
}
|
||||||
else if (st->crypto_cb && st->bufptr > st->buffer)
|
else if (st->crypto_cb && st->bufptr > st->buffer)
|
||||||
{
|
{
|
||||||
|
26
testpdfio.c
26
testpdfio.c
@ -979,7 +979,7 @@ do_unit_tests(void)
|
|||||||
puts("\n");
|
puts("\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return (1);
|
goto fail;
|
||||||
|
|
||||||
// Test the value parsers for edge cases...
|
// Test the value parsers for edge cases...
|
||||||
fputs("_pdfioValueRead(cid_dict): ", stdout);
|
fputs("_pdfioValueRead(cid_dict): ", stdout);
|
||||||
@ -993,7 +993,7 @@ do_unit_tests(void)
|
|||||||
puts("\n");
|
puts("\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return (1);
|
goto fail;
|
||||||
|
|
||||||
// Do crypto tests...
|
// Do crypto tests...
|
||||||
if (do_crypto_tests())
|
if (do_crypto_tests())
|
||||||
@ -1004,34 +1004,36 @@ do_unit_tests(void)
|
|||||||
if ((outpdf = pdfioFileCreate("testpdfio-out.pdf", NULL, NULL, NULL, (pdfio_error_cb_t)error_cb, &error)) != NULL)
|
if ((outpdf = pdfioFileCreate("testpdfio-out.pdf", NULL, NULL, NULL, (pdfio_error_cb_t)error_cb, &error)) != NULL)
|
||||||
puts("PASS");
|
puts("PASS");
|
||||||
else
|
else
|
||||||
return (1);
|
goto fail;
|
||||||
|
|
||||||
if (write_unit_file(inpdf, outpdf, &num_pages, &first_image))
|
if (write_unit_file(inpdf, outpdf, &num_pages, &first_image))
|
||||||
return (1);
|
goto fail;
|
||||||
|
|
||||||
if (read_unit_file("testpdfio-out.pdf", num_pages, first_image, false))
|
if (read_unit_file("testpdfio-out.pdf", num_pages, first_image, false))
|
||||||
return (1);
|
goto fail;
|
||||||
|
|
||||||
// Stream a new PDF file...
|
// Stream a new PDF file...
|
||||||
if ((outfd = open("testpdfio-out2.pdf", O_CREAT | O_TRUNC | O_WRONLY | O_BINARY, 0666)) < 0)
|
if ((outfd = open("testpdfio-out2.pdf", O_CREAT | O_TRUNC | O_WRONLY | O_BINARY, 0666)) < 0)
|
||||||
{
|
{
|
||||||
perror("Unable to open \"testpdfio-out2.pdf\"");
|
perror("Unable to open \"testpdfio-out2.pdf\"");
|
||||||
return (1);
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
fputs("pdfioFileCreateOutput(...): ", stdout);
|
fputs("pdfioFileCreateOutput(...): ", stdout);
|
||||||
if ((outpdf = pdfioFileCreateOutput((pdfio_output_cb_t)output_cb, &outfd, NULL, NULL, NULL, (pdfio_error_cb_t)error_cb, &error)) != NULL)
|
if ((outpdf = pdfioFileCreateOutput((pdfio_output_cb_t)output_cb, &outfd, NULL, NULL, NULL, (pdfio_error_cb_t)error_cb, &error)) != NULL)
|
||||||
puts("PASS");
|
puts("PASS");
|
||||||
else
|
else
|
||||||
return (1);
|
goto fail;
|
||||||
|
|
||||||
if (write_unit_file(inpdf, outpdf, &num_pages, &first_image))
|
if (write_unit_file(inpdf, outpdf, &num_pages, &first_image))
|
||||||
return (1);
|
goto fail;
|
||||||
|
|
||||||
close(outfd);
|
close(outfd);
|
||||||
|
|
||||||
if (read_unit_file("testpdfio-out2.pdf", num_pages, first_image, true))
|
if (read_unit_file("testpdfio-out2.pdf", num_pages, first_image, true))
|
||||||
return (1);
|
goto fail;
|
||||||
|
|
||||||
|
pdfioFileClose(inpdf);
|
||||||
|
|
||||||
// Create new encrypted PDF files...
|
// Create new encrypted PDF files...
|
||||||
fputs("pdfioFileCreate(\"testpdfio-rc4.pdf\", ...): ", stdout);
|
fputs("pdfioFileCreate(\"testpdfio-rc4.pdf\", ...): ", stdout);
|
||||||
@ -1108,6 +1110,12 @@ do_unit_tests(void)
|
|||||||
return (1);
|
return (1);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
|
fail:
|
||||||
|
|
||||||
|
pdfioFileClose(inpdf);
|
||||||
|
|
||||||
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user