hi,
in the gnu.jpdf.PDFGraphics class there are the
methods to print images drawImage(....)
public boolean drawImage(Image img,int x,int y,int
w,int h,ImageObserver obs) {
closeBlock();
PDFImage image = new PDFImage(img,x,y,w,h,obs);
page.getPDFDocument().setImageName(image);
page.getPDFDocument().add(image);
page.addToProcset("/ImageC");
page.addResource("/XObject << " + image.getName()
+ " " + image.getSerialID() + " 0 R >>");
..........
}
works fine, as long as you only print one image on a
page, but if you add a 2nd one the /XObject Image2
could not be found when trying to read the document
the problem imo is that the produced code in the pdf
file isn't correct:
/ProcSet 7 0 R /XObject << /Image1 9 0 R >> /XObject
<< /Image2 10 0 R >>
should be:
/ProcSet 7 0 R /XObject << /Image1 9 0 R /Image2 10 0
R >>
would be great if you could have a look at this
easy
Logged In: YES
user_id=294682
I have submitted a patch that fixes this problem.
Logged In: NO
I encountered the same problem. Hopefully it could be fixed
quite
easily:
in PDFGraphcis.drawImage, replaced:
page.addResource("/XObject << " + image.getName() + " " +
image.getSerialID() + " 0 R >>");
by
page.addImageResource(image.getName() + " " +
image.getSerialID() +
" 0 R");
in PDFPage class:
added attribute: protected Vector imageResources;
initialized in PDFPage() constructor:
imageResources = new Vector();
added metod:
public void addImageResource(String resource) {
imageResources.addElement(resource);
}
in PDFPage.write, added:
// Any other resources
for(Enumeration
en=resources.elements();en.hasMoreElements();) {
String str = en.nextElement().toString();
os.write(str.getBytes());
os.write(" ".getBytes());
}
// ADDED THIS BLOC OF CODE HERE:
if(imageResources.size() > 0) {
os.write("/XObject << ".getBytes());
for(Enumeration
en=imageResources.elements();en.hasMoreElements();) {
String str = en.nextElement().toString();
os.write(str.getBytes());
os.write(" ".getBytes());
}
os.write(" >> ".getBytes());
}
os.write(">>\n".getBytes());
// The thumbnail
...