Skip to content

When draw an “X” to the contentStream it stays below the content (CheckBox) #581

@enriquebautista

Description

@enriquebautista

Describe the bug
I need when the user taps on the screen to “draw” an X where he clicked on the pdf, in my case, it is in the checkBoxes, but my pdf reader does not interact with the checkBoxes, I am just trying to draw an X on top of the pdf.
With pdfBox I have managed to edit the pdf and save the changes, but to my surprise the red “X” exists but when there is a “checkbox” right on the “X” , the “X” is under the checkBox. Any idea how to fix it ? If I add an annotation by drawing lines it does work, but I don't really want an annotation (since it can be edited).

To reproduce
Code snippet to reproduce the behavior:

val document = PDDocument.load(pdfFile)

for ((pageIndex, pointF) in tappedPositions) {
    val page = document.getPage(pageIndex)
    val x = pointF.x
    val y = pointF.y

val contentStream = PDPageContentStream(document, page, PDPageContentStream.AppendMode.APPEND, true)
contentStream.setStrokingColor(0f, 1f, 0.65f, 0.08f)
contentStream.setLineWidth(2f)

// Draw X
contentStream.moveTo(x - 10, y - 10)
contentStream.lineTo(x + 10, y + 10)
contentStream.moveTo(x + 10, y - 10)
contentStream.lineTo(x - 10, y + 10)
contentStream.stroke()
contentStream.close()
}

document.save(newPdfFile)

PDF example
https://drive.google.com/file/d/1q5mw9XfATXOtjtEpOQHiRbX6HWwm2DDk/view?usp=sharing

Expected behavior
What I expect is that the “X” will be drawn on top of any element in the PDF.

Actual behavior
Currently the “X” is below the checkBoxes.

Environment details:

  • PdfBox-Android version: 2.0.27.0
  • Android API version: 33 (Android 13)

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugExisting feature doesn't work correctly

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions