Reputation: 87
I would like to have 4 shapes printed on each page.
If I run the generateWord() function, the shape is not printed only on the second page.
Why isn't the shape printed on the second page?
I am attaching the word file in question.
generateWord()
private fun generateWord(path: String) {
val document = Document()
val builder = DocumentBuilder(document)
DocumentUtils.generateLine(builder)
builder.insertBreak(BreakType.PAGE_BREAK)
DocumentUtils.generateLine(builder)
builder.insertBreak(BreakType.PAGE_BREAK)
DocumentUtils.generateLine(builder)
builder.insertBreak(BreakType.PAGE_BREAK)
DocumentUtils.generateLine(builder)
document.save(path)
}
generateLine()
fun generateLine(builder: DocumentBuilder) {
builder.also {
it.insertParagraph()
val shape = Shape(builder.document, ShapeType.LINE).apply {
width = 452.0
top = 10.0
}
it.insertNode(shape)
}
}
Upvotes: 0
Views: 403
Reputation: 1962
Your code properly inserts a shape on each page of the generated document. See the screenshot of the generated document in MS Word.
Most likely the problem is caused by the consumer application, which is used to view the document.
Also if you need a shape on each page, maybe you can simply insert it into the primary header of the document. https://docs.aspose.com/words/java/working-with-headers-and-footers/
Upvotes: 1