pdfbox

Detect Bold, Italic and Strike Through text using PDFBox with VB.NET

萝らか妹 提交于 2019-11-28 06:14:43
问题 Is there a way to preserve the text formatting when extracting a PDF with PDFBox? I have a program that parses a PDF document for information. When a new version of the PDF is released the authors use bold or italic text to indicate new information and Strike through or underlined to indicated omitted text. Using the base Stripper class in PDFbox returns all the text but the formatting is removed so I have no way of telling if the text is new or omitted. I'm currently using the project

PDFBox - opening and saving a signed pdf invalidates my signature

隐身守侯 提交于 2019-11-28 05:56:46
问题 I am trying to learn to use Apache's pdfBox to deal with digitaly signed documents for work. During testing, I created a completely empty pdf document. I then signed the document through Adobe reader using the sign with certificate function. I tried to open, save and close the signed file with pdfBox without any modifications. However once I open the file in Adobe the files are no longer valid. Adobe tells me: "There are errors in the formatting or information contained in this signature

How to create Table using Apache PDFBox

无人久伴 提交于 2019-11-28 05:22:14
We are planning to migrate our pdf generation utilities from iText to PDFBox (Due to licensing issues in iText). With some effort, I was able to write and position text, draw lines etc. But creating Tables with text embedded in Table cells is a challenge, I went through the documentation, examples, Google, Stackoverflow couldn't find a thing. Was wondering if PDFBox provides native support for creating Tables with embedded text. My last resort would be to use this link https://github.com/eduardohl/Paginated-PDFBox-Table-Sample Since I also needed table drawing functionality for a side project,

How to split a PDF using Apache PDFBox? [closed]

对着背影说爱祢 提交于 2019-11-28 05:08:16
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 4 years ago . I am using Apache PDFBox to handle PDF files in my Java application. I would like to split a PDF document, for example, on every page. Is it possible to do this wirth Apache PDFBox? If so, how? 回答1: This is possible using a Splitter. This is a sample code that will split a

how to know if a field is on a particular page?

久未见 提交于 2019-11-28 01:19:21
问题 The PDFbox content stream is done per page, but the fields come from the form which comes from the catalog, which comes from the pdf doc itself. So I'm not sure which fields are on which pages, and its causing to write text out to incorrect locations/pages. ie. I'm processing fields per page, but not sure which fields are on which pages. Is there a way to tell which field is on which page? Or, is there a way to get just the fields on the current page? Thank you! Mark code snippet: PDDocument

PDFBox - Issue with generating PDF from a image

无人久伴 提交于 2019-11-28 00:12:19
I am trying to generate a PDF from images of type JPEG, BMP but i am gettng part of the image on the right always getting cut off. I am using one of the default windows picture Sunset.jpg. Below is the code: import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; import javax.imageio.stream.FileImageInputStream; import org.apache.pdfbox.exceptions.COSVisitorException; import org.apache.pdfbox.io.RandomAccessFile; import org.apache.pdfbox.pdmodel.PDDocument; import org.apache.pdfbox.pdmodel.PDPage; import org.apache.pdfbox.pdmodel.edit

how to make my watermark text in any pdf file as non-selectable?

帅比萌擦擦* 提交于 2019-11-27 23:18:55
I have done watermark text in pdf file using itextpdf, but when I copy the actual text of the pdf file it allows us to copy the watermark text too. Is there anyway that we can restrict our watermark text as Non-selectable? Image watermark_image = Image.getInstance(imageFile.getAbsolutePath()); while (i < num_of_pages) { i++; //To pass our watermark over text add_waterMark = pdfStamper.getOverContent(i); //To pass our watermark under text //add_waterMark = pdfStamper.getUnderContent(i); // watermark_image. watermark_image.setAbsolutePosition(0, 0); add_waterMark.beginText(); //add_waterMark

Can't add an image to a pdf using PDFBox

。_饼干妹妹 提交于 2019-11-27 22:58:58
问题 I'm writing a java app that creates a pdf from scratch using the pdfbox library. I need to place a jpg image in one of the page. I'm using this code: PDDocument document = new PDDocument(); PDPage page = new PDPage(PDPage.PAGE_SIZE_A4); document.addPage(page); PDPageContentStream contentStream = new PDPageContentStream(document, page); /* ... */ /* code to add some text to the page */ /* ... */ InputStream in = new FileInputStream(new File("c:/myimg.jpg")); PDJpeg img = new PDJpeg(document,

compress pdf with large images via java

若如初见. 提交于 2019-11-27 22:25:01
Looking for a way to compress images in a pdf and to output a pdf for archiving. I cannot compress the images before creation as it would compromise the quality of the print. The size of each pdf is around 8MB with the bulk of this being made up of 2 images. Images are in png format and are brought into pdf during generation(3rd party generator used) Is there a way to compress these in java without using a 3rd party tool. I have tried with pdfbox, itext and a 3rd party exe(neevia), the 3rd party tool the only one that has given me any results so far(Down to around half a MB) but I do not want

Add BufferedImage to PDFBox document

蹲街弑〆低调 提交于 2019-11-27 21:01:51
问题 In my current project, I try to add a BufferedImage to a PDFBox document. More specificly, I use an image from a JFreeChart . My code looks like this: public void exportToPDF(JFreeChart chart, String filePath){ PDDocument doc = null; PDPage page = null; PDXObjectImage ximage = null; try { doc = new PDDocument(); page = new PDPage(); doc.addPage(page); PDPageContentStream content = new PDPageContentStream(doc, page); BufferedImage image = chart.createBufferedImage(300, 300); ximage = new