From users-return-11846-archive-asf-public=cust-asf.ponee.io@pdfbox.apache.org Wed Jun 26 16:16:54 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 ED95F18064D for ; Wed, 26 Jun 2019 18:16:53 +0200 (CEST) Received: (qmail 77024 invoked by uid 500); 26 Jun 2019 16:16:53 -0000 Mailing-List: contact users-help@pdfbox.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@pdfbox.apache.org Delivered-To: mailing list users@pdfbox.apache.org Received: (qmail 77013 invoked by uid 99); 26 Jun 2019 16:16:52 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 26 Jun 2019 16:16:52 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 0D86CC0021 for ; Wed, 26 Jun 2019 16:16:52 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.002 X-Spam-Level: * X-Spam-Status: No, score=1.002 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id dCUou6gpQtVh for ; Wed, 26 Jun 2019 16:16:48 +0000 (UTC) Received: from mailout08.t-online.de (mailout08.t-online.de [194.25.134.20]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id BAE0B5FD5C for ; Wed, 26 Jun 2019 16:16:47 +0000 (UTC) Received: from fwd10.aul.t-online.de (fwd10.aul.t-online.de [172.20.26.152]) by mailout08.t-online.de (Postfix) with SMTP id D1C7C41D6BB5 for ; Wed, 26 Jun 2019 18:16:40 +0200 (CEST) Received: from [192.168.2.111] (Z4wu-iZBwhHH+kiBl1KRox2WuRPhZaenVNYVOSOd3OYxBWv4ZIJ-kjtEVm3piWEQ10@[84.151.177.203]) by fwd10.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384 encrypted) esmtp id 1hgAbA-0qolRA0; Wed, 26 Jun 2019 18:16:40 +0200 Subject: Re: Drawing only a portion of a PDF (Graphics.clip is ignored/overwritten) To: users@pdfbox.apache.org References: <2460331894-29665@connect.abm-local.de> From: Tilman Hausherr Message-ID: <3b61b8a5-a240-4f24-aa96-9fadc01d140c@t-online.de> Date: Wed, 26 Jun 2019 18:16:39 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <2460331894-29665@connect.abm-local.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-ID: Z4wu-iZBwhHH+kiBl1KRox2WuRPhZaenVNYVOSOd3OYxBWv4ZIJ-kjtEVm3piWEQ10 X-TOI-MSGID: 405d8eca-a771-4de1-b9ba-c704e9b84733 Very good question. Yes, PageDrawer uses setClip(). We can still do this, but should remember the initial clipping path and intersect that one. Please create an issue tomorrow if there isn't a different opinion. Tilman Am 26.06.2019 um 09:29 schrieb Jan Buschtoens: > Hi. > > > I want to use PDFBox to draw PDFs in a swing application. > > > I already created a  new issue for a problem I had on Linux (PDFBOX-4581). But unrelated to that I had another problem (on windows and  linux), and I wanted to ask first if I'm doing something wrong before I create a new issue. > > > I want to draw only a portion of the PDF. As far as I know, the way to do this in swing is with the "clip"-method on the Graphics object. However, no matter what clip I set, the wohle PDF is drawn. I believe that PDFRenderer calls "setClip", when it probably should use "clip". The latter sets the current clip to the intersection of the old current clip and the provided shape, wheras the former resets the current clip. > > > > My code is essentially the following: > > >         @Override >         public void paint(final Graphics g) { > >             final Graphics2D g2 = (Graphics2D) g; >             try { >                 PDDocument pdDocument = PDDocument.load(App.class.getResourceAsStream("somepdf.pdf")); >                 g2.clip(new Rectangle(20, 20)); >                 final PDFRenderer pdfRenderer = new org.apache.pdfbox.rendering.PDFRenderer(pdDocument); >                 pdfRenderer.renderPageToGraphics(0, g2); >             } catch (final IOException e) { >                 throw new RuntimeException(e); >             } >         } > > > -- > > { Geschaeftsfuehrer: Dipl.-Inform. Christopher Asp, Amtsgericht: Mannheim, HRB: 105845 } --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org For additional commands, e-mail: users-help@pdfbox.apache.org