Return-Path: X-Original-To: apmail-pdfbox-users-archive@www.apache.org Delivered-To: apmail-pdfbox-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id DDB7F1083B for ; Tue, 5 Aug 2014 07:14:42 +0000 (UTC) Received: (qmail 5060 invoked by uid 500); 5 Aug 2014 07:14:42 -0000 Delivered-To: apmail-pdfbox-users-archive@pdfbox.apache.org Received: (qmail 5038 invoked by uid 500); 5 Aug 2014 07:14:42 -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 5027 invoked by uid 99); 5 Aug 2014 07:14:42 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 Aug 2014 07:14:42 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [194.25.134.83] (HELO mailout07.t-online.de) (194.25.134.83) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 Aug 2014 07:14:38 +0000 Received: from fwd25.aul.t-online.de (fwd25.aul.t-online.de [172.20.26.130]) by mailout07.t-online.de (Postfix) with SMTP id 8665BCBDE5 for ; Tue, 5 Aug 2014 09:14:13 +0200 (CEST) Received: from [192.168.2.102] (V81n+UZawhyS0L1WIbdKVEm1bckuyaIuh4m3+mQ6xxc1w1OEOxr89voTZg5f+1agd1@[217.231.167.133]) by fwd25.t-online.de with (TLSv1:ECDHE-RSA-AES256-SHA encrypted) esmtp id 1XEYwf-0k6ALI0; Tue, 5 Aug 2014 09:14:05 +0200 Message-ID: <53E0843E.4070103@t-online.de> Date: Tue, 05 Aug 2014 09:14:06 +0200 From: Tilman Hausherr User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: users@pdfbox.apache.org Subject: Re: Gradient paint References: <009f01cfb058$da939770$8fbac650$@comcast.net> In-Reply-To: <009f01cfb058$da939770$8fbac650$@comcast.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ID: V81n+UZawhyS0L1WIbdKVEm1bckuyaIuh4m3+mQ6xxc1w1OEOxr89voTZg5f+1agd1 X-TOI-MSGID: a745d858-99ad-45e4-b3a7-5f17c192c67c X-Virus-Checked: Checked by ClamAV on apache.org Hi, please send both pdf files to me directly (tilman at snafu dot de) and I'll answer publicly. Tilman Am 05.08.2014 04:56, schrieb Eric Inman: > The code below works for me and the gradient appears. > > However, if I try to fill a rectangle by following > > contentStream.appendRawCommands("/sh1 sh"); > > with > > contentStream.setNonStrokingColor(Color.MAGENTA); > contentStream.fillRect(100,100,100,100); > > then the gradient no longer appears nor does the rectangle. If I put the rectangle code before the appendRawCommands call, then both the rectangle and the gradient appear. > > In this simple example, switching the order is an acceptable solution, but in the real application that I'm working on, I need to do these operations in either order. Is that possible? > > Thanks > > -----Original Message----- > From: Tilman Hausherr > Sent: Wed, 16 Jul 2014 04:42:47 GMT > To: users@pdfbox.apache.org > Subject: Re: Gradient paint > > For the 1.8 version the code is slightly different: > > PDDocument document = new PDDocument(); > PDPage page = new PDPage(); > document.addPage(page); > > // shading attributes > COSDictionary dict = new COSDictionary(); > dict.setInt(COSName.SHADING_TYPE, 2); > dict.setName(COSName.COLORSPACE, "DeviceRGB"); > COSArray coords = new COSArray(); > coords.add(COSInteger.get(100)); > coords.add(COSInteger.get(400)); > coords.add(COSInteger.get(400)); > coords.add(COSInteger.get(600)); > dict.setItem(COSName.COORDS, coords); > > // function with attributes > COSDictionary fdict = new COSDictionary(); > fdict.setInt(COSName.FUNCTION_TYPE, 2); > COSArray domain = new COSArray(); > domain.add(COSInteger.get(0)); > domain.add(COSInteger.get(1)); > COSArray c0 = new COSArray(); > c0.add(COSFloat.get("1")); > c0.add(COSFloat.get("0")); > c0.add(COSFloat.get("0")); > COSArray c1 = new COSArray(); > c1.add(COSFloat.get("0.5")); > c1.add(COSFloat.get("1")); > c1.add(COSFloat.get("0.5")); > fdict.setItem(COSName.DOMAIN, domain); > fdict.setItem(COSName.C0, c0); > fdict.setItem(COSName.C1, c1); > fdict.setInt(COSName.N, 1); > dict.setItem(COSName.FUNCTION, fdict); > > PDShadingType2 shading = new PDShadingType2(dict); > > // create and add to shading resources > page.setResources(new PDResources()); > Map shadings = new > HashMap(); > shadings.put("sh1", (PDShadingResources) shading); > page.getResources().setShadings(shadings); > > // invoke shading from content stream > PDPageContentStream contentStream = new > PDPageContentStream(document, page, true, false); > contentStream.appendRawCommands("/sh1 sh"); > contentStream.close(); > > document.save("shtest.pdf"); > document.close(); > > >