The problem you're describing is a Java error, nothing to do with iText. 

The error message contains the info you need. If you pass 8.1 to a function,
Java treats it as a double. Change it to 8.1f to make it a float. The
problem should go away.

(If you review data types in Java, you'll be able to figure out why the
integer worked.)

---mr. bean


Stepan RYBAR wrote:
> 
> Hello,
> 
> yes, You are right, that in JavaDoc is float and not int, but when I use
> following code:
> 
> over.showTextAligned(Element.ALIGN_LEFT, omr, 8.1, 666, 90);
> 
> I receive following error during compilation:
> 
> C:\temp\Apache FOP User Data>"C:\Program Files\Java\jdk1.6.0_10\bin\javac"
> -cp "
> iText-2.1.4.jar" AddPageNumbersToExistingPageNumberPDF.java
> AddPageNumbersToExistingPageNumberPDF.java:121: cannot find symbol
> symbol  : method showTextAligned(int,java.lang.String,double,int,int)
> location: class com.lowagie.text.pdf.PdfContentByte
>         over.showTextAligned(Element.ALIGN_LEFT, omr, 8.1, 666, 90);
>             ^
> 1 error
> 
> while when I use integer value:
> 
> over.showTextAligned(Element.ALIGN_LEFT, omr, 8, 666, 90);
> 
> compilation and running is OK. I am using Sun Java SDK 1.6.0_10 64bit
> version on MS Windows Vista Enterprise 64bit EN with Czech regional
> settings. You can see my whole simple Java code in attachment. There is
> still chance, that I can make some fatal mistake in my Java code, but I
> hope not so.
> 
> Stepan
> 
>> ------------ Původní zpráva ------------
>> Od: mister bean <abinstock@>
>> Předmět: Re: [iText-questions] FOP 0.95 and iText 2.1.3 unable to do
>> exact
>> overprint
>> Datum: 13.11.2008 08:07:16
>> ----------------------------------------
>>
>> Not sure if this is the answer, but I don't understand why you say that
>> the
>> showTextAligned() uses integers. In fact, it uses floating-point values.
>> See
>> the Javadoc
>> http://1t3xt.info/api/com/lowagie/text/pdf/PdfContentByte.html#showTextAligned(int,%20java.lang.String,%20float,%20float,%20float,%20boolean)
>>
>> Likewise, setFontAndSize() takes a floating-point value. Again, look at
>> the
>> JavaDoc.
>>
>> I suspect that you can tweak the values to fit perfectly.
>>
>> ---mr. bean
>>
> 
> import java.io.FileOutputStream;
> 
> import com.lowagie.text.Element;
> import com.lowagie.text.pdf.BaseFont;
> import com.lowagie.text.pdf.PdfContentByte;
> import com.lowagie.text.pdf.PdfReader;
> import com.lowagie.text.pdf.PdfStamper;
> 
> public class AddPageNumbersToExistingPageNumberPDF {
>   public static void main(String[] args) {
>     try {
>       PdfReader reader = new PdfReader(args[0]);
>       int n = reader.getNumberOfPages();
>       //System.out.println(n);
> 
>       PdfStamper stamp = new PdfStamper(reader, new
> FileOutputStream(args[1]));
>       int i = 0;
>       String omr = new String();
>       PdfContentByte over;
>       BaseFont bf = BaseFont.createFont("C:\\Program Files\\Apache FOP
> 0.95\\fonts\\cour.ttf", BaseFont.WINANSI, BaseFont.EMBEDDED);
>       while (i < n) {
>         i++;
>         over = stamp.getOverContent(i);
>         over.beginText();
>         over.setFontAndSize(bf, 10);
>         switch (((i - 1) % 31) + 1) {
>           case 1: 
>             omr = "10000"; 
>             break; 
>           case 2: 
>             omr = "01000"; 
>             break; 
>           case 3: 
>             omr = "111000"; 
>             break; 
>           case 4: 
>             omr = "00100"; 
>             break; 
>           case 5: 
>             omr = "110100"; 
>             break; 
>           case 6: 
>             omr = "101100"; 
>             break; 
>           case 7: 
>             omr = "11100"; 
>             break; 
>           case 8: 
>             omr = "00010"; 
>             break; 
>           case 9: 
>             omr = "110010"; 
>             break; 
>           case 10: 
>             omr = "101010"; 
>             break; 
>           case 11: 
>             omr = "11010"; 
>             break; 
>           case 12: 
>             omr = "100110"; 
>             break; 
>           case 13: 
>             omr = "10110"; 
>             break; 
>           case 14: 
>             omr = "01110"; 
>             break; 
>           case 15: 
>             omr = "111110"; 
>             break; 
>           case 16: 
>             omr = "00001"; 
>             break; 
>           case 17: 
>             omr = "110001"; 
>             break; 
>           case 18: 
>             omr = "101001"; 
>             break; 
>           case 19: 
>             omr = "11001"; 
>             break; 
>           case 20: 
>             omr = "101001"; 
>             break; 
>           case 21: 
>             omr = "10101"; 
>             break; 
>           case 22: 
>             omr = "01101"; 
>             break; 
>           case 23: 
>             omr = "111101"; 
>             break; 
>           case 24: 
>             omr = "100011"; 
>             break; 
>           case 25: 
>             omr = "10011"; 
>             break; 
>           case 26: 
>             omr = "01011"; 
>             break; 
>           case 27: 
>             omr = "111011"; 
>             break; 
>           case 28: 
>             omr = "00111"; 
>             break; 
>           case 29: 
>             omr = "110111"; 
>             break; 
>           case 30: 
>             omr = "101111"; 
>             break; 
>           case 31: 
>             omr = "11111"; 
>             break; 
>         }
>         over.showTextAligned(Element.ALIGN_LEFT, omr, 8.1, 666, 90);
>         over.endText();
>       }
>       stamp.close();
> 
>     } catch (Exception de) {
>       de.printStackTrace();
>     }
>   }
> }
> C:\temp\Apache FOP User Data>"C:\Program Files\Java\jdk1.6.0_10\bin\javac"
> -cp "
> iText-2.1.4.jar" AddPageNumbersToExistingPageNumberPDF.java
> AddPageNumbersToExistingPageNumberPDF.java:121: cannot find symbol
> symbol  : method showTextAligned(int,java.lang.String,double,int,int)
> location: class com.lowagie.text.pdf.PdfContentByte
>         over.showTextAligned(Element.ALIGN_LEFT, omr, 8.1, 666, 90);
>             ^
> 1 error
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the
> world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> iText-questions mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/itext-questions
> 
> Buy the iText book: http://www.1t3xt.com/docs/book.php
> 

-- 
View this message in context: 
http://www.nabble.com/FOP-0.95-and-iText-2.1.3-unable-to-do-exact-overprint-tp20458311p20486273.html
Sent from the iText - General mailing list archive at Nabble.com.


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php

Reply via email to