mirror of
https://github.com/michaelrsweet/pdfio.git
synced 2024-11-08 06:28:27 +01:00
Merge branch 'master' into crypto
This commit is contained in:
commit
e2b33a6cbb
@ -7,10 +7,13 @@ v1.0.0 (TBD)
|
||||
|
||||
- Added `pdfioFileCreateOutput` API to support streaming output of PDF
|
||||
(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.
|
||||
|
||||
|
||||
v1.0b1 (August 30, 2021)
|
||||
------------------------
|
||||
|
||||
- Initial release
|
||||
- Initial release
|
||||
|
9
Makefile
9
Makefile
@ -75,8 +75,8 @@ all: $(TARGETS)
|
||||
all-shared:
|
||||
if test `uname` = Darwin; then \
|
||||
$(MAKE) DSONAME="libpdfio.1.dylib" -$(MAKEFLAGS) all; \
|
||||
else
|
||||
$(MAKE) DSONAME="libpdfio.so.1" -$(MAKEFLAGS) all; \
|
||||
else \
|
||||
$(MAKE) COMMONFLAGS="-g -Os -fPIC" DSONAME="libpdfio.so.1" -$(MAKEFLAGS) all; \
|
||||
fi
|
||||
|
||||
debug:
|
||||
@ -124,6 +124,9 @@ install-shared:
|
||||
test: testpdfio
|
||||
./testpdfio
|
||||
|
||||
valgrind: testpdfio
|
||||
valgrind --leak-check=full ./testpdfio
|
||||
|
||||
|
||||
# pdfio library
|
||||
libpdfio.a: $(LIBOBJS)
|
||||
@ -131,7 +134,7 @@ libpdfio.a: $(LIBOBJS)
|
||||
$(RANLIB) $@
|
||||
|
||||
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)
|
||||
$(CC) $(DSOFLAGS) $(COMMONFLAGS) -dynamiclib -o $@ -install_name $(prefix)/lib/$@ -current_version $(VERSION) -compatibility_version 1.0 $(LIBOBJS) $(LIBS)
|
||||
|
12
doc/pdfio.3
12
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
|
||||
pdfio \- pdf read/write library
|
||||
.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:
|
||||
.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
|
||||
.SS Detecting PDFio
|
||||
.PP
|
||||
@ -160,7 +160,7 @@ PDFio can be detected using the pkg\-config command, for example:
|
||||
.nf
|
||||
|
||||
if pkg\-config \-\-exists pdfio; then
|
||||
...
|
||||
...
|
||||
fi
|
||||
.fi
|
||||
.PP
|
||||
@ -1406,9 +1406,9 @@ Set the stroke pattern.
|
||||
.nf
|
||||
bool pdfioContentSetDashPattern (
|
||||
pdfio_stream_t *st,
|
||||
int phase,
|
||||
int on,
|
||||
int off
|
||||
double phase,
|
||||
double on,
|
||||
double off
|
||||
);
|
||||
.fi
|
||||
.SS pdfioContentSetFillColorDeviceCMYK
|
||||
|
@ -548,12 +548,12 @@ make install-shared
|
||||
<pre><code>sudo xcodebuild install
|
||||
</code></pre>
|
||||
<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>
|
||||
<h3 class="title" id="detecting-pdfio">Detecting PDFio</h3>
|
||||
<p>PDFio can be detected using the <code>pkg-config</code> command, for example:</p>
|
||||
<pre><code>if pkg-config --exists pdfio; then
|
||||
...
|
||||
...
|
||||
fi
|
||||
</code></pre>
|
||||
<p>In a makefile you can add the necessary compiler and linker options with:</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>
|
||||
<p class="description">Set the stroke pattern.</p>
|
||||
<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>
|
||||
<table class="list"><tbody>
|
||||
<tr><th>st</th>
|
||||
|
@ -357,6 +357,15 @@ _pdfioArrayDebug(pdfio_array_t *a, // I - Array
|
||||
void
|
||||
_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)
|
||||
free(a->values);
|
||||
|
||||
|
@ -660,11 +660,11 @@ pdfioContentSave(pdfio_stream_t *st) // I - Stream
|
||||
bool // O - `true` on success, `false` on failure
|
||||
pdfioContentSetDashPattern(
|
||||
pdfio_stream_t *st, // I - Stream
|
||||
int phase, // I - Phase (offset within pattern)
|
||||
int on, // I - On length
|
||||
int off) // I - Off length
|
||||
double phase, // I - Phase (offset within pattern)
|
||||
double on, // I - On 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 pdfioContentRestore(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 pdfioContentSetFillColorDeviceGray(pdfio_stream_t *st, double g) _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;
|
||||
}
|
||||
}
|
||||
|
||||
deflateEnd(&st->flate);
|
||||
}
|
||||
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");
|
||||
}
|
||||
else
|
||||
return (1);
|
||||
goto fail;
|
||||
|
||||
// Test the value parsers for edge cases...
|
||||
fputs("_pdfioValueRead(cid_dict): ", stdout);
|
||||
@ -993,7 +993,7 @@ do_unit_tests(void)
|
||||
puts("\n");
|
||||
}
|
||||
else
|
||||
return (1);
|
||||
goto fail;
|
||||
|
||||
// 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)
|
||||
puts("PASS");
|
||||
else
|
||||
return (1);
|
||||
goto fail;
|
||||
|
||||
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))
|
||||
return (1);
|
||||
goto fail;
|
||||
|
||||
// Stream a new PDF file...
|
||||
if ((outfd = open("testpdfio-out2.pdf", O_CREAT | O_TRUNC | O_WRONLY | O_BINARY, 0666)) < 0)
|
||||
{
|
||||
perror("Unable to open \"testpdfio-out2.pdf\"");
|
||||
return (1);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
fputs("pdfioFileCreateOutput(...): ", stdout);
|
||||
if ((outpdf = pdfioFileCreateOutput((pdfio_output_cb_t)output_cb, &outfd, NULL, NULL, NULL, (pdfio_error_cb_t)error_cb, &error)) != NULL)
|
||||
puts("PASS");
|
||||
else
|
||||
return (1);
|
||||
goto fail;
|
||||
|
||||
if (write_unit_file(inpdf, outpdf, &num_pages, &first_image))
|
||||
return (1);
|
||||
goto fail;
|
||||
|
||||
close(outfd);
|
||||
|
||||
if (read_unit_file("testpdfio-out2.pdf", num_pages, first_image, true))
|
||||
return (1);
|
||||
goto fail;
|
||||
|
||||
pdfioFileClose(inpdf);
|
||||
|
||||
// Create new encrypted PDF files...
|
||||
fputs("pdfioFileCreate(\"testpdfio-rc4.pdf\", ...): ", stdout);
|
||||
@ -1108,6 +1110,12 @@ do_unit_tests(void)
|
||||
return (1);
|
||||
|
||||
return (0);
|
||||
|
||||
fail:
|
||||
|
||||
pdfioFileClose(inpdf);
|
||||
|
||||
return (1);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user