Hi
We are working on a pwa that will run in the LANSA Mobile Wrapper. (reason: communication with devices/camera)
At the moment we have the following situation:
It is a big challenge to download a PDF from the server routine and show it (or at least save it on the device).
Does anyone have any idea how to do that?
- One way could be to send the pdf data in base64 and use the #SYS_WEB.CreateBlob on client to create a pdf again. But how to store or show this blob?
- And yes, there are other widgets such as xDeviceFileWrite or xDeviceFileTransfer but I don't think these will help me.
- And another way could be to convert the pdf to image, transfer in base64 and show in in an image container. But this feels unnatural and propably slow.
Thanks for any help...
Dominique
LANSA Mobile with Webpage how to show pdf
Re: LANSA Mobile with Webpage how to show pdf
Do you have a particular reason to download the pdf to the device before to show it?
If you have it in the server already, a simple sys_web.navigate can display it both in iOs and Android:
will show the pdf in the device
...and allow the user to download if he want it (in Android).
if you want the user to be able to download the pdf in iOs, then its better to include an html container like this
then in your code use the address of the document:
If you have it in the server already, a simple sys_web.navigate can display it both in iOs and Android:
Code: Select all
#SYS_WEB.Navigate Url('/images/temp/report0012389.pdf') Target(New)...and allow the user to download if he want it (in Android).
if you want the user to be able to download the pdf in iOs, then its better to include an html container like this
Code: Select all
Define_Com Class(#PRIM_WEB.HtmlContainer) Name(#Html1) Description('Html Container') Displayposition(2) Height(200) Left(53) Parent(#COM_OWNER) Tabposition(2) Tabstop(False) Top(99) Width(150)
Code: Select all
#Html1.html := '/images/temp/report0012389.pdf" download>Download PDF right here</a>'
Re: LANSA Mobile with Webpage how to show pdf
Hi Dino
Thanks for your answer.
One reason to download is that the pdf contains user sensitive data. That doesn't allows us to publish the pdf on a Server.
is "#SYS_WEB.Navigate Url('/images/temp/report0012389.pdf') Target(New)" in LANSA Mobile? We tried to execute a serverroutine with targed := new to download the pdf. While this was working in Browseer, LANSA Mobile ignored that command. It's only possible to use target =: current. But this is not working because you will loose your Mobile Session after displaying.
Another approach we tried was to convert the pdf into a base64 list and to display it as embedded data in HTML Container. That worked but the behavior of the HTML container was strange (no zoom, no pages, nothing)
Example Server
Example Web
At the moment we don't know how to solve this challenge.
Thanks for your answer.
One reason to download is that the pdf contains user sensitive data. That doesn't allows us to publish the pdf on a Server.
is "#SYS_WEB.Navigate Url('/images/temp/report0012389.pdf') Target(New)" in LANSA Mobile? We tried to execute a serverroutine with targed := new to download the pdf. While this was working in Browseer, LANSA Mobile ignored that command. It's only possible to use target =: current. But this is not working because you will loose your Mobile Session after displaying.
Another approach we tried was to convert the pdf into a base64 list and to display it as embedded data in HTML Container. That worked but the behavior of the HTML container was strange (no zoom, no pages, nothing)
Example Server
Code: Select all
Srvroutine Name(DownloadBase64) Session(*REQUIRED)
List_Map For(*OUTPUT) List(#iPDFBase) Parameter_Name(Base64List)
Define_Com Class(#PRIM_ALPH) Name(#Alpha)
Define_Com Class(#XPRIM_Binary) Name(#File)
*Info WXVLSTR = NVARCHAR(65535)
#File.FromFile Path(*PART_DIR_OBJECT + "PDFTest.pdf")
#Alpha := #File.AsBase64String
Dountil Cond(#Alpha.cursize *EQ 0)
If (#Alpha.cursize > 10000)
#WXVLSTR := #Alpha.Substring( 1 10000 )
Else
#WXVLSTR := #Alpha.Substring( 1 #Alpha.cursize )
Endif
Add_Entry To_List(#iPDFBase)
#Alpha := #Alpha.Substring( 10001 )
Enduntil
EndroutineCode: Select all
Mthroutine Name(GetBase64Stream)
Define_Com Class(#W3SM_PwaQVSession.DownloadBase64) Name(#Downloader)
Def_List Name(#iPDFBase) Fields(#WXVLSTR) Type(*WORKING) Entrys(*MAX)
#Downloader.ExecuteAsync Base64list(#iPDFBase)
Evtroutine Handling(#Downloader.Completed)
#largedata := *blanks
Selectlist Named(#iPDFBase)
#largedata += #WXVLSTR
Endselect
#Html1.html := ('<embed type="application/pdf" src="data:application/pdf;base64,&1" style="width:100%; height:100%;"/>').Substitute( #largedata )
Endroutine
EndroutineAt the moment we don't know how to solve this challenge.