viewing PDF

Post

Posted
Rating:
#1 (In Topic #1815)
Avatar
Enthusiast
Yogi is in the usergroup ‘Enthusiast’

PDF in documentview with zoom

Dear all,

after seeking and trying some methods for viewing PDF Files I went back to the
deprecated gb.PDF component.

It is short, simple and does what one could expect from a PDF viewer.

A look at the software farm was not successful, maybe there is something
I couldn't find - is there a search function?

On the other hand, I am interested in how the problem can be solved with
the newer gb.poppler component.

Has anyone done something like this before or knows where to find something?
Thanks and best regards
Yogi
Online now: No Back to the top

Post

Posted
Rating:
Item has a rating of 5 (Liked by Yogi)
#2
Avatar
Administrator
gbWilly is in the usergroup ‘unknown’
I would like to help but I never had the need for a pdf viewer or anything of the kind.
I did create pdfs using gb.cairo, but that is a whole other matter.
I guess you will need to look into https://gambaswiki.org/wiki/comp/gb.poppler/pdfdocument for viewing.

I couldn't find much on the topic either except for some on the Italian forum:
https://www.gambas-it.org/wiki/index.php/Estrarre_il_testo_da_un_file_PDF_con_le_risorse_del_Componente_gb.poppler 
https://www.gambas-it.org/wiki/index.php/Stampare_un_file_PDF
I guess you could use a translator and see if it get's you anywhere.

Good luck and keep us posted. I happilly think along :thumbs:

Edit: Forget all above, I found this on the farm from gianluigi

farm.png

That should provide some answers :lol:

On the farm I selected All software, next clicked on radiobutton Show Filters and put gb.poppler in Filter to find above

search.png

Last edit: by gbWilly


gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories


… there is always a Catch if things go wrong!
Online now: No Back to the top

Post

Posted
Rating:
Item has a rating of 5 (Liked by gbWillyLiked by Yogi)
#3
Avatar
Enthusiast
Gianluigi is in the usergroup ‘Enthusiast’
You can find a more detailed project here:
k23:k23.12:k23.12.5:start [GAMBAS BOOK 3.19.5]
The lesson starts here:
k23:k23.12:start [GAMBAS BOOK 3.19.5]

 :hand:
Online now: No Back to the top

Post

Posted
Rating:
Item has a rating of 5 (Liked by Yogi)
#4
Avatar
Administrator
gbWilly is in the usergroup ‘unknown’

Gianluigi said

You can find a more detailed project here:
k23:k23.12:k23.12.5:start [GAMBAS BOOK 3.19.5]
The lesson starts here:
k23:k23.12:start [GAMBAS BOOK 3.19.5]
I totally forgot about gambas-buch.  :thumbs:

Yogi -> it's originally in German, even better for you  :lol:

gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories


… there is always a Catch if things go wrong!
Online now: No Back to the top

Post

Posted
Rating:
#5
Avatar
Enthusiast
Yogi is in the usergroup ‘Enthusiast’

gbWilly said

I would like to help but I never had the need for a pdf viewer or anything of the kind.


Dear Willy,
Every help is very much appreciated.

Actually I learn with the m3u project how to do it with Gambas. First it was just creating and editing
m3u Files (yes, even VLC can handle m3u files 😀). But learning by doing is the best way for me
and also putting some ideas in the project. Now I'm also extending the project with an mp3 player -
there are plenty of it.

But back to the topic, one idea was to give a little help by opening a PDF file.
Not everyone has good eyesight; I wear glasses myself, so I simply wanted
to incorporate a zoom feature. That worked out great with the gb.PDF
Let's see how it works out with the poppler PDF component.

Regarding the software farm, I didn't understand the filter thing, thanks for pointing that out!

The older you get, the more you expect things to work a certain way.
I was looking for the term or symbol “search” or “find.”

At the moment first I look in the mentioned Gambas Book. If I don't find in short time what
I'm looking for next is the forum, then startpage.com. Doesn't mean that the info I'm looking
for is not in the book, just not finding it.
Next is getting to the community 😇

Thanks a lot and
kind regards,
Yogi
Online now: No Back to the top

Post

Posted
Rating:
#6
Avatar
Enthusiast
Yogi is in the usergroup ‘Enthusiast’

Gianluigi said

You can find a more detailed project here:
k23:k23.12:k23.12.5:start [GAMBAS BOOK 3.19.5]
The lesson starts here:
k23:k23.12:start [GAMBAS BOOK 3.19.5]

 :hand:

Thanks for pointing me there, I'll have a look;
Kind regards,
Yogi
Online now: No Back to the top

Post

Posted
Rating:
#7
Avatar
Enthusiast
Yogi is in the usergroup ‘Enthusiast’

gbWilly said

Gianluigi said

You can find a more detailed project here:
k23:k23.12:k23.12.5:start [GAMBAS BOOK 3.19.5]
The lesson starts here:
k23:k23.12:start [GAMBAS BOOK 3.19.5]
I totally forgot about gambas-buch.  :thumbs:

Yogi -> it's originally in German, even better for you  :lol:

I downloaded it some time ago. I prefer the German language, but English has always been
the main language for programming.
Greetings to the Netherlands (or even Holland 😀)
Kind Regards
Yogi
Online now: No Back to the top

Post

Posted
Rating:
#8
Avatar
Enthusiast
Yogi is in the usergroup ‘Enthusiast’
Ok, it could be sorted out now with all your help 👍

First I had a look at Gianluigi

Gianluigi said

DocumentViewPDFZoomDialog
and played around,
at the first sight it worked with zooming in. So of course I can use this as a sample.
Next I found out that there is no zoomOut there, ok, copied the sub for zooming in …

Code (gambas)

Public Sub btnZoomIn_Click()

  Dim f As Float = DocumentView1.Zoom

  f += 0.05
  If f > 2 Then f = 1
  DocumentView1.Zoom = f
  DocumentView1.Count = $hPdf.Count
  DocumentView1.Refresh
  Wait

End

to

Code (gambas)

Public Sub btnZoomOut_Click()

  Dim f As Float = DocumentView1.Zoom

  f -= 0.05
  If f < 0.5 Then f = 1
  DocumentView1.Zoom = f
  DocumentView1.Count = $hPdf.Count
  DocumentView1.Refresh
  Wait

End

and had a try. Zooming in worked, zoomig out worked - but this doesn't work as expected,
the PDF becomes somehow clipped.
OK, next step. Downloading the PDF-Reader from Gambas Book PDF Reader from Gambas Book

There I found out, that there is some difference which version of Gambas you are using for rendering the page
in

Code (gambas)

Public Sub DocumentView1_Draw(Page As Integer, Width As Integer, Height As Integer)

Here is this peace of code:

Code (gambas)

'-- My standard for rendering method in V3.19.0 after a few bug fixes in gb.poppler
    If System.FullVersion = "3.19.0" Then
   '-- 150 dpi provides a better quality in the DocumentView but slower
       Paint.DrawImage(hPdfDocument[Page].Render(,,,,, 150), 0, 0, width, height)
    Else If System.FullVersion >= "3.19.1" Then
     '-- Refer to Mailing List email of Benoît Minisini in the 'Notes' file in the project directory
     '-- https://lists.gambas-basic.org/pipermail/user/2024-February/081570.html
     '-- Quote: In the last commit, I modified the Render() method so that if you
     '-- specify the width And height arguments, And Not the resolution argument,
     '-- the best drawing resolution will be automatically computed.
     
    '-- Automatically choosing the resolution for a good readable result in a DocumentView,
     Paint.DrawImage(hPdfDocument[Page].Render(0, 0, Width, Height), 0, 0)
    Else
        Message.Error("Gambas 3.19.0 is the minimum version for a reasonable use of gb.poppler")
    Endif
 

As I am on Gambas 3.20.4 copied just the one line, changed the variable and voila,
now it works in both directions zooming in & out.

So we are ready for dropping gb.pdf

Have a nice weekend,
Kind regards,
Yogi
Online now: No Back to the top

Post

Posted
Rating:
Item has a rating of 5 (Liked by gbWillyLiked by Yogi)
#9
Avatar
Enthusiast
Gianluigi is in the usergroup ‘Enthusiast’
 :thumbs:

Since we're talking about Zoom, I also wanted to point out this page:
Codice essenziale per mostrare un file PDF con le risorse del Componente gb.poppler - Gambas-it.org - Wikipedia

:goodbye:
Online now: No Back to the top

Post

Posted
Rating:
#10
Avatar
Administrator
gbWilly is in the usergroup ‘unknown’

Gianluigi said

 :thumbs:

Since we're talking about Zoom, I also wanted to point out this page:
Codice essenziale per mostrare un file PDF con le risorse del Componente gb.poppler - Gambas-it.org - Wikipedia

:goodbye:

Been looking at the code in above link and it's actually quite easy to create a pdfviewer  :thumbs:
A lot easier that creating a pdf using gb.cairo :lol:

I might be adding this as an GUI application to build in Book 2 I'm writing.
It is a very practical application to have on a system and a good example to use for demonstrating 'stuff'…
I see some educational value in it  ;)
 

gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories


… there is always a Catch if things go wrong!
Online now: No Back to the top

Post

Posted
Rating:
#11
Avatar
Enthusiast
Yogi is in the usergroup ‘Enthusiast’
Hi again 😀

The PDF viewing is already good to use.

I'm just curious about one thing:
it is possible with the mouse wheel to scroll the page up and down.
Especially if one zooms in this is a good thing.

How to do that scrolling with the up and down key?

Tried some things, looked also at the Italian site Gianluigi suggested.
Looked into the classes (poppler, scroll) but nothing what I could find out.

Something like

Code (gambas)

 $hPdf.scrolly(100)
 $hPdf.scrolly(-100)
didn't do the job

here the code for keypress:

Code (gambas)

  1. Public Sub Form_KeyPress()
  2.  
  3.   If Key.Code = Key.Esc Then
  4.     Me.Close
  5.   Else If Key.Code = Key.Down Then
  6.     '$hPdf.scrolly(100)
  7.  
  8.    
  9.   Else If Key.Text = "+" Then
  10.     zoom_Click("zoomin")
  11.  
  12.   Else If Key.Text = "-" Then
  13.     zoom_Click("zoomout")
  14.    
  15.   Else If Key.Code = Key.PageUp Then
  16.     Dec $iPage
  17.     If $iPage < 0 Then
  18.       $iPage = $hPdf.Max
  19.     Endif
  20.     DocumentView1.Goto($iPage)
  21.     DocumentView1.Refresh
  22.    
  23.  
  24.   Else If Key.Code = Key.PageDown Then
  25.     Inc $iPage
  26.     If $iPage > $hPdf.Count Then
  27.       $iPage = 0
  28.     Endif
  29.     DocumentView1.Goto($iPage)
  30.     DocumentView1.Refresh
  31.  
  32.   Else If Key.Code = Key.Home Then
  33.     zoom_Click("reset")
  34.  


Any ideas?

Thanks a lot &
kind regards
Yogi


Online now: No Back to the top

Post

Posted
Rating:
#12
Avatar
Enthusiast
Gianluigi is in the usergroup ‘Enthusiast’
HI,
To achieve what you want, I think you'll also need to create the index.

Unfortunately, I don't have much time to devote to Gambas these days. If you haven't solved the problem in the meantime, I'll send you some code.
Sorry.

 :goodbye:
Online now: No Back to the top

Post

Posted
Rating:
#13
Avatar
Enthusiast
Gianluigi is in the usergroup ‘Enthusiast’
I forgot, this works in Claus's code:

Code

Public Sub Form_KeyPress()

  Dim i As Integer = Val(ListViewPages.Current.Key)

  If Key.Code = Key.PageDown Then
    Try ListViewPages[i + 1].Selected = True
  Endif
  If Key.Code = Key.PageUp Then
    Try ListViewPages[i - 1].Selected = True
  Endif

End
But I think it would be better to use arrows for possible future additions

 :goodbye:
Online now: No Back to the top

Post

Posted
Rating:
#14
Avatar
Enthusiast
Yogi is in the usergroup ‘Enthusiast’

Gianluigi said

I forgot, this works in Claus's code:

Code

Public Sub Form_KeyPress()

  Dim i As Integer = Val(ListViewPages.Current.Key)

  If Key.Code = Key.PageDown Then
    Try ListViewPages[i + 1].Selected = True
  Endif
  If Key.Code = Key.PageUp Then
    Try ListViewPages[i - 1].Selected = True
  Endif

End
But I think it would be better to use arrows for possible future additions

 :goodbye:

Dear Gianluigi ,
Thank you again for your effort.

I tried out your sample but could not make it running. Unknown ListViewPages…

For the handling I used the PgUp/PgDn keys for showing previous/next PDF pages which
is already working.
The scrolling part with the arrow up/Down keys I have no clue how to scroll the pdf just
like the mouse wheel,

Kind regards,
Yogi
Online now: No Back to the top

Post

Posted
Rating:
#15
Avatar
Enthusiast
Gianluigi is in the usergroup ‘Enthusiast’
Dear Yogi (explain to me how to enter your name like you did mine):$
I meant something like this.
See the attached project, which is a "reduction" of the one in the lesson.

:goodbye:
Attachment

pdf-reader-g-0.0.1.tar.gz

Online now: No Back to the top

Post

Posted
Rating:
Item has a rating of 5 (Liked by YogiLiked by Gianluigi)
#16
Avatar
Administrator
sholzy is in the usergroup ‘unknown’

Gianluigi said

Dear Yogi (explain to me how to enter your name like you did mine):$
I meant something like this.
See the attached project, which is a "reduction" of the one in the lesson.

:goodbye:

It's very simple.

@Gianluigi


Gianluigi

sholzy
Gambas One Site Director

To report bugs in the Gambas IDE:
Official Gambas Bug Tracker
Online now: No Back to the top

Post

Posted
Rating:
#17
Avatar
Enthusiast
Yogi is in the usergroup ‘Enthusiast’

Gianluigi said

Dear Yogi (explain to me how to enter your name like you did mine):$
I meant something like this.
See the attached project, which is a "reduction" of the one in the lesson.

:goodbye:

Good morning,
Yes, it is that simple, just using the "@" and a few characters and the system - as it is supported by most
of the chat systems - will give you a hint which person to address.

Thanks again for your help,
Have a nice day,
Regards,
Yogi
Online now: No Back to the top

Post

Posted
Rating:
#18
Avatar
Enthusiast
Yogi is in the usergroup ‘Enthusiast’

I may not have explained very well what I wanted to achieve.
Here is a short video with the standard viewer in Ubuntu, where it works with both
the mouse wheels and the up/down keys in the same way.

In Gambas, it works with the mouse without any additional actions, but doesn't with they down/up keys.

pdfreader720.mp4


The jumping forward/backward one page is working already and I'm happy with it.
Just this detail with smooth scrolling with the Down/Up keys…

Thanks again,
Regards,
Yogi
Online now: No Back to the top

Post

Posted
Rating:
#19
Avatar
Administrator
gbWilly is in the usergroup ‘unknown’
I guess you will have to code the Key.Up and Key.Down to make that work

Code (gambas)

  1. Public Sub Form_KeyPress()
  2.  
  3.   If Key.Code = Key.Up Then
  4.     ' your code here
  5.   Endif
  6.   If Key.Code = Key.Down Then
  7.     ' your code here
  8.   Endif
  9.  

All that is missing is the "Your code here" part to make it work.
Good luck :thumbs:

P.S. The "&#39;' is a single quote for comment but the code editor seems to like to replace it for some reason with &#39;

gbWilly
- Gambas Dutch translator
- Gambas wiki content contributor
- Gambas debian/ubuntu package recipe contributor
- GambOS, a distro for learning Gambas and more…
- Gambas3 Debian/Ubuntu repositories


… there is always a Catch if things go wrong!
Online now: No Back to the top

Post

Posted
Rating:
#20
Avatar
Enthusiast
Gianluigi is in the usergroup ‘Enthusiast’
Dear Yogi

As suggested by gbWilly I'd already pointed you to this lesson written by Vuott on the Italian wiki:
Codice essenziale per mostrare un file PDF con le risorse del Componente gb.poppler - Gambas-it.org - Wikipedia
I'm attaching an example.
Attachment

PdfScroll-0.0.1.tar.gz

Online now: No Back to the top

Post

Posted
Rating:
#21
Avatar
Enthusiast
Yogi is in the usergroup ‘Enthusiast’

gbWilly said

I guess you will have to code the Key.Up and Key.Down to make that work

Code (gambas)

  1. Public Sub Form_KeyPress()
  2.  
  3.   If Key.Code = Key.Up Then
  4.     &#39;your code here
  5.   Endif
  6.   If Key.Code = Key.Down Then
  7.     &#39;your code here
  8.   Endif
  9.  

All that is missing is the "Your code here" part to make it work.
Good luck 

P.S. The "&#39;' is a single quote for comment but the code editor seems to like to replace it for some reason with &#39;

Hi Willy,
Yes, that is the point
Regards
Yogi
Online now: No Back to the top

Post

Posted
Rating:
#22
Avatar
Enthusiast
Yogi is in the usergroup ‘Enthusiast’

Gianluigi said

Dear Yogi

As suggested by gbWilly I'd already pointed you to this lesson written by Vuott on the Italian wiki:
Codice essenziale per mostrare un file PDF con le risorse del Componente gb.poppler - Gambas-it.org - Wikipedia
I'm attaching an example.

Dear Gianluigi ,
I had already a look at this website Wiki and I am more confused than before.
I thought I can have the documentview container to get it work. After the Italian Wiki I had no idea
because of the different containers used for showing the PDF.

Now I think I quit, just had my "working" code tested with the PDF provided by the samples for download with
different page sizes, and what - my code doesn't work as expected. If all is size A4 no problem, but if mixed up…

Anyway, if someone is interested in the sample I did:

Attachment

PDF_Documentview-0.0.1.tar.gz


Kind regards,
Yogi
Online now: No Back to the top

Post

Posted
Rating:
#23
Avatar
Enthusiast
Gianluigi is in the usergroup ‘Enthusiast’
Dear Yogi ,
you need to get a little familiar with Gambas containers.
If you wanted to do this, see what I changed and practice.  :)

 :goodbye:

Attachment

PDF_Documentview-0.0.2.tar.gz

Online now: No Back to the top

Post

Posted
Rating:
#24
Avatar
Enthusiast
Yogi is in the usergroup ‘Enthusiast’

Gianluigi said

Dear Yogi ,
you need to get a little familiar with Gambas containers.
If you wanted to do this, see what I changed and practice.  :)

 :goodbye:


Dear Gianluigi ,
Thank you for giving a lesson in arranging the container in a form. Much appreciated because I did the last
time a view to resize automatically the objects and container on a form without using the sourcecode.
Not that easy if your are not aware of the actions done by arrange, expand, resize etc.

But 😂 it doesn't change anything to my problem regarding scrolling and viewing the PDF Files.
Anyway, thanks a lot!

Kind regards,
Yogi
Online now: No Back to the top

Post

Posted
Rating:
Item has a rating of 5 (Liked by YogiLiked by gbWilly)
#25
Avatar
Enthusiast
Gianluigi is in the usergroup ‘Enthusiast’

But 😂 it doesn't change anything to my problem regarding scrolling and viewing the PDF Files. Anyway, thanks a lot! said


Dear Yogi ,
We were suggesting this (see attached project).
Good night.


Attachment

PDFscroll-0.0.1.tar.gz

Online now: No Back to the top
1 guest and 0 members have just viewed this.