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
    p1.png
    21.3 KB · Views: 156

vp2020

Member
Licensed User
Hi, I did an experiment to check whether the version of pdf.js cuases the pdf display error,

So I created a custom pdfviewer component with Pdf.js 2.1.266 used on my web page,
on SSL Secured site, custom pdfveiwer no display error, whereas as ABMPdfViewer reported error.

CompPdfViewer:
'Class module
Sub Class_Globals
    Public ABMComp As ABMCustomComponent
    
End Sub


'Initializes the object. You can add parameters To this method If needed.
Public Sub Initialize(InternalPage As ABMPage, ID As String)
    
    Dim CSS As String =""
    
    ABMComp.Initialize("ABMComp", Me, InternalPage, ID,CSS)

End Sub

Sub ABMComp_Build(InternalPage As ABMPage, internalID As String) As String
    
    Dim html As String
    
    html=$"
        <div>
            <iframe id="ksp" style="width:100%;height:500px;border: 0px"
            src="../../js/web/viewer.html?file=../../eCallRoll/uploads/1.pdf" class="only-print">
            </iframe>
        </div>

    "$

    Return html
    
End Sub

Build Modal Sheet:
Sub BuildModalDownload() As ABMModalSheet

    Dim myModal As ABMModalSheet
    myModal.Initialize(page, "ModalDW", False,ABM.MODALSHEET_TYPE_NORMAL, "")
    myModal.Content.UseTheme("modalcontent")
    myModal.Footer.UseTheme("modalfooter")
    myModal.Size=ABM.MODALSHEET_SIZE_NORMAL
    myModal.IsDismissible = False

    myModal.Content.AddRowsM(2,True,20,0,"").AddCellsOSMP(1,0,0,0,12,12,12,0,0,0,0,"")
    myModal.Content.BuildGrid

'    Dim PdfViewer As ABMPDFViewer
'    PdfViewer.Initialize(page, "PdfViewerDW", 500, "../uploads/1.pdf","")
'    PdfViewer.PreparePrintingText = "Preparing to print..."
'    PdfViewer.ReadDirection = ABM.Pdf_READDIRECTION_LTR
'    PdfViewer.AllowDownload = True
'    PdfViewer.AllowOpen = False
'    PdfViewer.AllowPrint = False
'    PdfViewer.AllowSideBar = False
'    PdfViewer.AllowViewBookmark = False
'       
'    myModal.Content.Cell(2,1).AddComponent(PdfViewer)


    Dim myViewer As CompPdfViewer
    myViewer.Initialize(page,"myViewer")
    
    myModal.Content.Cell(2,1).AddComponent(myViewer.ABMComp)


    ' create the buttons for the footer
    myModal.Footer.AddRowsM(1,True,0,0,"").AddCellsOS(1,10,10,10,1,1,1,"").AddCellsOS(1,0,0,0,1,1,1,"")
    myModal.Footer.BuildGrid

    Dim btnCancelDW As ABMButton
    btnCancelDW.Initializefloating(page, "btnCancelDW", "mdi-navigation-close", "")
    btnCancelDW.size = ABM.BUTTONSIZE_NORMAL
    
    myModal.Footer.Cell(1,1).PaddingTop="5px"
    myModal.Footer.Cell(1,1).AddComponent(btnCancelDW)

    Return myModal

End Sub

Please see the images attached.

May be the Pdf.js and other related js files wrapped with ABMPdfViewer are too old and have to be updated?
or may be this scenario only occurred in my server and not the common case.

Regards
 

Attachments

  • p1.png
    p1.png
    28.7 KB · Views: 122
  • p2.png
    p2.png
    216.6 KB · Views: 133
Upvote 0

Don Oso

Active Member
Licensed User
Longtime User
Hi, I did an experiment to check whether the version of pdf.js cuases the pdf display error,

So I created a custom pdfviewer component with Pdf.js 2.1.266 used on my web page,
on SSL Secured site, custom pdfveiwer no display error, whereas as ABMPdfViewer reported error.

CompPdfViewer:
'Class module
Sub Class_Globals
    Public ABMComp As ABMCustomComponent
  
End Sub


'Initializes the object. You can add parameters To this method If needed.
Public Sub Initialize(InternalPage As ABMPage, ID As String)
  
    Dim CSS As String =""
  
    ABMComp.Initialize("ABMComp", Me, InternalPage, ID,CSS)

End Sub

Sub ABMComp_Build(InternalPage As ABMPage, internalID As String) As String
  
    Dim html As String
  
    html=$"
        <div>
            <iframe id="ksp" style="width:100%;height:500px;border: 0px"
            src="../../js/web/viewer.html?file=../../eCallRoll/uploads/1.pdf" class="only-print">
            </iframe>
        </div>

    "$

    Return html
  
End Sub

Build Modal Sheet:
Sub BuildModalDownload() As ABMModalSheet

    Dim myModal As ABMModalSheet
    myModal.Initialize(page, "ModalDW", False,ABM.MODALSHEET_TYPE_NORMAL, "")
    myModal.Content.UseTheme("modalcontent")
    myModal.Footer.UseTheme("modalfooter")
    myModal.Size=ABM.MODALSHEET_SIZE_NORMAL
    myModal.IsDismissible = False

    myModal.Content.AddRowsM(2,True,20,0,"").AddCellsOSMP(1,0,0,0,12,12,12,0,0,0,0,"")
    myModal.Content.BuildGrid

'    Dim PdfViewer As ABMPDFViewer
'    PdfViewer.Initialize(page, "PdfViewerDW", 500, "../uploads/1.pdf","")
'    PdfViewer.PreparePrintingText = "Preparing to print..."
'    PdfViewer.ReadDirection = ABM.Pdf_READDIRECTION_LTR
'    PdfViewer.AllowDownload = True
'    PdfViewer.AllowOpen = False
'    PdfViewer.AllowPrint = False
'    PdfViewer.AllowSideBar = False
'    PdfViewer.AllowViewBookmark = False
'     
'    myModal.Content.Cell(2,1).AddComponent(PdfViewer)


    Dim myViewer As CompPdfViewer
    myViewer.Initialize(page,"myViewer")
  
    myModal.Content.Cell(2,1).AddComponent(myViewer.ABMComp)


    ' create the buttons for the footer
    myModal.Footer.AddRowsM(1,True,0,0,"").AddCellsOS(1,10,10,10,1,1,1,"").AddCellsOS(1,0,0,0,1,1,1,"")
    myModal.Footer.BuildGrid

    Dim btnCancelDW As ABMButton
    btnCancelDW.Initializefloating(page, "btnCancelDW", "mdi-navigation-close", "")
    btnCancelDW.size = ABM.BUTTONSIZE_NORMAL
  
    myModal.Footer.Cell(1,1).PaddingTop="5px"
    myModal.Footer.Cell(1,1).AddComponent(btnCancelDW)

    Return myModal

End Sub

Please see the images attached.

May be the Pdf.js and other related js files wrapped with ABMPdfViewer are too old and have to be updated?
or may be this scenario only occurred in my server and not the common case.

Regards
Hello your solutions i think its the way , in my case, ABMPdfViewer keeps loading pdf generated with PDFjet.. i believe.. and yes pdf.js used by this component its too old.

ABMaterial in the real life its unsupported library because this issues. I hope this library will be open source in the future.
 
Last edited:
Upvote 0
Top