Hello, I'm validating the use of pdfbox 1.8.6 for the creation of a pdf file for an editor.
Therefore I need to create a shading within an ellipse, which looks like the following: [cid:[email protected]] I wrote a test program, which creates a circular shading: public static void main(String[] args) { testLinearGradient(); testCircularGradient(); } public static void testCircularGradient() { try { float width = 600.0f; float height = 600.0f; PDRectangle sizePDF = new PDRectangle(width, height); PDDocument document = new PDDocument(); PDPage page = new PDPage(sizePDF); document.addPage(page); // shading attributes COSDictionary dict = new COSDictionary(); dict.setInt(COSName.SHADING_TYPE, 3); dict.setName(COSName.COLORSPACE, "DeviceRGB"); COSArray coords = new COSArray(); coords.add(COSInteger.get(300)); //x1 coords.add(COSInteger.get(300)); //y1 coords.add(COSInteger.get(300)); //x2 coords.add(COSInteger.get(300)); //y2 int radius = 300; coords.add(COSInteger.get(radius)); //r1 coords.add(COSInteger.get(0)); //r2 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")); //color 1 red c0.add(COSFloat.get("0")); c0.add(COSFloat.get("0")); COSArray c1 = new COSArray(); c1.add(COSFloat.get("0")); // color 2 blue c1.add(COSFloat.get("0")); c1.add(COSFloat.get("1")); fdict.setItem(COSName.DOMAIN, domain); fdict.setItem(COSName.C0, c0); fdict.setItem(COSName.C1, c1); fdict.setFloat(COSName.N, 1.0f); dict.setItem(COSName.FUNCTION, fdict); PDShadingType3 shading = new PDShadingType3(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("c:\\pdfCircularGradient.pdf"); document.close(); } catch (Exception e) { System.out.println(" error creating pdf file." + e.toString()); } } Does anyone has an idea, how I can change the program, so it will create an elliptic shading. Is an elliptic shading supported by the pdf specification? Thanks Klaus Graaf Sitz der Gesellschaft / Corporate Headquarters: Lufthansa Systems AS GmbH, Norderstedt, Registereintragung / Registration: Amtsgericht Norderstedt 3688NO Geschaeftsfuehrung / Management Board: Bernd Appel

