Hello,
I am having problems getting the Image object to work correctly.
I have this code:
objPage.getElements().add(new Image("image.gif", 0, 0, 0.24f));
But it will not compile.
I tried importing:
import com.cete.dynamicpdf.pageelements.Image;
But this will not compile either.
Images
Re: Images
Support · Dec 6, 2005Hello,
Can you tell us what error or stack trace are you getting when trying to compile your code?
Thanks,
ceTe Software Support Team
Re: Images
Forum member · Dec 6, 2005Here is my whole class along with the errors in comments:
package quester.testing;
import com.cete.dynamicpdf.Document;
import com.cete.dynamicpdf.Page;
import com.cete.dynamicpdf.PageOrientation;
import com.cete.dynamicpdf.PageSize;
import com.cete.dynamicpdf.pageelements.Image;
// error
// import com.cete.dynamicpdf.pageelements.Image conflicts with a type defined in the same file
public class Image {
public static void main(String args[]) {
Document objDocument = new Document();
objDocument.setCreator("HelloWorld.java");
objDocument.setAuthor("Your Name");
objDocument.setTitle("Hello World");
Page objPage = new Page(PageSize.LETTER, PageOrientation.PORTRAIT, 28.0f);
objDocument.getPages().add(objPage);
objPage.getElements().add(new Image("image.gif", 0, 0, 0.24f));
// error
// Multiple makers at this line
// - The method add(PageElement) in the type Group is not applicatible for the arguments (Image)
// - The constructor Image(String, int, int, float) is undefined
objDocument.draw("F:\\workspace.3.1\\dynamicpdf\\webApplication\\pdfs\\HelloWorld.pdf");
}
}
Re: Images
Support · Dec 6, 2005Hello,
The reason you are getting the error is because the class name you are using is Image and it is conflicting with the Image page element. It is searching for an overloaded Image constructor within the defined Image class resulting in the error. Change your class name to something else and that will fix your problem.
Thanks,
ceTe Software Support Team
Re: Images
Forum member · Dec 6, 2005Duh on my part. I totally overlooked that.
Thanks!
Nice work on this package. I have reviewed several Java APIs for creating PDFs and this one is by far the best.