Android Question Odd Behavior with CLV.sv.ScrollViewInnerPanel.Snapshot

MrKim

Well-Known Member
Licensed User
Longtime User
I decide for now the simplest way to get my printing done is to put everything in a CLV and use
Dim bmp As B4XBitmap = PrintCLV.sv.ScrollViewInnerPanel.Snapshot DestRect.Initialize(10,10,280, 835) pdf.Canvas.DrawBitmap(bmp, Null, DestRect) pdf.FinishPage
Which works fine - EXCEPT if I try to center the text, As I do on the first line,
B4X:
    NameLbl.SetTextAlignment("BOTTOM", "CENTER")
    Phone1Lbl.SetTextAlignment("BOTTOM", "CENTER")
    EmailLbl.SetTextAlignment("BOTTOM", "CENTER")

the text disappears on the bmp.

Here is a screenshot of the CLV on the Page:
1597978793991.png


Here is what the corresponding bmp looks like:
1597981930143.png


If I leave the first line Left Justified it works as expected.

I tried this in both debug and release mode with the same results.

The text also disappears if RIGHT justified.
 

Attachments

  • 1597979309078.png
    1597979309078.png
    91.3 KB · Views: 160
  • Screenshot_20200821-115013.png
    Screenshot_20200821-115013.png
    192.3 KB · Views: 186

MrKim

Well-Known Member
Licensed User
Longtime User
First step is to understand where is the problem. Show the bitmap with an ImageView. Are the titles missing?
Sorry if I wasn't clear. That is what the second image above is. The first image is the CLV (PrintCLV). As you can see the data is displayed (circled in Red). The second image is the BMP taken with PrintCLV.sv.ScrollViewInnerPanel.Snapshot displayed in an ImageView. I diddn't mean to include the two attachments. 159759...png is a screenshot of the pdf. I was originally going to just show the pdf and realized I better check the snapashot image first. The other attachment is basically a duplicate of the .bmp.
 
Upvote 0

MrKim

Well-Known Member
Licensed User
Longtime User
If I understand correctly the problem has nothing to do with the PDF but rather with the snapshot feature. Right?
Yes, I should have left out the portion about the pdf. When I started this post I was thinking it was a pdf issue since that was all I was looking at. Then I checked the snapshot/ The issue is with the snapshot.
 
Upvote 0

MrKim

Well-Known Member
Licensed User
Longtime User
Can you reproduce it in a small project?
Yes.
It took a while. It is some sort of timing issue. At first I couldn't duplicate it in a simple program because I was displaying the snapshot with a button. I inadvertently discovered the problem when I put a break-point on the ...ScrollViewInnerPanel.Snapshot line in MY programs's code. When I did that it worked the way it should. The problem only occurs when there is no break in the action between filling the CLV and running the snapshot.
Adding Sleep(0) before the snapshot line actually solves the problem.
In the code provided when you open PagePrint it will not display correctly. If you then click the button it will.
There is a lot of extra code in the sample, (including the extra page) because, as I said, at first I couldn't duplicate the problem so I added the Drawer menu and the extra page, etc. thinking something else in my program must be affecting it.

I love working with pages. So simple. Thank you for all of your work.
 

Attachments

  • SnapshotError.zip
    15.8 KB · Views: 183
Last edited:
Upvote 0
Top