[Gtk-sharp-list] Rendering PDF Documents

Rampage atomikramp at email.it
Wed Sep 8 12:42:03 EDT 2010

Adam Tauno Williams ha scritto:
> On Wed, 2010-09-08 at 00:35 -0700, Rampage wrote:
>> Adam Tauno Williams-3 wrote:
>>> Well, a bit-o-binging led me to 
>>> <http://git.gnome.org/browse/pdfmod/tree/src/PdfMod/Pdf/Document.cs>
>>> which is a source file for the *very* nice PDFMod application.  Which
>>> displays and slice-and-dices PDF files.  It seems to use PdfSharp
>>> <http://sourceforge.net/projects/pdfsharp/> and poppler.
>> yesterday by playing around and on a trial and error basis i've managed do
>> somehow accomplish my task using Poppler-sharp + Cairo in a drawingarea.
> Sounds like a great topic for a BLOG post!  Then there would at least be
> something for Bing to find for the next guy or gal.
>> my main problem now is that if the page/picture rendered is bigger than the
>> area i have the view of (due to video resolution) i can't scroll.
>> i've tried putting the drawingarea into a scrolledwindow container, but with
>> no luck.
> Do the scroll bars appear?  If they appear are they at maximum as though
> the entire area is already visible?
>> i'm trying to build a simple widget so for now i'm not interested in
>> scrolling the pdf pages, i'll use a toolbar with back and forward buttons to
>> trigger the rendering of a specified page number.
>> the problem is, as i said above, that the whole page is rendered but can't
>> be scrolled.
>> any kind of hint is really welcome.
> _______________________________________________
> Gtk-sharp-list maillist  -  Gtk-sharp-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
Sorry for the bad quoting but i'm a bit in a hurry.
i want to share my snipplet with you in the hope that someone may find 
it usefull or somother one may submit me some suggestions.

at the moment the widget renders only the first page of a pdf using 
poppler-sharp bindings + cairo.
it's really basic, no zoom features nothing of nothing, just take the 
first page and render it into a drawingarea.

        protected virtual void OnDrawingarea1ExposeEvent (object o, 
Gtk.ExposeEventArgs args)
            double x;
            double y;

            Gtk.DrawingArea area = (Gtk.DrawingArea)o;
            Cairo.Context context = 

            Poppler.Document doc = 
Poppler.Document.NewFromFile("file:/path/to/file.pdf", null);
            Poppler.Page page = doc.GetPage(0);
            page.GetSize(out x, out y);

            area.SetSizeRequest((int)x, (int)y);


i would really like to be able to render a whole pdf by scrolling all 
the pages, but i dunno how..
i hope i'll find some c++ example to translate to c#.

More information about the Gtk-sharp-list mailing list