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 0BA1D11F31 for ; Tue, 5 Aug 2014 02:57:15 +0000 (UTC) Received: (qmail 70111 invoked by uid 500); 5 Aug 2014 02:57:14 -0000 Delivered-To: apmail-pdfbox-users-archive@pdfbox.apache.org Received: (qmail 70085 invoked by uid 500); 5 Aug 2014 02:57:14 -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 70067 invoked by uid 99); 5 Aug 2014 02:57:14 -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 02:57:14 +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: domain of eric-inman@comcast.net designates 76.96.62.48 as permitted sender) Received: from [76.96.62.48] (HELO qmta05.westchester.pa.mail.comcast.net) (76.96.62.48) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 Aug 2014 02:57:08 +0000 Received: from omta24.westchester.pa.mail.comcast.net ([76.96.62.76]) by qmta05.westchester.pa.mail.comcast.net with comcast id aqb41o0061ei1Bg55qwjdq; Tue, 05 Aug 2014 02:56:43 +0000 Received: from Y510P ([50.171.243.30]) by omta24.westchester.pa.mail.comcast.net with comcast id aqwi1o00S0g45zE3kqwj7H; Tue, 05 Aug 2014 02:56:43 +0000 From: "Eric Inman" To: Subject: RE: Gradient paint Date: Mon, 4 Aug 2014 21:56:28 -0500 Message-ID: <009f01cfb058$da939770$8fbac650$@comcast.net> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 15.0 Thread-Index: Ac+wVxUOsfTabGCDQrurfl9oD8QLXQ== Content-Language: en-us DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=comcast.net; s=q20140121; t=1407207403; bh=vkUBpugURR0Cgp24rYqzGbLd0eTlR7csvtNEOQCIlG4=; h=Received:Received:From:To:Subject:Date:Message-ID:MIME-Version: Content-Type; b=ilQIuKZs+4Xg6ejOGJBEheZ6bAd3GHVjXhHiIvs8ZS2kdAFlh02Cdk9eJFLdho72Q 72C259yMnq6h+Iad3P1S4UI8r+oF6YYezh2VkQSiDq41+VGZjYIqL+k91oE6AynQlg w1wH08E2d21+rvyDORLCGy5X2cj2x0NcwzWMN0BcV+PnOBQWt9ZlnMOWwT80klqT9k Jh6xtnuffX6hdPn2nBCvtxopKApTZoOKhhaAYeWmkpExzKnKJU92d+b4Dau79roOXI gduv2E7Dz30u/qNoIxmnSz/sfkQC+KN8FasM6QlCPjtiDFITVkWTfKIlWvO2o6sJsO tf8Wn4kwVpnCA== X-Virus-Checked: Checked by ClamAV on apache.org 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=20 Subject: Re: Gradient paint For the 1.8 version the code is slightly different: PDDocument document =3D new PDDocument(); PDPage page =3D new PDPage(); document.addPage(page); // shading attributes COSDictionary dict =3D new COSDictionary(); dict.setInt(COSName.SHADING_TYPE, 2); dict.setName(COSName.COLORSPACE, "DeviceRGB"); COSArray coords =3D 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 =3D new COSDictionary(); fdict.setInt(COSName.FUNCTION_TYPE, 2); COSArray domain =3D new COSArray(); domain.add(COSInteger.get(0)); domain.add(COSInteger.get(1)); COSArray c0 =3D new COSArray(); c0.add(COSFloat.get("1")); c0.add(COSFloat.get("0")); c0.add(COSFloat.get("0")); COSArray c1 =3D 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 =3D new PDShadingType2(dict); // create and add to shading resources page.setResources(new PDResources()); Map shadings =3D new=20 HashMap(); shadings.put("sh1", (PDShadingResources) shading); page.getResources().setShadings(shadings); // invoke shading from content stream PDPageContentStream contentStream =3D new=20 PDPageContentStream(document, page, true, false); contentStream.appendRawCommands("/sh1 sh"); contentStream.close(); document.save("shtest.pdf"); document.close();