pdfbox

How to get the current Page Number from PDF form using PDFBOX?

[亡魂溺海] 提交于 2019-12-23 05:17:30
问题 How to get the current Page Number from PDF form using PDFBOX ? Is there any way to get the particular fields page number? For example, if a text box named First name is present on 4 page of a PDF form is it possible to retrieve current Page number as 4? Any insight into a possible solution? Thanks 回答1: I am usually filling the page number information on every new page during the pdf build. This means that I know the page number of the edited page which is currently the last page. private

PDFBox retrieve text from overlapping boxes

♀尐吖头ヾ 提交于 2019-12-23 05:01:49
问题 I've had some success using the PDFTextStripperByArea class to retrieve text contained within a specified rectangle. However, some of the PDFs I an scraping have text that is in slightly different places from page to page. I'm looking for help in how to deal with this. In the example below, I can open the PDF in Acrobat Edit mode and see multiple text boxes (outlines with thin grey lines). I have indicated two regions (purple and red) that I would like to extract text from. However, instead

PDFBox retrieve text from overlapping boxes

心已入冬 提交于 2019-12-23 05:01:25
问题 I've had some success using the PDFTextStripperByArea class to retrieve text contained within a specified rectangle. However, some of the PDFs I an scraping have text that is in slightly different places from page to page. I'm looking for help in how to deal with this. In the example below, I can open the PDF in Acrobat Edit mode and see multiple text boxes (outlines with thin grey lines). I have indicated two regions (purple and red) that I would like to extract text from. However, instead

Place an image on a PDF file using JavaFX

我与影子孤独终老i 提交于 2019-12-23 03:41:41
问题 I've manged to place text into a pdf file using Javafx and PDFbox from Apache. Now I am trying to place an image from taking a screen shot of a scene, to the pdf document. WritableImage snapshot = quotes.getScene().snapshot(null); PDDocument doc = null; PDPage page = null; PDXObjectImage ximg = null; BufferedImage bufferedImg = SwingFXUtils.fromFXImage(snapshot, null); try{ doc = new PDDocument(); page = new PDPage(); doc.addPage(page); PDPageContentStream content = new PDPageContentStream

Place an image on a PDF file using JavaFX

可紊 提交于 2019-12-23 03:41:32
问题 I've manged to place text into a pdf file using Javafx and PDFbox from Apache. Now I am trying to place an image from taking a screen shot of a scene, to the pdf document. WritableImage snapshot = quotes.getScene().snapshot(null); PDDocument doc = null; PDPage page = null; PDXObjectImage ximg = null; BufferedImage bufferedImg = SwingFXUtils.fromFXImage(snapshot, null); try{ doc = new PDDocument(); page = new PDPage(); doc.addPage(page); PDPageContentStream content = new PDPageContentStream

Faster PDF page dimensions using PDFBox?

那年仲夏 提交于 2019-12-23 03:22:52
问题 I am comparing Apache PDFBox (2.0.8) and ITextPDF (5.1.3) on Java. My use case is to find the dimensions of every page in a PDF. PDFBox is a lot slower than iText when it comes to this. While iTextPDF seems to have methods to get page's size exclusively, I was not able to find any method which would let PDFBox do the same without reading the page's content. iText : reader = new PdfReader(filepath); Rectangle psize = reader.getPageSize(pageNumber); float width = psize.getWidth(); float height

Attachment damages signature

不羁的心 提交于 2019-12-23 02:56:08
问题 I have PDF document. 1) Adobe reader reads document well. 2) I sign document (using pdfbox) and everything is well 3) I try to attach file to original pdf (Code is written in the pdfbox web page - in the cookBook). 4) Adobe reader reads attached document well. everything is well. 5) Now I have document with attachment. 6) I try to sign that document (I mean document with attachment). And I have 2 problem: First: when I open document, Adobe reader tells me that signature byte range is invalid.

Convert PS files to PDF/A via Ghostscript, color space problems

痴心易碎 提交于 2019-12-23 02:25:08
问题 I am faced with a quite similar issue as discussed in this thread. Using GhostScript 9.14 I am trying to create a valid PDF/A from a Postscript file. I am invoking following command: "gswin64.exe" -dPDFA=1 -dBATCH -dNOPAUSE -dNOOUTERSAVE -sColorConversionStrategy=/RGB -sOutputICCProfile=AdobeRGB1998.icc -sDEVICE=pdfwrite -sOutputFile=output.pdf -dPDFACompatibilityPolicy=2 "PDFA_defRGB.ps" input.ps After doing so I validate via Apache's PDFBox and online via www.pdf-tools.com. PDF-tools tells

write in unicode text on visible signature - pdfbox

梦想与她 提交于 2019-12-23 01:37:29
问题 I'we build PDF, using PDFBox. I've visible signature too. I write some text like that: ... builderSting.append("Tm\n"); builderSting.append(" /F1 " + fontSize + "\n"); builderSting.append("Tf\n"); builderSting.append("(hello world)"); builderSting.append("Tj\n"); builderSting.append("ET"); ... PDStream stream= ...; stream.createOutputStream().write(builder.toString().getBytes("ISO-8859-1")); everything works well. but if I write some unicode characters in builderString, there is "???"s

How to import an icon to a button field in a PDF using PDFBox?

醉酒当歌 提交于 2019-12-23 01:34:10
问题 I'm looking for a way to set the normal appearance of a button field in a PDF file to an image file, but am not finding any information about this process. The closest I could find was the opposite, ie how to extract an icon from a button field to a stand-alone image file, here: How can i extract image from button icon in PDF using Apache PDFBox? I would prefer to use PDFBox for this task. Any help is greatly appreciated. 回答1: You can create a button with an image appearance using PDFBox like