diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2016-02-24 16:14:50 +0100 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2016-02-25 00:43:08 +0100 |
commit | 69aed0dfe71a37f58b1be4571b2fff2c257a9b98 (patch) | |
tree | d401bd03137d44c1b2f088e43ce5fc4de08dd0f7 | |
parent | 7d7016377a6457a49ae4c4857a934c93be7b9051 (diff) | |
download | mupdf-69aed0dfe71a37f58b1be4571b2fff2c257a9b98.tar.xz |
Skip the newline before endstream if the stream ends in a newline.
-rw-r--r-- | source/pdf/pdf-write.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/source/pdf/pdf-write.c b/source/pdf/pdf-write.c index 31c65b32..e9b06d33 100644 --- a/source/pdf/pdf-write.c +++ b/source/pdf/pdf-write.c @@ -1661,7 +1661,9 @@ static void copystream(fz_context *ctx, pdf_document *doc, pdf_write_state *opts pdf_print_obj(ctx, opts->out, obj, opts->do_tight); fz_puts(ctx, opts->out, "\nstream\n"); fz_write(ctx, opts->out, buf->data, buf->len); - fz_puts(ctx, opts->out, "\nendstream\nendobj\n\n"); + if (buf->len > 0 && buf->data[buf->len-1] != '\n') + fz_putc(ctx, opts->out, '\n'); + fz_puts(ctx, opts->out, "endstream\nendobj\n\n"); fz_drop_buffer(ctx, buf); pdf_drop_obj(ctx, obj); @@ -1710,7 +1712,9 @@ static void expandstream(fz_context *ctx, pdf_document *doc, pdf_write_state *op pdf_print_obj(ctx, opts->out, obj, opts->do_tight); fz_puts(ctx, opts->out, "\nstream\n"); fz_write(ctx, opts->out, buf->data, buf->len); - fz_puts(ctx, opts->out, "\nendstream\nendobj\n\n"); + if (buf->len > 0 && buf->data[buf->len-1] != '\n') + fz_putc(ctx, opts->out, '\n'); + fz_puts(ctx, opts->out, "endstream\nendobj\n\n"); fz_drop_buffer(ctx, buf); pdf_drop_obj(ctx, obj); |