diff --git a/src/main/java/com/github/fabriciofx/cactoos/pdf/type/Dictionary.java b/src/main/java/com/github/fabriciofx/cactoos/pdf/type/Dictionary.java index ac61434..70ca234 100644 --- a/src/main/java/com/github/fabriciofx/cactoos/pdf/type/Dictionary.java +++ b/src/main/java/com/github/fabriciofx/cactoos/pdf/type/Dictionary.java @@ -106,16 +106,14 @@ public String asString() throws Exception { @Override public byte[] asBytes() throws Exception { - final ByteArrayOutputStream baos = new ByteArrayOutputStream(); + final ByteArrayOutputStream output = new ByteArrayOutputStream(); if (!this.entries.isEmpty()) { - baos.write(this.asString().getBytes(StandardCharsets.UTF_8)); + output.write(this.asString().getBytes(StandardCharsets.UTF_8)); } if (!this.stream.isEmpty()) { - baos.write("\nstream\n".getBytes(StandardCharsets.UTF_8)); - baos.write(this.stream.get(0).value()); - baos.write("\nendstream".getBytes(StandardCharsets.UTF_8)); + output.write(this.stream.get(0).asBytes()); } - return baos.toByteArray(); + return output.toByteArray(); } /** diff --git a/src/main/java/com/github/fabriciofx/cactoos/pdf/type/Stream.java b/src/main/java/com/github/fabriciofx/cactoos/pdf/type/Stream.java index 362a50d..77c33f3 100644 --- a/src/main/java/com/github/fabriciofx/cactoos/pdf/type/Stream.java +++ b/src/main/java/com/github/fabriciofx/cactoos/pdf/type/Stream.java @@ -68,7 +68,7 @@ public byte[] value() throws Exception { @Override public byte[] asBytes() throws Exception { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); - baos.write("stream\n".getBytes(StandardCharsets.UTF_8)); + baos.write("\nstream\n".getBytes(StandardCharsets.UTF_8)); baos.write(this.bytes.asBytes()); baos.write("\nendstream".getBytes(StandardCharsets.UTF_8)); return baos.toByteArray();