Skip to content

Commit 82652f8

Browse files
committed
Fix stream to byte array
Signed-off-by: Kyle Corry <kylecorry31@gmail.com>
1 parent 5c81c0a commit 82652f8

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import com.vanniktech.maven.publish.AndroidSingleVariantLibrary
22

3-
val versionName = "16.0.0-beta01"
3+
val versionName = "16.0.0"
44
val groupId = "com.kylecorry.andromeda"
55

66
buildscript {

pdf/src/main/java/com/kylecorry/andromeda/pdf/PDFValue.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.kylecorry.andromeda.pdf
22

3+
import java.io.ByteArrayOutputStream
4+
35
sealed interface PDFValue {
46

57
fun toByteArray(): ByteArray {
@@ -49,6 +51,17 @@ sealed interface PDFValue {
4951
content.joinToString(separator = "\n") +
5052
"\nendobj"
5153
}
54+
55+
override fun toByteArray(): ByteArray {
56+
val bytes = ByteArrayOutputStream()
57+
bytes.write("$id $generation obj\n".toByteArray())
58+
for (value in content) {
59+
bytes.write(value.toByteArray())
60+
bytes.write("\n".toByteArray())
61+
}
62+
bytes.write("endobj\n".toByteArray())
63+
return bytes.toByteArray()
64+
}
5265
}
5366

5467
class PDFStream(val content: ByteArray) : PDFValue {

0 commit comments

Comments
 (0)