show / view PDF's with openFrameworks

Someone know if it’s possible open / read / show PDF’s in a openFrameworks application??

Thanks to all!!

Roger

i also wanna know.

we’re looking to hookup libharu for pdf output - http://libharu.org/wiki/Main-Page
input would be great too!

I was successful opening pdf files as if they were Quicktime .mov files, using OF’s movie object normally. The PDF pages play as if they were parts of the movie file (you can even change the playback speed).

oh wow - thats a great find!
thats crazy that it works!

Theo

:shock: Ya! It works!

greetings ascorbin

I was researching on Internet and only I finded xpdf library but Quicktime solution is really really easy for OF and cross platform

[quote author=“theo”]we’re looking to hookup libharu for pdf output - http://libharu.org/wiki/Main-Page
input would be great too![/quote]

Hey,

are there any working copies of this sourcetree?

sh

Actually we are looking now at cairo instead as it has lots of output options (not just pdf).

Todd has been hooking up ofxCairo which is based on ofxVectorGraphics and is about 90% compatible with the ofxVectorGraphics example.

You can grab ofxCairo here:
http://code.google.com/p/vanderlin/downloads/list

There are a couple of differences between vecGraphics and ofxCairo - mainly in how the setup and save to disk work - but it should do quite a bit for you at this point.

Here is the vec graphics example app modified for ofxCairo - also notes on what is currently not working.

point.[attachment=0:1y55db08]demo.zip[/attachment:1y55db08]

demo.zip

Thank you. Now I can finally draw with alpha values.

Can’t wait to get involved in the development of this.

sh

Thank you for your information

Thank you for sharing

sweet, not only pdf output but also svg, postscript and quartz!
truly awesome effort guys.

have been going through the notes on the cairo site (http://cairographics.org/) and it seems you can only output to those formats but not the other way around.

just wondering if cairo is able to load svg files, render the data and also make it available as a set of points for OF to work with?

this isn’t about input, but I modified todd’s ofxCairo to have another rendering path: pixels, which could be interesting to some people. Here’s a simple drawing tool (drawing lines) in cairo and then uploading it to a texture. I didn’t experiment with caps or joints (thus the funky thick lines), but it’s super to see such smooth graphical output:

http://www.openframeworks.cc/files/bred-…-xelsOF.zip

essentially, this means that you can render smooth lines, polygons, fonts, etc into a pixel array and use it for drawing, computer vision, etc.

some caveats:

a) I set all the alpha to 255 at the moment, as I think I need to do something about premultiplied alpha here. I haven’t really investigated it.
b) there’s an R/B (ie BGR to RGB) switch that needs to be done, and even though I do it with pointer math, it must be slow.

it’s still a work in progress, and I know todd wanted to take some time to think about how to support all the different output paths (to, for example, support both onscreen and vector output), but I was quite happy with the output.

faster then uploading to a texture might be a pbo or some sort of other pixels -> gl operation. I wondered also if calculating a “dirty rectangle” could help with speed.

take care,
zach

PS: I just reread the topic – sorry to hijack this thread which is about input, we should open up another cairo specific thread.

@jalupy, there are a few simple ways to get svg working:

http://forum.openframeworks.cc/t/extract-paths-from-svg-files-to-draw-in-of/1220/0
download/file.php?id=242

nothing as fancy as cairo - and I know also kyle has worked on something similar for our NZ night lights (yesyesno.com/night-lights) project…

![](http://forum.openframeworks.cc/uploads/default/726/Screen shot 2010-05-13 at 5.50.21 AM.png)

I use also the movie player to display pdf files in openFrameworks.
It works nice on the mac, I can even use alpha channel,
but in windows I get the following error message :
OF_ERROR: NewMovieFromFile failded -2048
I have the last quicktime installed on windows.

Somebody has an idea why this happen ?

:? hm ->http://www.openframeworks.cc/files/bred … xelsOF.zip seems to be damaged? it cant be unzipped. Has someone a working example for pixel rendering with cairo ?

greetings ascorbin

:? hm ->http://www.openframeworks.cc/files/bred … xelsOF.zip seems to be damaged? it cant be unzipped. Has someone a working example for pixel rendering with cairo ?

greetings ascorbin

there’s going to be cairo rendering in OF 007, you can check it out from the git version. take a look at devApps/ofPathExample to see how to use it.

hey arturo!
thank you for that! this works and is very useful, but i like to render also images in my pdf not only vector stuff, is this possible ?

greetings ascorbin

i think it’s possible but haven’t tried yet. you have access to the cairo context from the renderer so you can try to directly use cairo to render images. post if you find how : )

ah… ok! i’m nearly there…

  
cairo_t *cr = cairo.getCairoContext();  
	  
	cairo_surface_t *image;  
	int stride = cairo_format_stride_for_width (CAIRO_FORMAT_ARGB32, bild.width);  
	image = cairo_image_surface_create_for_data(bild.getPixels(), CAIRO_FORMAT_ARGB32, bild.width, bild.height, stride);  
	  
	cairo_set_source_surface (cr, image, 0, 0);  
	cairo_paint (cr);  
	cairo_surface_destroy (image);  

so, theres just the bit-order to bring it in alpha, red, green, blue, that should make it, i dont have more time today, so until tomorrow!

greetings