[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: DocumentView confusion


On Saturday, November 15th, 2025 at 21:33, Fabien Bodard <gambas.fr@xxxxxxxxx> wrote:

> Fabien Bodard
>
> Le sam. 15 nov. 2025, 20:28, Lee <t.lee.davidson@xxxxxxxxx> a écrit :
>
>> On 11/15/25 5:56 AM, gbWilly wrote:
>>> On Saturday, November 15th, 2025 at 00:09, Lee <t.lee.davidson@xxxxxxxxx> wrote:
>>>>
>>>> I thought I might investigate this but ......
>>>>
>>>> How in the world does one load a document into DocumentView?
>>>>
>> [snip]
>>>
>>> Public Sub DocumentView1_Draw(Page As Integer, Width As Integer, Height As Integer)
>>>
>>> Paint.DrawImage($hPdfFile[Page].Render(0, 0, Width, Height), 0, 0)
>>>
>>> End
>>>
>> [snip]
>>
>> Okay. So one does not "load" a document into DocumentView. It must be rendered in the Draw event with code customized for the
>> particular type of document being viewed. I did not find that mentioned on the Wiki.
>>
>> Now, I think there are a couple of issues here:
>> 1. The existence of one or more bugs,
>> 2. The documentation is confusing due to the redundancy of the FirstVisible-Document/Page properties (they represent the same
>> values) and their conflicting descriptions. The Document-Height/Width properties also represent the same values as
>> Page-Height/Width.
>>
>> From a cursory look at the DocumentView code, it seems apparent that a document's page number, in its properties and methods,
>> is referenced by its index (starting at 0) not its visual page number. This would mean that the value for LastVisibleDocument,
>> and LastVisiblePage, may always be incorrect.
>>
>> Document.Goto's integer parameter is obviously to be a page's index. If I use that method to go to the page at index 5, the view
>> displays visual Page 6 of the document as it should. However, the ShowPage display says that the view is on page 5 even though
>> only Page 6 is visible.
>>
>> Also while still on the page at index 5, the value of FirstVisibleDocument is 4 while the value of LastVisibleDocument is 6.
>> Both are incorrect.
>>
>> The above results were obtained with a PDF document of size US Letter (8.5 x 11 inch) with .DocumentHeight and .DocumentWidth
>> set to 280 and 215, respectively, and with a view port size that can show only a partial page at a time.
>>
>> --
>> Lee
>>
>> --- Gambas User List Netiquette [https://gambaswiki.org/wiki/doc/netiquette] ----
>> --- Gambas User List Archive [https://lists.gambas-basic.org/archive/user] ----
>
> Hi Lee
>
> DocumentView is one of my old components.
>
> All the index represents index and not page.
> Goto(0) send you to the page 1.
>
> 0 is the position in an array of pages.
>
> Document View is the a displayer .
>
> Do you want a pdf viewer example ?

Since you are the author of the component, what I would like is some answers to what is discussed in this thread. No person better suited to shed some light on it all.

And Lee was not looking for a pdf viewer, but trying to help me figure out what is going on with DocumentView. He just needed a hand in how to get the pdf file into the DocumentView.
Above is what he discovered and that should be looked at. After his testing he comes to a lot of conclusion I come to as well (see earlier posts in this thread), that something is off.

We, by now, both understood that the index is used to get the page, but there are :
- some properties that make no sense in what they return, something is off
- Property ShowPage sometimes shows wrong page number on the DocumentView. It should do:
index = 0 it shows actual page 1 and says 1/total on the view -> good
index = 1 it shows actual page 2 and says 2/total on the view -> good
etc..
I have had situation where:
index = 1 it shows actual page 2 and says 1.total on the veiw -> not good.
When this happens I can't scroll to the real page 1 on index 0 as somehow because of the ShowPage it thinks it is already on page 1 (although showing page 2). Since I created a thumbnail index I can click on the real page 1 and get there.
When I do this on the DocumentView (because of ShowPage =True) it shows that I go from page 1/total (showing page 2) to page 1/total (showing proper page 1 now), that seems like a bug to me..

So, please take some time to see what is happening and take away the confusion (or bugs) ;-)

gbWilly

[GambOS](https://gambos.gambas.one/)
[Gambas3 for Debian/Ubuntu](https://gitlab.com/gbWilly/gambas3-debian-repository)
[GambOS](https://gambos.gambas.one/)

...there is always a Catch if things go wrong!

Sent with [Proton Mail](https://proton.me/mail/home) secure email.

Follow-Ups:
Re: DocumentView confusionGianluigi <gradobag@xxxxxxxxxxx>
References:
DocumentView confusiongbWilly <gbWilly@xxxxxxxxxxxxxx>
Re: DocumentView confusionLee <t.lee.davidson@xxxxxxxxx>
Re: DocumentView confusiongbWilly <gbWilly@xxxxxxxxxxxxxx>
Re: DocumentView confusionLee <t.lee.davidson@xxxxxxxxx>
Re: DocumentView confusionFabien Bodard <gambas.fr@xxxxxxxxx>