in my App I print some parts to a pdf for the user. I do this by using a PrintedPdfDocument.
The code looks in short like this:
// create a new document
val printAttributes = PrintAttributes.Builder()
.setMediaSize(mediaSize)
.setColorMode(PrintAttributes.COLOR_MODE_COLOR)
.setMinMargins(PrintAttributes.Margins.NO_MARGINS)
.build()
val document = PrintedPdfDocument(context, printAttributes)
// add pages
for ((n, pdfPageView) in pdfPages.withIndex()) {
val page = document.startPage(n)
Timber.d("Printing page " + (n + 1))
pdfPageView.draw(page.canvas)
document.finishPage(page)
}
// write the document content
try {
val out: OutputStream = FileOutputStream(outputFile)
document.writeTo(out)
out.close()
Timber.d("PDF written to $outputFile")
} catch (e: IOException) {
return
}
It all works fine. However now I want to add another page at the end. Only exception is that this will be a pre-generated pdf file from the assets. I only need to append it so no additional rendering etc. should be necessary.
Is there any way of doing this via the PdfDocument class from the Android SDK?
I assumed it might be a similar question like this here: how can i combine multiple pdf to convert single pdf in android?
But is this true? The answer was not accepted and is 3 years old. Any suggestions?