Quantcast
Channel: Processing Forum
Viewing all 1768 articles
Browse latest View live

Re : Transparency and resolution problems with exported PDF


Re : pfd export a specific area / box

$
0
0
hey andreas! thanks for your reply, it's almost the thing i want! but, is it possible just to get the maxtrix grid as a pdf, without the space (where actually controlP5 was)? one way would be 2 windows, 1 for controlls and 1 for the matrix, but this solution would be windowed only right? the goal would be a fullscreen app

Re : No font in exported PDF

$
0
0
No incantation but it only works when the
moon (is) of the same shape and season as the day when they were written
LOL. Try the code above, the second one. The only difference is I commented out the ellipse this time and I substituted for the font
  1.     f  =  createFont("../../fonts/tngani.ttf",  40);
I downloaded this font from TTFonts (one of those). Did you try the PDF? Did it look the same?

Re : No font in exported PDF

$
0
0
That's what I tried... (except I just put the TTF font in the data folder).

Aha, looking at my sketch, I see I made a beginner's error: I had the textFont() call before the beginRecord()! Moving it after do render the font in the file.
Sorry for the confusion. Glad you solved the problem yourself.

Error opengl without using opengl?

$
0
0
I use Processing: Version 2.0b7

I have always this error:
OpenGL error 1280 at bot beginDraw(): invalid enumerant

this is my simple code:

void setup() {
size(400, 300, P3D);
}

Can you help me please?
thank you.

Java Error in processing Mac OS X 10.7.5

$
0
0
Hello, 

I'm trying to interface with an Ardunio using the serial library and am getting this error

RXTX Warning:  Removing stale lock file. /var/lock/LK.032.018.004
gnu.io.PortInUseException: Unknown Application
at gnu.io.CommPortIdentifier.open(CommPortIdentifier.java:354)
at processing.serial.Serial.<init>(Unknown Source)
at processing.serial.Serial.<init>(Unknown Source)
at RotatingArcs.setup(RotatingArcs.java:29)
at processing.core.PApplet.handleDraw(PApplet.java:2117)
at processing.core.PGraphicsJava2D.requestDraw(PGraphicsJava2D.java:193)
at processing.core.PApplet.run(PApplet.java:2020)
at java.lang.Thread.run(Thread.java:680)
Exception in thread "Animation Thread" java.lang.RuntimeException: Error inside Serial.<init>()
at processing.serial.Serial.errorMessage(Unknown Source)
at processing.serial.Serial.<init>(Unknown Source)
at processing.serial.Serial.<init>(Unknown Source)
at RotatingArcs.setup(RotatingArcs.java:29)
at processing.core.PApplet.handleDraw(PApplet.java:2117)
at processing.core.PGraphicsJava2D.requestDraw(PGraphicsJava2D.java:193)
at processing.core.PApplet.run(PApplet.java:2020)
at java.lang.Thread.run(Thread.java:680)

I've tried Ellen's solution listed below, not luck. Any suggestions? 


Thanks!


PDF export / preserving ability to edit text

$
0
0
Hello,
I'm trying to export PDF while preserving ability to edit text – fonts should not be converted to shapes! According to docs it should work with createFont() but unfortunately I just can't seem to get it working :-(. Here is very simple example. I've tried it in 2.0b7 and 1.51. I would appreciate any help. Thanx.

  1. import processing.pdf.*;
  2. PFont f;

  3. void setup() 
  4. {
  5.   size(200, 200, PDF,"output.pdf");
  6.   background(100);
  7.   f = createFont("FreeSans.ttf",30);
  8.   textFont(f,30); 
  9. }

  10. void draw() {
  11.   fill(0);
  12.   text("Hello", 30, 60);
  13.   exit();
  14. }

Re : PDF export / preserving ability to edit text

$
0
0
Put this right after the size() call in setup():
  1.   textMode(MODEL);


Re : PDF export / preserving ability to edit text

$
0
0
Unfortunately this doesnt work, I've already tried it. In the example above I get error. While in examples that use beginRecord() / endRecord() I don't get error but pdf with font again converted to shapes :-(

  1. Exception in thread "Animation Thread" java.lang.RuntimeException: Use textMode(SHAPE) with PDF when loading .ttf and .otf files with createFont().
  2. at processing.pdf.PGraphicsPDF.checkFont(Unknown Source)
  3. at processing.pdf.PGraphicsPDF.textFont(Unknown Source)
  4. at processing.core.PGraphics.textFont(PGraphics.java:3973)
  5. at processing.core.PApplet.textFont(PApplet.java:12137)
  6. at pdf_font_export_test.setup(pdf_font_export_test.java:27)
  7. at processing.core.PApplet.handleDraw(PApplet.java:2117)
  8. at processing.core.PGraphicsJava2D.requestDraw(PGraphicsJava2D.java:193)
  9. at processing.core.PApplet.run(PApplet.java:2020)
  10. at java.lang.Thread.run(Thread.java:662)


Re : PDF export / preserving ability to edit text

$
0
0
It works for me in Processing 1.5.1 and 2.0b7 on WinXP. The problem may be your font.

I can select the text in Adobe Reader and also edit it in Adobe Illustrator CS6.

Adapted Code
  1. import processing.pdf.*;
  2.  
  3. void setup() {
  4.   size(200, 200, PDF, "output.pdf");
  5.   textMode(MODEL);
  6.   background(100);
  7.   textFont(createFont("Arial", 30), 30);
  8. }
  9.  
  10. void draw() {
  11.   fill(0);
  12.   text("Hello", 30, 60);
  13.   exit();
  14. }

Re : PDF export / preserving ability to edit text

$
0
0
Thanx Amnon!

You were right, that the problem was in font. I'm sure I've also tested with Arial, but I've probably made some other mistake at the same time.

Other example – one using begin/endRecord had additional problem. It seems like its very sensitive to the order they run in setup. This should be better documented. Order that finaly works for me is this:

/ setup /
1. size()
2. beginRecord()   <--- this had to go before textMode
3. textMode(MODEL)
4. textFont() / createFont()

/ draw /
5. text()
6. endRecord()


Re : Error opengl without using opengl?

$
0
0
P2D and P3D use OpenGL in Processing 2.0...

Re : Error opengl without using opengl?

$
0
0
Thank you.

I'm trying to develop an augmented reality app with my Dell inspiron 6400 notebook with an ATI Mobitlity Radeon X1300 graphic card

How can I solve this problem?

Re : Error opengl without using opengl?

$
0
0
Try updating your graphics drivers.

Re : Transparency and resolution problems with exported PDF

$
0
0
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.

  1. import java.awt.Color;
  2. import java.io.*;
  3. import com.lowagie.text.*;
  4. import com.lowagie.text.pdf.*;
  5. public class imagesPDF
  6. {
  7.     public static void main(String arg[])throws Exception
  8.         {                 
  9.          Rectangle pageRect = new Rectangle (580, 580);
  10.          pageRect.setBackgroundColor(new Color(0x00, 0x00, 0x00));
  11.          Document document = new Document(pageRect);
  12.          PdfWriter.getInstance(document,new FileOutputStream("imagePDF.pdf"));
  13.          document.open();
  14.          Image image = Image.getInstance ("moon.0096_cr.png");
  15.          int ppi = 180;
  16.          image.scalePercent(100*72/ppi);
  17.          //image.scaleAbsolute(document.getPageSize().getWidth()/4, document.getPageSize().getHeight()/4);
  18.          image.setAbsolutePosition(document.getPageSize().getWidth()/2 - image.getScaledWidth()/2, document.getPageSize().getHeight()/2 - image.getScaledHeight()/2);
  19.          document.add(image);
  20.          document.close();
  21.     }
  22. }

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.


Re : Transparency and resolution problems with exported PDF

$
0
0
"I have tried both SVG libraries"
Which ones?
Since I made one (a third one?), I am interested to have feedback.

"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 didn't know Preflight, so I went to their site, and they warn:
"Although transparency is now a widely accepted functionality within most design and page layout applications many printing companies are still wary of PDF files containing transparency and like to give them specific attention to ensure they are processed and imaged correctly. "

I suppose you use transparency, not to print, but to load the PDF in some vector drawing application, so it should be OK.

The problem is that iText, like Batik and similar libraries, can work in two modes: the native library mode, like the one you used above in the pure Java program, and the Java2D mode, where the library overrides AWT's Graphics2D, thus transforming regular AWT drawing calls to drawing instructions for the targeted output.
The latter is great for developers that have already Java2D drawings, as they can just make a thin wrapper around the library and redirect the drawings to it. That's what I made with my P8gGraphicsSVG library, inspired by the way PGraphicsPDF is done: if you look at its source, you will find it is quite small!

The downside is that this Java2D mode offers less flexibility overall, and has some limitations.
One of them is handling of fonts (you have to give the path to the font file to be able to use it), another seems to be transparency handling...

If your third attempt is almost OK with only the resolution issue, you can try and draw on a much bigger PGraphics, no?

"I don't know why 72ppi would be the default. It is ridiculously low even for a small-screen monitor."
72 dpi was the standard resolution of CRT monitors not so long ago...
I think it is the default of iText, unless otherwise specified.

Perhaps you can take the PGraphicsPDF as a start, and hack it to get the intended result: make a library out of it (compile and put the .class file in a jar) or just add the .java file to you sketch. Thus, you can add anything you might need.

The type Table is ambiguous

$
0
0
Hey all,

I'm trying to use geoMap library, but they have their own Table class, that conflicts with Processing's Table class.

So when I use Table I get this message:

  1. The type Table is ambiguous

I want to know how can I not import Processing's Table class.

Thanks!

Re : The type Table is ambiguous

$
0
0
something like

geoMap.Table table = new geoMap.Table(whatever);

is possible.

Re : Transparency and resolution problems with exported PDF

$
0
0

"I have tried both SVG libraries"

Which ones?

Since I made one (a third one?), I am interested to have feedback.

I tried prosvg and the PDE couldn’t find the library even though it was in the libraries folder with the other libraries. I tried P8gGraphicsSVG but none of the examples worked so I gave up. I don’t really want SVG output anyway.

"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 didn't know Preflight, so I went to their site, and they warn:

"Although transparency is now a widely accepted functionality within most design and page layout applications many printing companies are still wary of PDF files containing transparency and like to give them specific attention to ensure they are processed and imaged correctly. "

I suppose you use transparency, not to print, but to load the PDF in some vector drawing application, so it should be OK.

I tried fixing the problem in Acrobat and all it did was flatten the image (removed the transparency) and changed the entire background to dark gray. Bogus. And this is probably what a service provider is going to do too. I read that Adobe has a 100-page treatise about transparency in PDFs so I guess it’s not as easy as you might imagine. I mentioned in my other post, about fonts, that I intend to send this to a service provider, or actually to a local (cheap) photo printer like Costco. Their prices are great but I don’t know about quality. In any case I want the PDF to be perfect because they will not provide any personal service or expertise, I’m sure.

The latter is great for developers that have already Java2D drawings, as they can just make a thin wrapper around the library and redirect the drawings to it. That's what I made with my P8gGraphicsSVG library, inspired by the way PGraphicsPDF is done: if you look at its source, you will find it is quite small!

The downside is that this Java2D mode offers less flexibility overall, and has some limitations.

One of them is handling of fonts (you have to give the path to the font file to be able to use it), another seems to be transparency handling...

I’ll take a look but that transparency limitation would kill it for me.

If your third attempt is almost OK with only the resolution issue, you can try and draw on a much bigger PGraphics, no?

Well yeah, but it is not optimal. I plan to add different scalable fonts and vector graphics so it seems a real pain to have to worry about scaling everything to fit the large bitmap. Maybe not but I’d really like to be able to add some code and get the full functionality of iText, which BTW is quite sophisticated.

"I don't know why 72ppi would be the default. It is ridiculously low even for a small-screen monitor."

72 dpi was the standard resolution of CRT monitors not so long ago...

I think it is the default of iText, unless otherwise specified.

Not so long ago? You mean 15-20 years is ‘not so long ago’? In terms of Moore’s law it is comparable to the Middle Ages of computing. Yes, iText defaults, sadly, to 72 ppi. That’s why they provide scaling functions, which are obviously being ignored by the PDF library.

Perhaps you can take the PGraphicsPDF as a start, and hack it to get the intended result: make a library out of it (compile and put the .class file in a jar) or just add the .java file to you sketch. Thus, you can add anything you might need.

That’s the last thing I want to do. I might as well use iText directly rather than hack the library. How would you add a java file to my sketch above and access the iText functions using data from Processing as much as possible? That would be very helpful. I can’t find enough about doing that online. I’m not an experienced java programmer, though I write various scripting code all the time and do have experience with C++. I am using eclipse for both Processing and iText, so that helps a lot.

 

Re : The type Table is ambiguous

$
0
0
Thanks clankill3r!

I tried several ways, this was the one that worked:

  1. org.gicentre.geomap.Table tab = new org.gicentre.geomap.Table("data.tsv", this);

Viewing all 1768 articles
Browse latest View live