Yeah, I read all those unresolved old posts before I decided to start a new one. I was hoping that, by now, someone has come up with a hack or something. BTW I have tried both SVG libraries and they didn't work at all. I got many errors like other people.
You mentioned iText so I did some investigating. The pdf library is apparently a wrapper for iText. The itext.jar file is together with the pdf.jar file in C:\Program Files\Image\processing-2.0b7\modes\java\libraries\pdf\library\. I hacked together some java code to reproduce the same scenario using pure itext code.
The results are surprising and alarming.
The resolution is 180 ppi as in the first example above, BUT the transparency is honored, which is the DEFAULT for PNG in iText PDFs. Same PDF version of 1.4. The transparency shows up in preflight analysis. I don't know what the red X means other than some error, but it may not be good for the service provider. I don't know. But it looks great! I'm getting "high" resolution AND transparency. So now my question is, if this is the default behavior of iText, why isn't it being implemented in the library. I was careful to use the Processing itext.jar, in the directory listed above, directly, to level the playing field, so-to-speak. It is an older version. You will notice that I set the resolution directly with scalePercent so I would get exactly 180 ppi. image.scaleAbsolute(document.getPageSize().getWidth()/4, document.getPageSize().getHeight()/4) gave me like 178.749 ppi. :)
I know people have been able to incorporate calls to iText functions in their .PDE files but I don't know how to mix code like that. Maybe someone here does know and can give an example of how you could make a call to one of the image scale functions from my original script and put the image into the PDF using iText's image function.
You mentioned iText so I did some investigating. The pdf library is apparently a wrapper for iText. The itext.jar file is together with the pdf.jar file in C:\Program Files\Image\processing-2.0b7\modes\java\libraries\pdf\library\. I hacked together some java code to reproduce the same scenario using pure itext code.
- import java.awt.Color;
- import java.io.*;
- import com.lowagie.text.*;
- import com.lowagie.text.pdf.*;
- public class imagesPDF
- {
- public static void main(String arg[])throws Exception
- {
- Rectangle pageRect = new Rectangle (580, 580);
- pageRect.setBackgroundColor(new Color(0x00, 0x00, 0x00));
- Document document = new Document(pageRect);
- PdfWriter.getInstance(document,new FileOutputStream("imagePDF.pdf"));
- document.open();
- Image image = Image.getInstance ("moon.0096_cr.png");
- int ppi = 180;
- image.scalePercent(100*72/ppi);
- //image.scaleAbsolute(document.getPageSize().getWidth()/4, document.getPageSize().getHeight()/4);
- image.setAbsolutePosition(document.getPageSize().getWidth()/2 - image.getScaledWidth()/2, document.getPageSize().getHeight()/2 - image.getScaledHeight()/2);
- document.add(image);
- document.close();
- }
- }
The results are surprising and alarming.
The resolution is 180 ppi as in the first example above, BUT the transparency is honored, which is the DEFAULT for PNG in iText PDFs. Same PDF version of 1.4. The transparency shows up in preflight analysis. I don't know what the red X means other than some error, but it may not be good for the service provider. I don't know. But it looks great! I'm getting "high" resolution AND transparency. So now my question is, if this is the default behavior of iText, why isn't it being implemented in the library. I was careful to use the Processing itext.jar, in the directory listed above, directly, to level the playing field, so-to-speak. It is an older version. You will notice that I set the resolution directly with scalePercent so I would get exactly 180 ppi. image.scaleAbsolute(document.getPageSize().getWidth()/4, document.getPageSize().getHeight()/4) gave me like 178.749 ppi. :)
I know people have been able to incorporate calls to iText functions in their .PDE files but I don't know how to mix code like that. Maybe someone here does know and can give an example of how you could make a call to one of the image scale functions from my original script and put the image into the PDF using iText's image function.