pdfbox

Write higher resolution (DPI) Images to PDF

最后都变了- 提交于 2019-12-13 18:42:06
问题 I have seen code to extract the images based on image DPI using PDFBox like below PDDocument document = PDDocument.load(path); PDFImageWriter writer = new PDFImageWriter(); boolean success = writer.writeImage(document, "jpg", "", 1, 1, "C:\\Image Quality\\150", BufferedImage.TYPE_INT_RGB, 150); return document; In above code I can specify the image resolution(150) while extracting the image from pdf. With higher resolution I get larger image in return. Now I want reverse of it means to

Editing PDF from Java Using PDFBox

天大地大妈咪最大 提交于 2019-12-13 16:46:24
问题 I am currently getting a page from a PDF and then trying to edit that particular page. When i do the edit it is not saving within the PDF itself. This is my code could someone please help. PDPage page = (PDPage) allPages.get(f); System.out.println(page); PDRectangle pageSize = page.findMediaBox(); float stringWidth = font.getStringWidth( "AAA" ); float centeredPosition = (pageSize.getWidth() - (stringWidth*fontSize)/1000f)/2f; PDPageContentStream contentStream = new PDPageContentStream(pdoc

Pdf version information not correct using pdfbox

久未见 提交于 2019-12-13 10:16:59
问题 We are having a pdf which when opened in Acrobat Reader shows a version of 1.5 but when using Pdfbox(version 1.8.3) the version shows 1.3. The code that we are using: `aDocument.getDocument().getVersion()` where aDocument is an instance of PDDocument. Pdfbox version we are using is 1.8.3 Any help regarding this will be highly appreciated. 回答1: Hitesh Saliya already discussed that PDF in his question Adobe showing incorrect PDF Version (of PDF) in Properties. In this answer it became appearant

Extract Stream-Dump from PDF-Body with PDFBox

家住魔仙堡 提交于 2019-12-13 08:10:33
问题 i want to extract a Stream-Dump from a PDF with PDFBox. Is this possible with PDFBox? I want to get the original HEX-Code of the Content of a PDF, like this: BT /F19 8.9664 Tf 96.197 606.119 Td [(Kommunikation)]TJ ET q 1 0 0 1 85.238 594.35 cm []0 d 0 J 0.398 w 0 0 m 0 7.352 l S Q BT /F19 8.9664 Tf 133.856 595.758 Td [(Erster)-600(Testuebertrag)-600(auf)-600(die)-600(Neuentwicklung)-600(fuer)-600(die)-600(PSA)-600(Direktbank)-600(ma)]TJ ET q 1 0 0 1 85.238 583.989 cm []0 d 0 J 0.398 w 0 0 m 0

How to fetch MediaBox of PDF pages without parsing whole file?

谁说胖子不能爱 提交于 2019-12-13 04:46:02
问题 Is there a way to use Apache PDFBox to read the MediaBox Rectangle of all the pages in a PDF without parsing the entire file? I currently use the following code, which takes a long time for files over 1.5 GB. // Can I avoid this 'load()' function which tries to parse the entire PDF pdfDocument = PDDocument.load(pdfFile, MemoryUsageSetting.setupTempFileOnly()) // I can only use TempFile, instead of main memory, as there are restrictions to memory usage in the application. // get the page media

Search for text in PDF files [closed]

耗尽温柔 提交于 2019-12-13 04:28:46
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I have a list of words about (86 words), and some PDF files. I would like to search for those words into PDF files and return values ​​tell me if exist. During research for solutions in tutorials I meet two problems: is that I'm forced to convert pdf file to file ?? what is the simple bibilotheque that allows me

How to add Code128 Barcode image to existing pdf using pdfbox(1.8.12) with barcode4j library?

[亡魂溺海] 提交于 2019-12-13 04:28:28
问题 I am trying to generate the barcode from barcode4j library(code128bean, other barcode beans) and try to add to the existing pdf. The barcode image is getting created locally using the below code. //Create the barcode bean Code128Bean code128Bean = new Code128Bean(); final int dpi = 150; code128Bean.setModuleWidth(UnitConv.in2mm(1.0f / dpi)); //makes the narrow bar //width exactly one pixel //bean.setCodeset(2); code128Bean.doQuietZone(false); //Open output file File outputFile = new File("D:

Getting DPI of PDPage/PDDocument to calculate PDF Dimensions Accurately

╄→гoц情女王★ 提交于 2019-12-13 04:28:24
问题 I'm looking to get an accurate size of each page in a PDF as part of a Unit test of PDF's I'll be creating. As I'm dealing with PDFs that have many different page sizes in each document the code returns an ArrayList of dimensions. AFAIK each page can have its own DPI setting too. I've done quite a bit of Googling but I've only come up with this which only gives me part of the answer, as I still need to work out what DPI each page is. PDFBox - find page dimensions public static ArrayList<float

How to print `Non-breaking space` to a pdf using apache pdf box?

送分小仙女□ 提交于 2019-12-13 03:37:28
问题 final String NBSP = new String("\u00a0"); contentStream.showText("Konichua!" + NBSP); this throws the following exception: java.lang.IllegalArgumentException: U+00A0 ('nbspace') is not available in this font Courier encoding: WinAnsiEncoding I have tried it with all the 3 fonts available; TimesNewRoman, Courier & Helvitica with all 3 resulting in the same exception. But when you look at the WIN_ANSI_ENCODING_TABLE present in the source code of apcahe pdfBox, {040, "space"}, {0243, "sterling"}

PDF2SVG: Apache Batik textAsShape Option Causes Fonts Get Converted

♀尐吖头ヾ 提交于 2019-12-13 03:35:30
问题 The code below converts PDF files into SVG format perfectly, but whatever I do, it converts Fonts into shapes... and file size are getting bigger and bigger... There is: SVGGraphics2D g2d = new CustomSVGGraphics2D(ctx, false); which triggering super(generatorCtx, textAsShapes); but neighter "false" works, nor "true"... How to accomplish this? Here is the code: package pdf2svg; import java.awt.Desktop; import java.awt.GraphicsConfiguration; import java.awt.GraphicsDevice; import java.awt