Android Question PDFium strange compile error - cannot find symbol

Moosi

Member
Licensed User
Longtime User
Hi,

I´m using the nice PDFium wrapper, which really works great.

Unfortunately I get an strange compile Error when trying to create an Bitmap from one PDF page as shown here:
https://www.b4x.com/android/forum/bookmarks/?type=post&id=644677

B4X:
B4A Version: 9.50
Java Version: 8
Parse den Code.    (0.00s)
Building folders structure.    (0.01s)
Kompiliere den Code.    (0.02s)
Kompiliere Layoutcode.    (0.00s)
Organisiere Libraries.    (0.00s)
    (AndroidX SDK)
Generiere R Datei.    (0.00s)
Kompiliere generierten Java Code.    Error
B4A line: 50
pdf.renderPageBitmap(glDoc,bmp,page,0,0,600dip,60
javac 1.8.0_202
src\b4a\example\main.java:454: error: cannot find symbol
mostCurrent._pdf.renderPageBitmap((com.shockwave.pdfium.PdfDocument)(_gldoc),(Bitmap)(_bmp.getObject()),_page,(int) (0),(int) (0),anywheresoftware.b4a.keywords.Common.DipToCurrent((int) (600)),anywheresoftware.b4a.keywords.Common.DipToCurrent((int) (600)));
                                                                              ^
  symbol:   class Bitmap
  location: class main

This is the Sub in question:
B4X:
Sub RenderPDFThumbnail(TheFilename As String, page As Int)
    Dim bmp As Bitmap
    Dim glDoc As Object
    glDoc = pdf.newDocument(File.DirInternal,TheFilename, 268435456,"")
    bmp.InitializeMutable(600dip,600dip) 
    pdf.openPage(glDoc,page)
   
    pdf.renderPageBitmap(glDoc,bmp,page,0,0,600dip,600dip) '<-- this line raises the compile error
   
    Dim out As OutputStream = File.OpenOutput(File.DirInternal, "Out.jpg", False)
    bmp.WriteToStream(out, 80, "JPEG")
    out.Close
End Sub
r

Especially surprising is the fact that I can compile the app with line "commented out" and then use HotSwap to uncomment. That way everything works as expected.

Attached you will finde an reduced test.

It would be really great if someone has an idea.

Thanks in advance
Moosi
 

Attachments

  • PDFiumTest.zip
    178.7 KB · Views: 348

DonManfred

Expert
Licensed User
Longtime User
Try it with v1.04
The method expect an Object now. But you can use your Bitmap here.

this works with 1.04 but failed with the same compile error as your code with 1.03.

B4X:
Sub PDFium_onPageChanged(page As Int, TotalPages As Int)
    Log($"PDFium_onPageChanged(${page},${TotalPages})"$)
    lblPages.Text = $"${page-1}/${glPages}"$
    Dim bmp As Bitmap
    bmp.InitializeMutable(640dip,480dip) ' Bitmap on which the Page is rendered
    Log("OpenPage")
    pdf.openPage(glDoc,page) ' Mandatory to do before you want to render a Page   
    Log("RenderBitmap")
    
    pdf.renderPageBitmap(glDoc,bmp,page,0,0,640dip,480dip)
    Log("Set Bitmap to Imageview")
    image.Bitmap = bmp
    ' You can also save the Bitmap to a File. Do what you want with it ;-)   
End Sub
 
Upvote 0

Moosi

Member
Licensed User
Longtime User
Hey Manfred,
thanks a lot for the quick action. It works like a charm now. :D
You are doing an impressive job for the B4X community.
 
Upvote 0
Top