Hi, I'm trying to cross out text in PDF files in java with the PDFBOX 2.0.4 library, I currently cover the area with an image, but I discovered that by having OCR in the PDF the text is still selectable.
private void cubrir(int page, String imagePath, PDDocument document, String savepath) throws IOException {
PDPage docPage = document.getPage(page);
docPage = document.getPage(page);
PDRectangle mediabox = docPage.getMediaBox();
PDImageXObject pdImage = PDImageXObject.createFromFile(imagePath, document);
try (
PDPageContentStream contentStream = new PDPageContentStream(document, docPage, true, true)) {
contentStream.drawImage(pdImage, 0, 0, mediabox.getWidth(), mediabox.getHeight());
}
document.save(savepath);
}