pdfbox

PDFBox: put two A4 pages on one A3

孤者浪人 提交于 2020-01-25 20:41:02
问题 I have a pdf document with one or more pages A4 paper. The resulting pdf document should be A3 paper where each page contains two from the first one (odd on the left, even on the right side). I already got it to render the A4 pages into images and the odd pages are successfully placed on the first parts of a new A3 pages but I cannot get the even pages to be placed. public class CreateLandscapePDF { public void renderPDF(File inputFile, String output) { PDDocument docIn = null; PDDocument

How to ignore missing glyphs in font used by PDFBox 2.0.7

你说的曾经没有我的故事 提交于 2020-01-24 22:59:06
问题 I'm seeing "java.lang.IllegalArgumentException: No glyph for U+05D0 in font" (as an example) exception being thrown when calling the showText(String) method of PDFPageContentStream. Catching the exception isn't very helpful because good characters won't get written. Neither is checking each character in the input string, which would be a performance killer (each PDF could be thousands of pages, millions of characters). What I really need is a way to prevent the exception for ANY missing glyph

“Find Tag from Selection” is not working in tagged pdf?

不羁的心 提交于 2020-01-24 08:51:30
问题 I have tagged a pdf using pdfbox. How I was tagged: Instead of extract text and tagging I am adding mcid's to the existing content stream (both open and closing ex: /p<< MCID 0 >> BDC .. .. .. EMC) and then I am adding that marked content to document root catalog structure. What working: Almost everything is working fine like completely tagged pdf. It is passing the PAC3 accessibility checker also. //Adding tags tokens.add(++ind, type_check(t_ype, page)); currentMarkedContentDictionary = new

Filter out all text above a certain font size from PDF

本秂侑毒 提交于 2020-01-21 10:32:33
问题 As the title says, I want to filter out all text from a PDF that is above a certain font size. Currently, I am using the PDFBox library but I am open to using any other free library for Java. My approach was to use a PDFStreamParser to iterate through the tokens. When I pass a Tf operator that has a size greater than my threshold, don't add the next Tj/TJ that is seen. However, it has become clear to me that this relatively simple approach will not work because the text may be scaled by the

How to (horizontally) align text of PDTextField in PDFBox?

*爱你&永不变心* 提交于 2020-01-20 08:33:07
问题 I have a program that create TextFields inside a PDF-file so it can be used as a form. I would like to have the text I write in the TextFields I created to be centered though. How is that possible? My code currently looks like this: PDTextField textBox = new PDTextField(acroForm); textBox.setPartialName("Field " + j + " " + i); defaultAppearanceString = "/Helv 8 Tf 0 g"; //Textsize: 8 textBox.setDefaultAppearance(defaultAppearanceString); acroForm.getFields().add(textBox); PDAnnotationWidget

PDF versions supported by PDFBOX

会有一股神秘感。 提交于 2020-01-17 11:36:15
问题 I've been looking for all the PDF versions that are supported by Apache PDFBOX. I'm using PDFBOx 0.7.3 version and actually i'm able to process all PDF's from 1.5 and older but i need to process newer versions (1.6, 1.7 and so on). Do you know if upgrading PDFBOX could solve this issue? also is there any guide to upgrade PDFBOX? if so could you provide it? Which version do you recommend? 回答1: Thank you for response, actually i decided upgrade the PDFBox to 1.8.8, i think is the latest stable,

Get colours from fonts in PDFBox

一笑奈何 提交于 2020-01-17 06:03:10
问题 I am trying to get the font colour from PDFBox and I seem to keep throwing an exception. Can someone help? The way I tried to obtain the colour was (page is the PDPage I obtained): PDResources = page.getResources(); Iterable<COSName> fontNames = resources.getFontNames(); for (COSName fontName:fontNames) System.out.println("name: " + resources.getFont(fontName).getName() + "colour: " + resources.getColorSpace(fontName).getName()); This prints out the exception: org.apache.pdfbox.pdmodel

How to get the pagenumber of the content of a bookmark in a PDF with PDFBox

久未见 提交于 2020-01-16 12:02:16
问题 I am using Apache PDFBox version 2.0.x. I am trying to search a PDF using bookmarks and when I hit my target I should be able to get the Pagenumber the bookmark is referring to. This is my code to print all bookmarks. I can do an equals search like searchText.equals(current.getTitle()) public static void printBookmark(PDOutlineNode bookmark, String indentation) throws IOException { PDOutlineItem current = bookmark.getFirstChild(); COSObject targetPageRef = null; while (current != null) {

How to get the pagenumber of the content of a bookmark in a PDF with PDFBox

放肆的年华 提交于 2020-01-16 12:00:10
问题 I am using Apache PDFBox version 2.0.x. I am trying to search a PDF using bookmarks and when I hit my target I should be able to get the Pagenumber the bookmark is referring to. This is my code to print all bookmarks. I can do an equals search like searchText.equals(current.getTitle()) public static void printBookmark(PDOutlineNode bookmark, String indentation) throws IOException { PDOutlineItem current = bookmark.getFirstChild(); COSObject targetPageRef = null; while (current != null) {

Extract content stream(Images, Text and graphics) with in a BBOX. And place it back in new PDF without loosing any style?

怎甘沉沦 提交于 2020-01-15 11:55:10
问题 I have existing content stream in pdf. And I wanted to extract the content stream under the below bounding box's. 1st BBox the graphics, text content stream . 2nd BBOX text, some math equations related content stream. 3rd BBOX Image plus text content stream is there. So I want to extract the all content stream with in the bbox? After extracting content stream I will do tagging related manipulation in content stream and I want to place it back to new PDF? This operations I wanted to do by