Skip to content

Latest commit

 

History

History
45 lines (35 loc) · 1.08 KB

README.md

File metadata and controls

45 lines (35 loc) · 1.08 KB

convert pdf to pwg or pclm

The repo is Kotlin/jvm code.

The code is come from: jipp example, the library just wrapper sample code.

To use the code

  1. copy code of use maven/gradle
  2. import
dependencies {
    implementation("top.kikt:PdfToPrinter:1.0.0")
}
  1. use code in kotlin
package top.kikt.pdf

import org.junit.jupiter.api.Test
import java.io.FileInputStream
import java.io.IOException

internal class ConverterKtTest {

    @Test
    fun convertPdfTest() {
        for (outputFormat in OutputFormat.values()) {
            val inputStream =
                FileInputStream("testFiles/2022-11-26.pdf") ?: throw IOException("The inputStream cannot open")
            inputStream.use {
                convertPdf(inputStream, outputFormat) {
                    val bytes = it.toByteArray()
                    println("$outputFormat bytes count: ${bytes.count()}")
                }
            }
        }
    }

}