Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
enriquebautista opened this issue Feb 13, 2025 · 1 comment
Labels
type: bug Existing feature doesn't work correctly

Comments

@enriquebautista
Copy link

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)
@enriquebautista enriquebautista added the type: bug Existing feature doesn't work correctly label Feb 13, 2025
@enriquebautista
Copy link
Author

Update:
I found an solution: set pdf flatten before draw X.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Existing feature doesn't work correctly
Projects
None yet
Development

No branches or pull requests

1 participant