On Wed, Mar 4, 2009 at 4:30 PM, Brian Busch <bdbus...@gmail.com> wrote:

> On Wed, Mar 4, 2009 at 4:09 PM, Antonio Manuel Muñiz <
> amunizmar...@gmail.com> wrote:
>
>> Hello Alexis,
>>
>> The image is not added although it is in my file system. For example:
>>
>> public void imageTest() throws MalformedURLException, IOException,
>> DocumentException {
>>     Document document = new Document(PageSize.A4, 50, 50, 110, 50);
>>     PdfWriter.getInstance(document, new
>> FileOutputStream("image-test.pdf"));
>>     document.open();
>>     URL resource1 =
>> this.getClass().getClassLoader().getResource("sonar-large.png");
>>     Image image1 = Image.getInstance(resource1);
>>     URL resource2 =
>> this.getClass().getClassLoader().getResource("-2-black.png");
>>
>
> Just for testing - change the name so it doesn't start with a '-' (hypen).
> It might be a bad URL even tho it doesn't throw an exception. Weird, but
> easy to test.
>

If this still fails - remember, you're scanning the classpath for a file of
that name - java will stop at the first one it finds - it might be that you
have a file with that same name that is blank or bad image data somewhere
else on your class path that is causing it. i.e., you may have a copy of
this image elsewhere on your classpath.

by renaming the file you should be able to check to see if you have a
duplicate.

if on a unix box, do something like

#!/bin/ksh
for d in $(echo $CLASSPATH | tr ':' ' ')
do
  if [[ -s $d/-2-black.png ]]
  then
    echo found file in $d
  fi
done


Brian
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

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

Reply via email to