From dev-return-64508-archive-asf-public=cust-asf.ponee.io@pdfbox.apache.org Thu Aug 1 18:16:02 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 35B5D180644 for ; Thu, 1 Aug 2019 20:16:02 +0200 (CEST) Received: (qmail 40151 invoked by uid 500); 1 Aug 2019 18:16:01 -0000 Mailing-List: contact dev-help@pdfbox.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@pdfbox.apache.org Delivered-To: mailing list dev@pdfbox.apache.org Received: (qmail 40135 invoked by uid 99); 1 Aug 2019 18:16:01 -0000 Received: from mailrelay1-us-west.apache.org (HELO mailrelay1-us-west.apache.org) (209.188.14.139) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Aug 2019 18:16:01 +0000 Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id B9D52E2F9C for ; Thu, 1 Aug 2019 18:16:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 4165426640 for ; Thu, 1 Aug 2019 18:16:00 +0000 (UTC) Date: Thu, 1 Aug 2019 18:16:00 +0000 (UTC) From: "Tilman Hausherr (JIRA)" To: dev@pdfbox.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (PDFBOX-4615) AppearanceGeneratorHelper.setAppearanceValue doesn't set the bounding box on the appearance stream correctly MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/PDFBOX-4615?page=3Dcom.atlassia= n.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D168= 98254#comment-16898254 ]=20 Tilman Hausherr commented on PDFBOX-4615: ----------------------------------------- It turns out that there were many tests, but they are disabled. This is bec= ause they bring tiny visual differences so the test results are to be check= ed manually. All are good except one =F0=9F=98=A2 , the file of PDFBOX3083.= That one is 90=C2=B0 rotated. I tried something hard-coded just to test an= d that looks nice, but it means more changes are needed. > AppearanceGeneratorHelper.setAppearanceValue doesn't set the bounding box= on the appearance stream correctly > -------------------------------------------------------------------------= ----------------------------------- > > Key: PDFBOX-4615 > URL: https://issues.apache.org/jira/browse/PDFBOX-4615 > Project: PDFBox > Issue Type: Bug > Components: AcroForm > Affects Versions: 2.0.16 > Reporter: Rosalind Douglas > Priority: Major > Fix For: 2.0.17, 3.0.0 PDFBox > > Attachments: flattenedboundingbox.pdf, resetboundingbox-filled.pd= f, resetboundingbox-flattened-bugfix.pdf, resetboundingbox-flattened.pdf, r= esetboundingbox.pdf > > > Hello, thanks for all your effort with PDFBox. We use it heavily for pars= ing and flattening PDFs. > BUG: In the attached PDF "resetboundingbox.pdf", we programmatically set = the value of the text fields, then call pdAcroForm.flattten(), which produc= es the flattened PDF "flattenedboundingbox.pdf." I would expect that the te= xt would entirely fill the text box (see textbox with {color:#8eb021}green = border{color} in "flattenedboundingbox.pdf") but the text does not. Instead= , the filled text area obeys another box instead (see text area with {color= :#d04437}red border{color} in "flattenedboundingbox.pdf"). > POTENTIAL FIX: We've traced the problem to AppearanceGeneratorHelper.setA= ppearanceValue, lines 200-210. As long as we always set the bounding box (l= ine 243) like in=C2=A0AppearanceGeneratorHelper.prepareNormalAppearanceStre= am, regardless of the if/else at line 200, then the flattening works correc= tly: > {code:java} > /** * replace AppearanceGeneratorHelper lines 199-210 with: */=20 > PDAppearanceStream appearanceStream =3D appearance !=3D null && appearanc= e.isStream() ? appearance.getAppearanceStream() : new PDAppearanceStream(fi= eld.getAcroForm().getDocument()); > =20 > // copied from lines 237-243=20 > int rotation =3D resolveRotation(widget); > PDRectangle rect =3D widget.getRectangle();=20 > Matrix matrix =3D Matrix.getRotateInstance(Math.toRadians(rotation), 0, 0= );=20 > Point2D.Float point2D =3D matrix.transformPoint(rect.getWidth(), rect.get= Height());=20 > PDRectangle bbox =3D new PDRectangle(Math.abs((float) point2D.getX()), Ma= th.abs((float) point2D.getY()));=20 > appearanceStream.setBBox(bbox);=20 > appearanceDict.setNormalAppearance(appearanceStream); > {code} > Something I'm not sure about: in method=C2=A0prepareNormalAppearanceStrea= m, there is additional code for setting the matrix (lines 245-251), which w= e don't seem to need. Since it doesn't break anything, we just keep it too. > Thanks again for your help! -- This message was sent by Atlassian JIRA (v7.6.14#76016) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org For additional commands, e-mail: dev-help@pdfbox.apache.org