Embedded PDF viewer?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Embedded PDF viewer?

Manuel Leuenberger
Hi,

I want to view a PDF within Pharo. I found that Athens has a PDF canvas, but I have no idea how to use it. Is there a way to view a PDF within Pharo, so that I can scroll, zoom, click links etc. in the PDF?

Cheers,
Manuel


Reply | Threaded
Open this post in threaded view
|

Re: Embedded PDF viewer?

Stephane Ducasse-3
Hi manuel

So far I do not know if we have this is Pharo.
I imagine that we would have to build a renderer once we will have the
PDF reader from Christian library.

Stef

On Tue, Oct 10, 2017 at 8:58 PM, Manuel Leuenberger
<[hidden email]> wrote:
> Hi,
>
> I want to view a PDF within Pharo. I found that Athens has a PDF canvas, but I have no idea how to use it. Is there a way to view a PDF within Pharo, so that I can scroll, zoom, click links etc. in the PDF?
>
> Cheers,
> Manuel
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Embedded PDF viewer?

Offray Vladimir Luna Cárdenas-2
I have been thinking about this. I don't know if you can have a VNC
client inside the image that can be used to render a PDF app, but that
would be my first approach, to leverage all the features in the current
PDF readers.

Cheers,

Offray


On 10/10/17 14:04, Stephane Ducasse wrote:

> Hi manuel
>
> So far I do not know if we have this is Pharo.
> I imagine that we would have to build a renderer once we will have the
> PDF reader from Christian library.
>
> Stef
>
> On Tue, Oct 10, 2017 at 8:58 PM, Manuel Leuenberger
> <[hidden email]> wrote:
>> Hi,
>>
>> I want to view a PDF within Pharo. I found that Athens has a PDF canvas, but I have no idea how to use it. Is there a way to view a PDF within Pharo, so that I can scroll, zoom, click links etc. in the PDF?
>>
>> Cheers,
>> Manuel
>>
>>
>


Reply | Threaded
Open this post in threaded view
|

Re: Embedded PDF viewer?

kilon.alios
Implementation wise this may be possible through a hack, some OS windows can be semi trasparent , this make it possible to overlay one GUI element over the other in this case a PDF with basic scrolling handles. It should be possible with UFFI and some knowledge of OS GUI APIs. Probably much easier than having to implement the entire things in Pharo from scratch which would be ideal.

The overlay windows can change size according to the dimension of the Pharo windows so you can fool any pharo user thinking this is actually an internal Pharo window. This way even if the user resize or maximise the pharo window nothing messes up the Pharo gui. 

On Wed, Oct 11, 2017 at 12:04 AM Offray Vladimir Luna Cárdenas <[hidden email]> wrote:
I have been thinking about this. I don't know if you can have a VNC
client inside the image that can be used to render a PDF app, but that
would be my first approach, to leverage all the features in the current
PDF readers.

Cheers,

Offray


On 10/10/17 14:04, Stephane Ducasse wrote:
> Hi manuel
>
> So far I do not know if we have this is Pharo.
> I imagine that we would have to build a renderer once we will have the
> PDF reader from Christian library.
>
> Stef
>
> On Tue, Oct 10, 2017 at 8:58 PM, Manuel Leuenberger
> <[hidden email]> wrote:
>> Hi,
>>
>> I want to view a PDF within Pharo. I found that Athens has a PDF canvas, but I have no idea how to use it. Is there a way to view a PDF within Pharo, so that I can scroll, zoom, click links etc. in the PDF?
>>
>> Cheers,
>> Manuel
>>
>>
>


Reply | Threaded
Open this post in threaded view
|

Re: Embedded PDF viewer?

Ben Coman
In reply to this post by Stephane Ducasse-3

> On Tue, Oct 10, 2017 at 8:58 PM, Manuel Leuenberger
> <[hidden email]> wrote:
> > Hi,
> >
> > I want to view a PDF within Pharo. I found that Athens has a PDF canvas, but I have no idea how to use it. Is there a way to view a PDF within Pharo, so that I can scroll, zoom, click links etc. in the PDF?
> >
> > Cheers,
> > Manuel


On Wed, Oct 11, 2017 at 3:04 AM, Stephane Ducasse <[hidden email]> wrote:
>
> Hi manuel
>
> So far I do not know if we have this is Pharo.
> I imagine that we would have to build a renderer once we will have the
> PDF reader from Christian library.
>
> Stef

A renderer will have great synergy with PDFTalk, but I think a proof of concept can be done independently.
I've been poking at this topic for a while looking for options.  Coincidentally a couple of days I discovered the PDFium library. 
I haven't had time yet to give it a run, but it seems a good candidate since...
* Its a successful commercial product by Foxit built into Chrome converted to open source with Google's backing for use in Chromium
       https://www.foxitsoftware.com/company/press.php?id=305  
* Its license is BSD style
       https://github.com/hfiguiere/pdfium/tree/master/public
* Although written in C++ it has a C interface
      https://github.com/hfiguiere/pdfium/blob/master/public/fpdfview.h
      * Search here on  " Function: "  to skim through
      * Proof of concept seems to only need these key functions...  
          * void    FPDF_RenderPageBitmap( FPDF_BITMAP bitmap,FPDF_PAGE page, ... )
          * FPDF_BITMAP    FPDFBitmap_Create( int width, int height, int alpha);
          * FPDF_PAGE   FPDF_LoadPage   ( FPDF_DOCUMENT document, int page_index )
          * FPDF_DOCUMENT   FPDF_LoadMemDocument   ( const void* data_buf ... )
          * void    FPDF_InitLibrary ()    
* Has a concise getting started for POC... 
      https://github.com/hfiguiere/pdfium/blob/master/docs/getting-started.md
* Maybe useful fork with V8 disabled by default 
* Master repo here
      https://pdfium.googlesource.com/pdfium/

So Pharo might load a PDF file into a ByteArray, pass that to FPDF_LoadMemDocument() & FPDF_LoadPage(), 
then get a bitmap back from FPDFBitmap_Create() & FPDF_RenderPageBitmap() and display the result in a Pharo window.

The rest of this week I'm working 12 hour days on a mine site.  I could try it out once I'm home, but in the meantime is anyone else keen to try it? 

cheers -ben
Reply | Threaded
Open this post in threaded view
|

Re: Embedded PDF viewer?

Ben Coman


On Wed, Oct 11, 2017 at 2:03 PM, Ben Coman <[hidden email]> wrote:

> On Tue, Oct 10, 2017 at 8:58 PM, Manuel Leuenberger
> <[hidden email]> wrote:
> > Hi,
> >
> > I want to view a PDF within Pharo. I found that Athens has a PDF canvas, but I have no idea how to use it. Is there a way to view a PDF within Pharo, so that I can scroll, zoom, click links etc. in the PDF?
> >
> > Cheers,
> > Manuel


On Wed, Oct 11, 2017 at 3:04 AM, Stephane Ducasse <[hidden email]> wrote:
>
> Hi manuel
>
> So far I do not know if we have this is Pharo.
> I imagine that we would have to build a renderer once we will have the
> PDF reader from Christian library.
>
> Stef


[Edit: Update license link]
 
A renderer will have great synergy with PDFTalk, but I think a proof of concept can be done independently.
I've been poking at this topic for a while looking for options.  Coincidentally a couple of days I discovered the PDFium library. 
I haven't had time yet to give it a run, but it seems a good candidate since...
* Its a successful commercial product by Foxit built into Chrome converted to open source with Google's backing for use in Chromium
       https://www.foxitsoftware.com/company/press.php?id=305  
* Its license is BSD style 
       https://github.com/hfiguiere/pdfium/blob/master/LICENSE
* Although written in C++ it has a C interface
      https://github.com/hfiguiere/pdfium/blob/master/public/fpdfview.h
      * Search here on  " Function: "  to skim through
      * Proof of concept seems to only need these key functions...  
          * void    FPDF_RenderPageBitmap( FPDF_BITMAP bitmap,FPDF_PAGE page, ... )
          * FPDF_BITMAP    FPDFBitmap_Create( int width, int height, int alpha);
          * FPDF_PAGE   FPDF_LoadPage   ( FPDF_DOCUMENT document, int page_index )
          * FPDF_DOCUMENT   FPDF_LoadMemDocument   ( const void* data_buf ... )
          * void    FPDF_InitLibrary ()    
* Has a concise getting started for POC... 
      https://github.com/hfiguiere/pdfium/blob/master/docs/getting-started.md
* Maybe useful fork with V8 disabled by default 
* Master repo here
      https://pdfium.googlesource.com/pdfium/

So Pharo might load a PDF file into a ByteArray, pass that to FPDF_LoadMemDocument() & FPDF_LoadPage(), 
then get a bitmap back from FPDFBitmap_Create() & FPDF_RenderPageBitmap() and display the result in a Pharo window.

The rest of this week I'm working 12 hour days on a mine site.  I could try it out once I'm home, but in the meantime is anyone else keen to try it? 

cheers -ben