pdfbox

How to set the font color for PDAnnotationFreeText with using pdfbox 2.0.16

怎甘沉沦 提交于 2019-12-11 19:55:49
问题 After imported XFDF to FDFAnnotation and converted to PDAnnotation, I find that the font color of PDAnnotationFreeText is missing. <freetext page="0" rect="376.81193,778.184946,500.283994,807.936941" flags="print" name="373b558a-4892-5fb4-a9aa-b4d7175d3966" title="wwh" subject="Free text" date="D:20190808175721+08'00'" width="0" creationdate="D:20190808175700+08'00'" TextColor="#00CC63" FontSize="17"> <contents>English</contents> <defaultappearance>0 0 0 rg /Arial 17 Tf</defaultappearance>

Joining two images in java - an orange background is added

两盒软妹~` 提交于 2019-12-11 19:39:16
问题 This question is similar to… Java BufferedImage saves with unwanted background color …but regards .jpg and not .png . I join two images together using the following Java code, and an orange background is mysteriously added. How can I get rid of it? Note that I am trying to cover my bases using both setColor and setBackground , and both clearRect and fillRect . Note that the source of the two images is a PDF, extracted using PDFBox public static BufferedImage joinBufferedImage(BufferedImage

Shapes drawn on an image is inverted when written into PDF file part 2

吃可爱长大的小学妹 提交于 2019-12-11 19:05:29
问题 I have a PDF file that I converted into an image. I Was able to write on top of the image but when I tried to save the shapes/lines into the pdf, the point are not their place and the shapes are inverted. This is related to this question and it the first part was already answered. Now the second problem was when I try to scale the image. the points are not in their places. I found out that it is not working when the scale is changed.. I updated the code and added the Translate values to the

How to extract Font color using PDFBOX java?

非 Y 不嫁゛ 提交于 2019-12-11 18:57:38
问题 Actually I need to extract font color of each character , found this below piece of code from a forum but while executing it throws me the error Apr 19, 2013 6:23:45 PM org.apache.pdfbox.util.operator.pagedrawer.FillNonZeroRule process WARNING: java.lang.ClassCastException: org.apache.pdfbox.util.PDFStreamEngine cannot be cast to org.apache.pdfbox.pdfviewer.PageDrawer java.lang.ClassCastException: org.apache.pdfbox.util.PDFStreamEngine cannot be cast to org.apache.pdfbox.pdfviewer.PageDrawer"

PDFBox: Handling white text on color background

此生再无相见时 提交于 2019-12-11 17:24:36
问题 I have some tricky PDF files contains white text. To don't render it in text stripper, I override ProcessTextPosition method: private static final int COLOR_WHITE = 16777215; @Override protected void processTextPosition(TextPosition text) { PDGraphicsState gs = getGraphicsState(); PDColor nonStrokingColor = gs.getNonStrokingColor(); try { if (nonStrokingColor.toRGB() != COLOR_WHITE) { super.processTextPosition(text); } } catch (IOException e) { logger.error("Could not convert stroking color

Signing PDF with multiple signature fields using PDFBox 2.0.17

让人想犯罪 __ 提交于 2019-12-11 16:19:04
问题 I am trying to sign a PDF with 2 signature fields using the example code provided by PDFBox ( https://svn.apache.org/repos/asf/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateVisibleSignature.java ). But the signed PDF shows There have been changes made to this document that invalidate the signature . I have uploaded my sample project to GitHub please find it here. The project can be opened using IntelliJ or Eclipse. The program argument should be set to the

How to draw square in pdf if any character not available in the font file using pdfbox

拟墨画扇 提交于 2019-12-11 15:58:01
问题 I am working to create pdf using pdfbox 2.0 with the content available in datatable. While creating pdf some of the characters are not available in the font file. Below exception thrown if any character not available in the font. Note : AAAA indicate unicode character and BBBB is the font file in the exception block. java.lang.IllegalArgumentException: No glyph for AAAA in font BBBB at org.apache.pdfbox.pdmodel.font.PDCIDFontType2.encode(PDCIDFontType2.java:411) at org.apache.pdfbox.pdmodel

add signature or image on PDF using drag and drop android (get x and y coordinates )

只愿长相守 提交于 2019-12-11 15:29:26
问题 I am using Pdfbox https://github.com/TomRoush/PdfBox-Android to add signature(image) on pdf i want to add signature using drag and drop i have implemented some code using touch listener please see and help me i am not getting exact x and y coordinates to add it in pdfbox code from touch listener and i also try drag and drop code https://www.tutorialspoint.com/android/android_drag_and_drop.htm but it won't help. when i test the app and drop the signature(image) on pdf the result pdf won't get

Image replacement using PDFBox

我的未来我决定 提交于 2019-12-11 15:28:27
问题 I want to replace image on first page in my PDF. I am using the following code. However, it looks like transparency is lost. How to retain the transparency of original image for(int a=0;a<1;a++){ PDPage p = doc.getPage(a); PDResources resources = p.getResources(); for (COSName xObjectName : resources.getXObjectNames()) { PDXObject xObject = resources.getXObject(xObjectName); if (xObject instanceof PDImageXObject) { PDImageXObject original_img = ((PDImageXObject) xObject); PDImageXObject

Using pdfbox, why text can be extracted, but not image

偶尔善良 提交于 2019-12-11 15:13:10
问题 I am using pdfbox to extract image and text from this pdf. I have following code for extraction of text: PDFTextStripper p = new PDFTextStripper(); String thistext=p.getText(document); Which extracts the text properly. However, when I try to extract images from the same pdf using ExtractImages class, the images produced are all pages of the pdf, not the actual images. Is that because of the reason that the pdf might be a scanned copy? If that is true, how come the text is extracted? 回答1: I