I don't have the constructor ImgPostscript(byte[],int,int).
----- Original Message -----
From: "Carsten Hammer" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Monday, October 17, 2005 10:54 PM
Subject: [iText-questions] PdfTemplate going wild
> Hi,
> does anybody know why I get this exception:
>
> java.lang.ArrayIndexOutOfBoundsException
>
> at java.lang.System.arraycopy(Native Method)
>
> at com.lowagie.text.pdf.ByteBuffer.toByteArray(ByteBuffer.java:538)
>
> at com.lowagie.text.pdf.PdfContentByte.toPdf(PdfContentByte.java:219)
>
> at com.lowagie.text.pdf.PdfFormXObject.<init>(PdfFormXObject.java:98)
>
> at com.lowagie.text.pdf.PdfTemplate.getFormXObject(PdfTemplate.java:218)
>
> at
> com.lowagie.text.pdf.PdfWriter.addSharedObjectsToBody(PdfWriter.java:1170)
>
> at com.lowagie.text.pdf.PdfWriter.close(PdfWriter.java:1234)
>
> at com.lowagie.text.pdf.PdfDocument.close(PdfDocument.java:951)
>
> at com.lowagie.text.Document.close(Document.java:520)
>
> at inlinepostscript.<init>(inlinepostscript.java:85)
>
> at inlinepostscript.main(inlinepostscript.java:96)
>
>
> using the attached code?
>
> For inlinepostscript.java to run I needed the following constructor to
> add to ImgPostscript.java:
>
> public ImgPostscript(byte[] content,float width,float height) throws
> BadElementException, IOException {
> super( (URL)null);
> rawData = content;
> originalData = content;
> processParameters();
> this.urx=width;
> this.ury=height;
> }
>
> Any idea?
>
> Best regards,
> Carsten
>
----------------------------------------------------------------------------
----
> import com.lowagie.text.ImgPostscript;
>
> import java.io.FileOutputStream;
>
> import com.lowagie.text.pdf.*;
> import com.lowagie.text.*;
>
> public class inlinepostscript {
> public inlinepostscript() {
> try {
>
> Document document = new Document();
> PdfWriter pdfwriter = PdfWriter.getInstance(document,
> new FileOutputStream(
> "inlinetest.pdf"));
> document.compress = false;
> document.open();
>
> PdfContentByte cb = pdfwriter.getDirectContentUnder();
> cb.addImage(new ImgPostscript( ("/Helvetica-Bold findfont " +
> "50 scalefont setfont " +
> "/oshow" +
> "{ true charpath stroke } def\n" +
> "/circleofItext" +
> "{ 30 15 345\n" +
> "{ gsave\n" +
> "rotate 0 0 moveto\n" +
> "( itext) oshow\n" +
> "grestore\n" +
> "} for\n" +
> "} def\n" +
> "250 400 translate\n" +
> ".5 setlinewidth\n" +
> "circleofItext\n" +
> "showpage\n").
> getBytes(), 500, 800), 500, 0, 0, 800,
0, 0);
>
> for (int i = 0; i < 30; i++) {
> document.add(new Paragraph("Hello World Hello World Hello
World"));
> }
> document.newPage();
>
> cb = pdfwriter.getDirectContentUnder();
>
> cb.addImage(new ImgPostscript( ("%!PS-Adobe-1.0 \n" +
> "%%DocumentFonts: Courier \n" +
> "%%Title: Random Fern \n" +
> "%%Creator: Eric Wicklund from
algoritm of John Wicklund \n" +
> "%%EndComments \n" +
> "/m1 [ 0.00 0.00 0.00 0.16 0.00
0.00 ] def \n" +
> "/m2 [ 0.85 -0.04 0.04 0.85 0.00
1.60 ] def \n" +
> "/m3 [ 0.20 0.23 -0.26 0.22 0.00
1.60 ] def \n" +
> "/m4 [ -0.15 0.26 0.28 0.24 0.00
0.44 ] def \n" +
> "/inch {72 mul} bind def \n" +
> "%%EndProlog \n" +
> "%%Page: 1 1 \n" +
> "save \n" +
> "% will draw inside a 8 inch square
centered on \n" +
> "% a 8.5 by 11 inch page \n" +
> "4.25 inch 1.5 inch translate \n" +
> "0.8 inch dup scale \n" +
> "% x coordinate ranges from -5 to 5
\n" +
> "% y coordinate ranges from 0 to 10
\n" +
> "1 setlinecap \n" +
> "0.005 setlinewidth \n" +
> "0.36 0.63 0.07 setrgbcolor \n" +
> "% first point at the origin \n" +
> " 0 0 \n" +
> " 100000 { \n" +
> " % Pick a transformation
matrix probabilitistically \n" +
> " rand 100 mod \n" +
> " dup 1 lt { pop m1 } \n" +
> " { dup 86 lt { pop m2 } \n" +
> " { dup 93 lt { pop m3 } \n" +
> " { pop m4 }
ifelse } ifelse } ifelse \n" +
> " transform 2 copy moveto 0 0
rlineto stroke \n" +
> "} repeat \n" +
> "showpage").
> getBytes(), 500, 800), 500, 0, 0, 800,
0, 0);
>
> for (int i = 0; i < 30; i++) {
> document.add(new Paragraph("Hello World Hello World Hello
World"));
> }
>
> document.close();
>
> System.out.println("Finished.");
> }
> catch (Exception de) {
> de.printStackTrace();
> }
>
> }
>
> public static void main(String[] args) {
> inlinepostscript inlinepostscript = new inlinepostscript();
> }
> }
>
-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions