Re: [Pharo-users] Embedded PDF viewer?

2018-02-05 Thread Ben Coman
On 14 November 2017 at 00:18, Sean P. DeNigris  wrote:
> Ben Coman wrote
>> I've wanted PDF rendering inside Pharo for *years* and finally got a
>> sniff of a solid possibility - so I'm chasing it down.  It might not pan
>> out like I imagine, but "Live programming PDF documents" seems like a
>> catchy meme that the broader community may find intriguing.
>
> Go, go, go!!
>
>
>
> -
> Cheers,
> Sean

I've been distracted from this to play around with Bittrex trading.
In case someone feels inclined to take up the reins, I've blogged
about where I got up to.

Pharo PDF Rendering, part 1, building PDFium
http://blog.openinworld.com/2017/11/pharo-pdf-part-1/

Pharo PDF Rendering, part 2, UFFI interfacing PDFium
http://blog.openinworld.com/2018/02/pharo-pdf-part-2/

cheers -ben



Re: [Pharo-users] Embedded PDF viewer?

2017-11-14 Thread Christian Haider
In the end, you need to have bitmaps for the screen.
Rendering is the projection of vectors onto pixels.

But you don't want to lose the vectors, because you need them for interactions 
(mouse, keyboard focus).

I think that it is extremely sexy to have an interactive viewer for PDF!

Writing a renderer is a lot of work, although the newer Windows and Apple APIs 
make it a lot easier nowadays.
Still, you need to have an answer to color composition and irregular clipping 
paths (the hardest problems I think of. But there may be more).
And it must be fast enough for interactive applications...

I was hoping to use some existing renderer. I imagine that Bens approach can 
work well.

Although I didn’t do anything towards rendering myself, I am thinking of using 
PDF.js in an embedded browser.
PDF.js is used by many browsers and seems to be good enough by now.
And it would be not too bad to fiddle with JavaScript to connect it with the 
model in Smalltalk, I guess.
The problem is the browser embedding. Is this feasible in Pharo?

Happy hacking,
Christian


> -Ursprüngliche Nachricht-
> Von: Pharo-users [mailto:pharo-users-boun...@lists.pharo.org] Im Auftrag
> von K K Subbu
> Gesendet: Dienstag, 14. November 2017 06:43
> An: Ben Coman <b...@openinworld.com>
> Cc: Any question about pharo is welcome <pharo-users@lists.pharo.org>
> Betreff: Re: [Pharo-users] Embedded PDF viewer?
> 
> On Monday 13 November 2017 05:29 PM, Ben Coman wrote:
> > Yes, I've certainly considered it.  Pragmatically, in my electrical
> > career I deal with a lot of single page A3 PDF scans of schematic
> > drawings, so pre-converting to a bitmap format outside of Pharo
> > wouldn't lose much.
> 
> PDF deals with vector graphics, so bitmap conversion will be lossy. You could
> import them as SVG instead use the existing classes for handling SVG and
> XML.
> 
> HTH .. Subbu





Re: [Pharo-users] Embedded PDF viewer?

2017-11-13 Thread K K Subbu

On Monday 13 November 2017 05:29 PM, Ben Coman wrote:
Yes, I've certainly considered it.  Pragmatically, in my electrical 
career I deal with a lot of single page A3 PDF scans of schematic 
drawings, so pre-converting to a bitmap format outside of Pharo wouldn't 
lose much.


PDF deals with vector graphics, so bitmap conversion will be lossy. You 
could import them as SVG instead use the existing classes for handling 
SVG and XML.


HTH .. Subbu



Re: [Pharo-users] Embedded PDF viewer?

2017-11-13 Thread Offray Vladimir Luna Cárdenas


On 13/11/17 06:59, Ben Coman wrote:
> "Live programming PDF documents" seems like a catchy meme that the
> broader community may find intriguing.  
>
> Really, I'm just curious about what might be possible and can only
> discover that by walking the way.

Certainly I would be interested in that catchy meme. Please keep us
updated and keep also the good work.

Thanks,

Offray



Re: [Pharo-users] Embedded PDF viewer?

2017-11-13 Thread Sean P. DeNigris
Ben Coman wrote
> I've wanted PDF rendering inside Pharo for *years* and finally got a
> sniff of a solid possibility - so I'm chasing it down.  It might not pan
> out like I imagine, but "Live programming PDF documents" seems like a
> catchy meme that the broader community may find intriguing.

Go, go, go!!



-
Cheers,
Sean
--
Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html



Re: [Pharo-users] Embedded PDF viewer?

2017-11-13 Thread Ben Coman
On Mon, Nov 13, 2017 at 6:03 PM, K K Subbu  wrote:

> On Monday 13 November 2017 09:50 AM, Ben Coman wrote:
>
>> I've managed to build PDFium into a shared library on Ubuntu 16.04.
>> (I'll announce a blog post on this later.)
>> Now I'm considering the best bitmap format to bring the rendered page
>> back into Pharo.
>>
>
> Have you considered importing PDFs as a sequence of compressed PNGs into
> Pharo? If you not interested in twiddling pixels in the imported PDFs,
> perhaps PNG may be sufficient. They take up lesser space and easier to move
> around or re-export.
>
> Regards .. Subbu
>

Yes, I've certainly considered it.  Pragmatically, in my electrical career
I deal with a lot of single page A3 PDF scans of schematic drawings, so
pre-converting to a bitmap format outside of Pharo wouldn't lose much.
 But I've wanted PDF rendering inside Pharo for *years* and finally got a
sniff of a solid possibility - so I'm chasing it down.  It might not pan
out like I imagine, but "Live programming PDF documents" seems like a
catchy meme that the broader community may find intriguing.

Really, I'm just curious about what might be possible and can only discover
that by walking the way.

cheers -ben


Re: [Pharo-users] Embedded PDF viewer?

2017-11-13 Thread K K Subbu

On Monday 13 November 2017 09:50 AM, Ben Coman wrote:
I've managed to build PDFium into a shared library on Ubuntu 16.04.  
(I'll announce a blog post on this later.)
Now I'm considering the best bitmap format to bring the rendered page 
back into Pharo.


Have you considered importing PDFs as a sequence of compressed PNGs into 
Pharo? If you not interested in twiddling pixels in the imported PDFs, 
perhaps PNG may be sufficient. They take up lesser space and easier to 
move around or re-export.


Regards .. Subbu



Re: [Pharo-users] Embedded PDF viewer?

2017-11-12 Thread Ben Coman
I've managed to build PDFium into a shared library on Ubuntu 16.04.  (I'll
announce a blog post on this later.)
Now I'm considering the best bitmap format to bring the rendered page back
into Pharo.
I'm seeking advise on...

Q1. Looking at the two significant bitmap creation functions below from the
C header file,
which of PDFium's bitmap formats is the best match for Pharo?

// Gray scale bitmap, one byte per pixel.
#define FPDFBitmap_Gray 1
// 3 bytes per pixel, byte order: blue, green, red.
#define FPDFBitmap_BGR 2
// 4 bytes per pixel, byte order: blue, green, red, unused.
#define FPDFBitmap_BGRx 3
// 4 bytes per pixel, byte order: blue, green, red, alpha.
#define FPDFBitmap_BGRA 4

typedef void* FPDF_BITMAP;


// Function: FPDFBitmap_CreateEx
//  Create a device independent bitmap (FXDIB)
// Parameters:
//  width   -   The number of pixels in width for the bitmap.
//  Must be greater than 0.
//  height  -   The number of pixels in height for the bitmap.
//  Must be greater than 0.
//  format  -   A number indicating for bitmap format, as
defined
//  above.
//  first_scan  -   A pointer to the first byte of the first line if
//  using an external buffer. If this parameter is
NULL,
//  then the a new buffer will be created.
//  stride  -   Number of bytes for each scan line, for external
//  buffer only.
// Return value:
//  The bitmap handle, or NULL if parameter error or out of memory.
// Comments:
//  Similar to FPDFBitmap_Create function, but allows for more
formats
//  and an external buffer is supported. The bitmap created by this
//  function can be used in any place that a FPDF_BITMAP handle is
//  required.
//
//  If an external buffer is used, then the application should
destroy
//  the buffer by itself. FPDFBitmap_Destroy function will not
destroy
//  the buffer.
FPDF_BITMAP
FPDFBitmap_CreateEx(
  int width,
  int height,
  int format,
  void* first_scan,
  int stride);


// Function: FPDFBitmap_Create
//  Create a device independent bitmap (FXDIB).
// Parameters:
//  width   -   The number of pixels in width for the bitmap.
//  Must be greater than 0.
//  height  -   The number of pixels in height for the bitmap.
//  Must be greater than 0.
//  alpha   -   A flag indicating whether the alpha channel is
used.
//  Non-zero for using alpha, zero for not using.
// Return value:
//  The created bitmap handle, or NULL if a parameter error or out
of
//  memory.
// Comments:
//  The bitmap always uses 4 bytes per pixel. The first byte is
always
//  double word aligned.
//
//  The byte order is BGRx (the last byte unused if no alpha
channel) or
//  BGRA.
//
//  The pixels in a horizontal line are stored side by side, with
the
//  left most pixel stored first (with lower memory address).
//  Each line uses width * 4 bytes.
//
//  Lines are stored one after another, with the top most line
stored
//  first. There is no gap between adjacent lines.
//
//  This function allocates enough memory for holding all pixels in
the
//  bitmap, but it doesn't initialize the buffer. Applications can
use
//  FPDFBitmap_FillRect to fill the bitmap using any color.
FPDF_BITMAP
FPDFBitmap_Create(
  int width,
  int height,
  int alpha);


// Function: FPDFBitmap_Destroy
//  Destroy a bitmap and release all related buffers.
// Parameters:
//  bitmap  -   Handle to the bitmap. Returned by
FPDFBitmap_Create.
// Return value:
//  None.
// Comments:
//  This function will not destroy any external buffers provided
when
//  the bitmap was created.
void FPDFBitmap_Destroy(FPDF_BITMAP bitmap);


Pharo's relevant class comments are...

* Bitmap - My instances provide contiguous storage of bits, primarily to
hold the graphical data of Forms. Forms and their subclasses provide the
additional structural information as to how the bits should be interpreted
in two dimensions.

* Form - A rectangular array of pixels, used for holding images.  All
pictures, including character images are Forms.  The depth of a Form is how
many bits are used to specify the color at each pixel.  The actual bits are
held in a Bitmap, whose internal structure is different at each depth.
The supported depths (in bits) are 1, 2, 4, 8, 16, and 32.  The 

Re: [Pharo-users] Embedded PDF viewer?

2017-11-07 Thread Ben Coman
Thx for the tip.  However Envice is GPLd to constrain its use.

cheers -ben

On Mon, Nov 6, 2017 at 2:16 AM, Andrew Glynn <aglyn...@gmail.com> wrote:

> Evince is pretty easy to embed.
>
>
>
> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for
> Windows 10
>
>
>
> *From: *teso...@gmail.com
> *Sent: *Sunday, November 5, 2017 10:25 AM
> *To: *Any question about pharo is welcome <pharo-users@lists.pharo.org>
> *Subject: *Re: [Pharo-users] Embedded PDF viewer?
>
>
>
> Hello Ben,
>
>UFFI does not allow you to call static libraries. Static libraries are
> not executable per se, they need to be linked in another program.
>
> As I know, the only way of using an static library from Pharo is to:
>
>   - Build a plugin that wraps it.
>
>   - Build a DLL exposing all the functions in the library and then they
> are used through UFFI.
>
>
>
> The second option is the easiest to me, but it depends how the library is
> built up. For example, if the library uses a lot of compile time code
> generation (like macros or templates) making a generic DLL is not so easy.
>
>
>
> I think it is better to see if not other project has already tackle this
> problem when using the desired static library.
>
>
>
> Cheers,
>
> Pablo
>
>
>
> On Sun, Nov 5, 2017 at 1:39 PM, Ben Coman <b...@openinworld.com> wrote:
>
> I'm looking into calling PDFium from Pharo via FFI.
>
> Currently I'm stalled a bit since it doesn't have a shared-library target.
>
>
>
> If you consider access to such a library would be useful to the community,
>
> please take a few moments to star this issue...
>
> https://bugs.chromium.org/p/pdfium/issues/detail?id=826
>
>
>
> cheers -ben
>
>
>
>
>
> P.S. Can anyone comment on calling into a static library via FFI?
>
>
>
>
>
>
>
> On Wed, Oct 11, 2017 at 2:05 PM, Ben Coman <b...@openinworld.com> wrote:
>
>
>
>
>
> On Wed, Oct 11, 2017 at 2:03 PM, Ben Coman <b...@openinworld.com> wrote:
>
>
> > On Tue, Oct 10, 2017 at 8:58 PM, Manuel Leuenberger
> > <leuenber...@inf.unibe.ch> 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 <stepharo.s...@gmail.com>
> 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
> <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...
>   * voidFPDF_RenderPageBitmap( FPDF_BITMAP bitmap,FPDF_PAGE
> page, ... )
>   * FPDF_BITMAPFPDFBitmap_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
> ... )
>   * voidFPDF_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
>
>   https://github.com/klokantech/pdfium
>
> * 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
>
>
>
>
>
>
>
>
>
> --
>
> Pablo Tesone.
> teso...@gmail.com
>
>
>


Re: [Pharo-users] Embedded PDF viewer?

2017-11-05 Thread Andrew Glynn
Evince is pretty easy to embed.

Sent from Mail for Windows 10

From: teso...@gmail.com
Sent: Sunday, November 5, 2017 10:25 AM
To: Any question about pharo is welcome
Subject: Re: [Pharo-users] Embedded PDF viewer?

Hello Ben, 
   UFFI does not allow you to call static libraries. Static libraries are not 
executable per se, they need to be linked in another program.
As I know, the only way of using an static library from Pharo is to:
  - Build a plugin that wraps it.
  - Build a DLL exposing all the functions in the library and then they are 
used through UFFI. 

The second option is the easiest to me, but it depends how the library is built 
up. For example, if the library uses a lot of compile time code generation 
(like macros or templates) making a generic DLL is not so easy. 

I think it is better to see if not other project has already tackle this 
problem when using the desired static library. 

Cheers,
Pablo

On Sun, Nov 5, 2017 at 1:39 PM, Ben Coman <b...@openinworld.com> wrote:
I'm looking into calling PDFium from Pharo via FFI.
Currently I'm stalled a bit since it doesn't have a shared-library target.

If you consider access to such a library would be useful to the community, 
please take a few moments to star this issue...
https://bugs.chromium.org/p/pdfium/issues/detail?id=826

cheers -ben


P.S. Can anyone comment on calling into a static library via FFI?



On Wed, Oct 11, 2017 at 2:05 PM, Ben Coman <b...@openinworld.com> wrote:


On Wed, Oct 11, 2017 at 2:03 PM, Ben Coman <b...@openinworld.com> wrote:

> On Tue, Oct 10, 2017 at 8:58 PM, Manuel Leuenberger
> <leuenber...@inf.unibe.ch> 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 <stepharo.s...@gmail.com> 
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 
      https://github.com/klokantech/pdfium 
* 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






-- 
Pablo Tesone.
teso...@gmail.com



Re: [Pharo-users] Embedded PDF viewer?

2017-11-05 Thread teso...@gmail.com
Hello Ben,
   UFFI does not allow you to call static libraries. Static libraries are
not executable per se, they need to be linked in another program.
As I know, the only way of using an static library from Pharo is to:
  - Build a plugin that wraps it.
  - Build a DLL exposing all the functions in the library and then they are
used through UFFI.

The second option is the easiest to me, but it depends how the library is
built up. For example, if the library uses a lot of compile time code
generation (like macros or templates) making a generic DLL is not so easy.

I think it is better to see if not other project has already tackle this
problem when using the desired static library.

Cheers,
Pablo

On Sun, Nov 5, 2017 at 1:39 PM, Ben Coman  wrote:

> I'm looking into calling PDFium from Pharo via FFI.
> Currently I'm stalled a bit since it doesn't have a shared-library target.
>
> If you consider access to such a library would be useful to the community,
> please take a few moments to star this issue...
> https://bugs.chromium.org/p/pdfium/issues/detail?id=826
>
> cheers -ben
>
>
> P.S. Can anyone comment on calling into a static library via FFI?
>
>
>
> On Wed, Oct 11, 2017 at 2:05 PM, Ben Coman  wrote:
>
>>
>>
>> On Wed, Oct 11, 2017 at 2:03 PM, Ben Coman  wrote:
>>
>>>
>>> > On Tue, Oct 10, 2017 at 8:58 PM, Manuel Leuenberger
>>> >  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 <
>>> stepharo.s...@gmail.com> 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...
>>>   * voidFPDF_RenderPageBitmap( FPDF_BITMAP bitmap,FPDF_PAGE
>>> page, ... )
>>>   * FPDF_BITMAPFPDFBitmap_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 ... )
>>>   * voidFPDF_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
>>>   https://github.com/klokantech/pdfium
>>> * 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
>>>
>>
>>
>


-- 
Pablo Tesone.
teso...@gmail.com


Re: [Pharo-users] Embedded PDF viewer?

2017-11-05 Thread Ben Coman
I'm looking into calling PDFium from Pharo via FFI.
Currently I'm stalled a bit since it doesn't have a shared-library target.

If you consider access to such a library would be useful to the community,
please take a few moments to star this issue...
https://bugs.chromium.org/p/pdfium/issues/detail?id=826

cheers -ben


P.S. Can anyone comment on calling into a static library via FFI?



On Wed, Oct 11, 2017 at 2:05 PM, Ben Coman  wrote:

>
>
> On Wed, Oct 11, 2017 at 2:03 PM, Ben Coman  wrote:
>
>>
>> > On Tue, Oct 10, 2017 at 8:58 PM, Manuel Leuenberger
>> >  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 <
>> stepharo.s...@gmail.com> 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...
>>   * voidFPDF_RenderPageBitmap( FPDF_BITMAP bitmap,FPDF_PAGE
>> page, ... )
>>   * FPDF_BITMAPFPDFBitmap_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
>> ... )
>>   * voidFPDF_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
>>   https://github.com/klokantech/pdfium
>> * 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
>>
>
>


Re: [Pharo-users] Embedded PDF viewer?

2017-10-11 Thread Ben Coman
On Wed, Oct 11, 2017 at 2:03 PM, Ben Coman  wrote:

>
> > On Tue, Oct 10, 2017 at 8:58 PM, Manuel Leuenberger
> >  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 
> 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...
>   * voidFPDF_RenderPageBitmap( FPDF_BITMAP bitmap,FPDF_PAGE
> page, ... )
>   * FPDF_BITMAPFPDFBitmap_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
> ... )
>   * voidFPDF_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
>   https://github.com/klokantech/pdfium
> * 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
>


Re: [Pharo-users] Embedded PDF viewer?

2017-10-11 Thread Ben Coman
> On Tue, Oct 10, 2017 at 8:58 PM, Manuel Leuenberger
>  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 
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...
  * voidFPDF_RenderPageBitmap( FPDF_BITMAP bitmap,FPDF_PAGE
page, ... )
  * FPDF_BITMAPFPDFBitmap_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
... )
  * voidFPDF_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
  https://github.com/klokantech/pdfium
* 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


Re: [Pharo-users] Embedded PDF viewer?

2017-10-10 Thread Dimitris Chloupis
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 <
offray.l...@mutabit.com> 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
> >  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
> >>
> >>
> >
>
>
>


Re: [Pharo-users] Embedded PDF viewer?

2017-10-10 Thread Offray Vladimir Luna Cárdenas
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
>  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
>>
>>
>




Re: [Pharo-users] Embedded PDF viewer?

2017-10-10 Thread Stephane Ducasse
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
 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
>
>



[Pharo-users] Embedded PDF viewer?

2017-10-10 Thread 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