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 4DA0017FA1 for ; Wed, 1 Apr 2015 19:05:25 +0000 (UTC) Received: (qmail 26156 invoked by uid 500); 1 Apr 2015 19:05:22 -0000 Delivered-To: apmail-pdfbox-users-archive@pdfbox.apache.org Received: (qmail 26133 invoked by uid 500); 1 Apr 2015 19:05:22 -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 26122 invoked by uid 99); 1 Apr 2015 19:05:21 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 Apr 2015 19:05:21 +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 (athena.apache.org: local policy) Received: from [194.25.134.80] (HELO mailout01.t-online.de) (194.25.134.80) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 Apr 2015 19:05:15 +0000 Received: from fwd22.aul.t-online.de (fwd22.aul.t-online.de [172.20.26.127]) by mailout01.t-online.de (Postfix) with SMTP id A613F525482 for ; Wed, 1 Apr 2015 21:03:53 +0200 (CEST) Received: from [192.168.2.102] (ESLBmEZ1ghhpTxl0iX-rO-7e-vpebfmZVwDtUavMOB91CUS59BXGEt2bLg8Y0eeghF@[217.231.143.205]) by fwd22.t-online.de with (TLSv1.2:ECDHE-RSA-AES256-SHA encrypted) esmtp id 1YdNvb-0727ZA0; Wed, 1 Apr 2015 21:03:51 +0200 Message-ID: <551C4142.1040203@t-online.de> Date: Wed, 01 Apr 2015 21:04:34 +0200 From: Tilman Hausherr Reply-To: users@pdfbox.apache.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: users@pdfbox.apache.org Subject: Re: Separation Space References: <551C329B.7040004@gmail.com> <551C3780.2050807@t-online.de> In-Reply-To: <551C3780.2050807@t-online.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-ID: ESLBmEZ1ghhpTxl0iX-rO-7e-vpebfmZVwDtUavMOB91CUS59BXGEt2bLg8Y0eeghF X-TOI-MSGID: 8b683cfa-6610-44be-bdf8-d78b851727ad X-Virus-Checked: Checked by ClamAV on apache.org Hi, I have done a first fix. Wait some time until it will be available at the bottom of https://repository.apache.org/content/groups/snapshots/org/apache/pdfbox/pdfbox-app/1.8.10-SNAPSHOT/ and tell me if it works, or what "bad things" happen. Btw I still like to have a workable version of your test code. (I'm lazy, last time I added all the spaces myself) Tilman Am 01.04.2015 um 20:22 schrieb Tilman Hausherr: > Hi, > > There's obviously a bug in the initialization without parameters. The > array should be filled more / or the set method should fill what is > needed. I'll investigate and fix this and come back to you. > > Btw, your test code, could you please post it again and so that the > space between "new" and the rest is there? It is missing. Maybe it is > a tab? > > Tilman > > > Am 01.04.2015 um 20:02 schrieb Floris: >> Hallo there, >> >> I am trying to define a Separation color space but get the following >> error message if I try to run the program posted beneath. The error >> seems to be quite local; coming only from the setAlternateColorSpace. >> What is going on here? I am using >> org.apache.pdfbox:pdfbox:app-1.8.10-20150327.210556-4 (in this >> version DeviceN is working) and java version 1.8.0_40-ea. >> >> Have a nice day, >> Floris >> >> Error: >> Exception in thread "main" java.lang.IndexOutOfBoundsException: >> Index: 2, Size: 2 >> at java.util.ArrayList.rangeCheck(ArrayList.java:653) >> at java.util.ArrayList.set(ArrayList.java:444) >> at org.apache.pdfbox.cos.COSArray.set(COSArray.java:148) >> at >> org.apache.pdfbox.pdmodel.graphics.color.PDSeparation.setAlternateColorSpace(PDSeparation.java:182) >> at >> com.here.devicentest.DeviceNTest.WriteSeprationPDF(DeviceNTest.java:463) >> at com.here.devicentest.DeviceNTest.main(DeviceNTest.java:43) >> >> Program: >> >> packagecom.here.devicentest; >> >> importorg.apache.pdfbox.cos.*; >> importorg.apache.pdfbox.exceptions.COSVisitorException; >> importorg.apache.pdfbox.io.RandomAccessBuffer; >> importorg.apache.pdfbox.pdmodel.PDDocument; >> importorg.apache.pdfbox.pdmodel.PDPage; >> importorg.apache.pdfbox.pdmodel.PDResources; >> importorg.apache.pdfbox.pdmodel.common.PDRectangle; >> importorg.apache.pdfbox.pdmodel.common.function.PDFunctionType4; >> importorg.apache.pdfbox.pdmodel.edit.PDPageContentStream; >> importorg.apache.pdfbox.pdmodel.font.PDFont; >> importorg.apache.pdfbox.pdmodel.font.PDType1Font; >> importorg.apache.pdfbox.pdmodel.graphics.color.*; >> >> importjava.io.IOException; >> importjava.io.OutputStream; >> importjava.lang.String; >> importjava.lang.System; >> importjava.util.ArrayList; >> importjava.util.Arrays; >> importjava.util.HashMap; >> importjava.util.Map; >> >> public classDeviceNTest { >> >> public static voidmain(String[] args) { >> >> try{ >> WriteSeprationPDF("SeparationColorTest.pdf"); >> System.out.println("Done Writing!"); >> >> }catch(IOException e) { >> e.printStackTrace(); >> }catch(COSVisitorException e) { >> e.printStackTrace(); >> } >> >> } >> >> public static voidWriteSeprationPDF(String >> filename)throwsIOException, COSVisitorException { >> >> // Construct the PDF document >> PDDocument doc =newPDDocument(); >> >> // Construct the only page. >> PDPage pdpage =newPDPage(); >> >> // Specify the media box. >> PDRectangle mediabox =newPDRectangle(50,50); >> pdpage.setMediaBox( mediabox ); >> >> // Specify the fonts. >> PDFont currentfont = PDType1Font.HELVETICA; >> >> // Specify the color spaces. >> Map colorspaces =newHashMap> PDColorSpace>(); >> >> // Specify DeviceGray for text. >> PDColorSpace cs1 =newPDDeviceGray(); >> >> // Add the color sapce to the color space map. >> colorspaces.put("Cs1", cs1); >> >> /* >> Construct Separation Space >> */ >> PDSeparation cs3 =newPDSeparation(); >> cs3.setColorantName("MYCOLORNAME"); >> cs3.setAlternateColorSpace(PDDeviceCMYK.INSTANCE); >> >> // - Tint Transform >> /* >> Function Type 4 >> - Domain >> - Range >> - Length >> - Type >> - Stream (containing the PS code). >> */ >> // - Domain >> COSArray domains3 =newCOSArray(); >> domains3.setFloatArray(new float[]{0,1}); >> >> // - Range >> COSArray ranges3 =newCOSArray(); >> ranges3.setFloatArray(new >> float[]{0.0f,1.0f,0.0f,1.0f,0.0f,1.0f,0.0f,1.0f}); >> >> // - Dictionary >> COSDictionary functiondata3 =newCOSDictionary(); >> >> functiondata3.setItem(COSName.FUNCTION_TYPE, COSInteger.get(4)); >> functiondata3.setItem(COSName.DOMAIN, domains3); >> functiondata3.setItem(COSName.RANGE, ranges3); >> functiondata3.setItem(COSName.TYPE, COSName.FUNCTION); >> >> // - Stream >> String functionText3 ="{dup dup dup}"; >> >> COSStream functionStream3 >> =newCOSStream(functiondata3,newRandomAccessBuffer()); >> OutputStream out3 = functionStream3.createUnfilteredStream(); >> out3.write(functionText3.getBytes("US-ASCII")); >> out3.close(); >> >> // Construct the tint transform function. >> PDFunctionType4 tinttransformfunction3 = (PDFunctionType4) >> PDFunctionType4.create(functionStream3); >> >> // Add it to the color space. >> cs3.setTintTransform(tinttransformfunction3); >> >> colorspaces.put("Cs3", cs3); >> >> // Add the color space map to the page resources. >> PDResources res =newPDResources(); >> pdpage.setResources(res); >> pdpage.getResources().setColorSpaces(colorspaces); >> >> // Add the page to the document. >> doc.addPage( pdpage ); >> >> >> // Specify the page (pdpage) contents of the PDF file (doc). >> PDPageContentStream contentStream >> =newPDPageContentStream(doc, pdpage,false,false); >> >> /* >> Add a rectangle to the page. >> */ >> // Set color space >> contentStream.setNonStrokingColorSpace(cs3); >> contentStream.setNonStrokingColor(1); >> contentStream.fillRect(10,10,20,20); >> >> /* >> Add some text (Hello World) to the page. >> */ >> contentStream.beginText(); >> contentStream.moveTextPositionByAmount(10,10); >> >> contentStream.setNonStrokingColorSpace(cs1); >> contentStream.setFont(currentfont,16); >> contentStream.setStrokingColor(0.9); >> contentStream.drawString("Hello World!"); >> contentStream.endText(); >> >> // Close the stream. >> contentStream.close(); >> >> // Finally save the document. >> doc.save( filename ); >> >> // Close the document. >> if( doc !=null) { >> try{ >> doc.close(); >> }catch(IOException e) { >> e.printStackTrace(); >> } >> } >> } >> } >> >> >> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org > For additional commands, e-mail: users-help@pdfbox.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org For additional commands, e-mail: users-help@pdfbox.apache.org