B4J Question ABMPDFViewer pdf file not displayed

vp2020

Member
Licensed User
Hi, Server pdf file did not display on client page's ABMPDFViewer control, but the file can be downloaded if press download button.
Anyone could tell me how to solve this problem?

B4X:
    Dim PdfViewer As ABMPDFViewer
    PdfViewer.Initialize(page, "PdfViewer", 800, "../uploads/" & ClassID & ".pdf?" & DateTime.Now,"")
    PdfViewer.PreparePrintingText = "Preparing to print..."
    PdfViewer.ReadDirection = ABM.Pdf_READDIRECTION_LTR
    PdfViewer.AllowDownload = True
    PdfViewer.AllowOpen = False
    PdfViewer.AllowPrint = False
    PdfViewer.AllowSideBar = True
    PdfViewer.AllowViewBookmark = False
  
    page.CellR(1,1).AddComponent(PdfViewer)
 

Attachments

  • p1.png
    21.3 KB · Views: 214

vp2020

Member
Licensed User
Thanks to alwaysbusy and Harris,
PdfViewer.AllowOpen = true and after cell assigment refresh pdfviewer still not working,
I guess may be network delay causes the display issue,
if server and client page on the same computer, there is no display problem,
but local client and remote server (not the same computer) the file will not be displayed.
 
Upvote 0

vp2020

Member
Licensed User
I check server log file, found the following error log:
java.nio.channels.ClosedChannelException
at org.eclipse.jetty.http2.HTTP2Session$ControlEntry.succeeded(HTTP2Session.java:1226)
at org.eclipse.jetty.http2.HTTP2Flusher$Entry.complete(HTTP2Flusher.java:319)
at org.eclipse.jetty.http2.HTTP2Flusher$Entry.access$200(HTTP2Flusher.java:294)
at org.eclipse.jetty.http2.HTTP2Flusher.lambda$complete$0(HTTP2Flusher.java:217)
at java.util.ArrayList.forEach(Unknown Source)
at org.eclipse.jetty.http2.HTTP2Flusher.complete(HTTP2Flusher.java:217)
at org.eclipse.jetty.http2.HTTP2Flusher.process(HTTP2Flusher.java:192)
at org.eclipse.jetty.util.IteratingCallback.processing(IteratingCallback.java:241)
at org.eclipse.jetty.util.IteratingCallback.iterate(IteratingCallback.java:224)
at org.eclipse.jetty.http2.HTTP2Session.frame(HTTP2Session.java:676)
at org.eclipse.jetty.http2.HTTP2Session.frames(HTTP2Session.java:648)
at org.eclipse.jetty.http2.HTTP2Session.control(HTTP2Session.java:634)
at org.eclipse.jetty.http2.HTTP2Session.onGoAway(HTTP2Session.java:433)
at org.eclipse.jetty.http2.parser.BodyParser.notifyGoAway(BodyParser.java:187)
at org.eclipse.jetty.http2.parser.GoAwayBodyParser.onGoAway(GoAwayBodyParser.java:169)
at org.eclipse.jetty.http2.parser.GoAwayBodyParser.parse(GoAwayBodyParser.java:139)
at org.eclipse.jetty.http2.parser.Parser.parseBody(Parser.java:182)
at org.eclipse.jetty.http2.parser.Parser.parse(Parser.java:110)
at org.eclipse.jetty.http2.parser.ServerParser.parse(ServerParser.java:115)
at org.eclipse.jetty.http2.HTTP2Connection$HTTP2Producer.produce(HTTP2Connection.java:202)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:211)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:126)
at org.eclipse.jetty.http2.HTTP2Connection.onFillable(HTTP2Connection.java:116)
at org.eclipse.jetty.http2.HTTP2Connection$FillableCallback.succeeded(HTTP2Connection.java:254)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:110)
at org.eclipse.jetty.io.ssl.SslConnection.onFillable(SslConnection.java:289)
at org.eclipse.jetty.io.ssl.SslConnection$3.succeeded(SslConnection.java:149)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:110)
at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124)
at org.eclipse.jetty.util.thread.Invocable.invokePreferred(Invocable.java:135)
at org.eclipse.jetty.util.thread.Invocable$InvocableExecutor.invoke(Invocable.java:222)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:294)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:199)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:673)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:591)
at java.lang.Thread.run(Unknown Source)
 
Upvote 0

vp2020

Member
Licensed User
Press F12, found the followr warning:

pdf.worker.min.js:1 The provided value 'moz-chunked-arraybuffer' is not a valid enum value of type XMLHttpRequestResponseType.
(anonymous) @ pdf.worker.min.js:1
 
Upvote 0

vp2020

Member
Licensed User
@alwaysbusy:
Sorry! I could not mail you because this is company file.
but you remind me that file size may be the problem.

yes it is! I compress the original pdf file from 220k to 74k, now the file was displayed normally.
So we have to separate big pdf file to more than one pdf files and displayed by AbmPdfViewer separately.

may I know that AbmPdfViewer has file size limit?
 
Upvote 0

vp2020

Member
Licensed User
SSL secured site (myApp.StartServerHTTP2) may cause the display issue.
See the images attached, I run my webapp with SSL secured, the pdf document did not be displayed and server log file reported errors,
if I run the app without SSL, the pdf document displayed normally and no errors.
ABMPdfViewer was not compatible with HTTP2?
 

Attachments

  • p1.png
    23.5 KB · Views: 186
  • p2.png
    142.6 KB · Views: 184
Upvote 0

Harris

Expert
Licensed User
Longtime User
Where is the PDF located - local server or some where else?
All my PDF's are stored on local server (never an issue) - yet I can't see how outside storage would affect this...
One never knows... Weird beans indeed...
 
Upvote 0

vp2020

Member
Licensed User
located at the local server.

B4X:
Dim s As String="https://ehostel.xxx.xxx:xxx/xxx/uploads/1.pdf?" & DateTime.Now  '(same domian origin)
PdfViewer.SetDocument(s)
or
B4X:
Dim s As String="../uploads/1.pdf?" & DateTime.Now
PdfViewer.SetDocument(s)
the pdf did not be displayed on the secure site.
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
Dim s As String="https://ehostel.xxx.xxx:xxx/xxx/uploads/1.pdf?" & DateTime.Now
Why use this?

Any client is asking the server for the PDF...
so the server will deliver: Dim s As String="../uploads/1.pdf?" & DateTime.Now

Yet, don't quite understand your code... (ie. 1.pdf?"&Dateime.Now) - unique naming???

Supply a code tag snippet...
 
Upvote 0

vp2020

Member
Licensed User
Oh!no I just used 1.pdf (from ABMMaterial demo 42mb file size) for testing, the actual code as belows:
B4X:
Dim myModal As ABMModalSheet=page.ModalSheet("ModalDW")
Dim PdfViewer As ABMPDFViewer = myModal.Content.Component("PdfViewerDW")
Dim PdfFileName As String

PdfFileName = userID & DateTime.Now & ".pdf"
'''''''
If FileCreated Then
    'Dim s As String="../uploads/1.pdf?" & DateTime.Now
    'PdfViewer.SetDocument(s)
    PdfViewer.SetDocument("../temp/" & PdfFileName)
    'PdfViewer.Refresh
    page.ShowModalSheet("ModalDW")
    'PdfViewer.Refresh
Else
    page.Msgbox("","Please try later!","eHostel","OK",False,ABM.MSGBOX_POS_CENTER_CENTER,"")
End If
'''''

I tried this: Dim s As String="https://ehostel.xxx.xxx:xxx/xxx/uploads/1.pdf?" & DateTime.Now
just to figure out whether the document need to be came from same domian origin, please ignore this line of code.
 
Last edited:
Upvote 0

Harris

Expert
Licensed User
Longtime User
Opps - AB beat me to it - with perhaps a more reasonable answer... - cause I am shooting in the dark here..

PdfViewer.SetDocument("../temp/" & PdfFileName)
Is this a valid dir?
Your last post stated this is the location for the PDF:
Dim s As String="../uploads/1.pdf?" & DateTime.Now

Truely, it aint that difficult... (SSL or not)...
 
Upvote 0

vp2020

Member
Licensed User
Many Thanks to Harris and alwaysbusy.

S2L1 file size 75kb, no error:



S3E1.pdf file size 220kb, reported error:



http site absolutely no error, I totally no idea why?

may be something wrong on my server firewall SSL settings, I am going to further studies.

Once agian thanks alot to your help!
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
Are you by any chance using HAProxy? I could find back in my emails with the tech team, we did also have a ERR_HTTP2_PROTOCOL_ERROR and they reported back to me that there was a bug in HAProxy (https://github.com/haproxy/haproxy/issues/798) and by downgrading to a lower version that not had this problem it was fixed.

I now see the version they use is: HA-Proxy version 2.2.8-1~bpo9+1 2021/01/14, so I suppose this bug is now fixed and they recently updated it to the latest version.
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
Wow man, I am out of here... Sorry...
Maye I (and others) can learn something here...
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…