B4J Question Apache PDFBox

amaxco

Member
Licensed User
Longtime User
Hi,

I am inquiring about whether there is any implementation of the above library in B4J and if it has a built-in viewer.

Regards
 

amaxco

Member
Licensed User
Longtime User
I'm using the same library (modified for ABMaterial) and my url looks like this:

./viewerpdf.html?file=../PDF/1.pdf

so myabe in your case you could try something similar?

file:/C:/temp/ViewerJS/index.html?file=file:/C:/temp/pdftest.pdf

@alwaysbusy Thank you for your response

I tried your syntax (file:/C:/temp/ViewerJS/index.html?file=file:/C:/temp/pdftest.pdf) against @Daestrum (file:/C:/temp/ViewerJS/index.html#file:/C:/temp/pdftest.pdf) but no luck so far.
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
Have you tried it with a different pdf file ?
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
It seems that putting the webview in a pane and using these lines of code is the problem
B4X:
webview2.PrefWidth=Pane2.width-25
webview2.PrefHeight=Pane2.height-25

They are returning the width and height of Pane2 as 0 (zero) therefore the webview is being resized to -25 x -25 so you cant see it.
(prefWidth and prefHeight also return 0)

I had to explicitly set the pane width and height when I added it to the rootpane (f1.rootpane.addnode(p1,0,0,600,600) before the webview was visible.
 
Upvote 0

amaxco

Member
Licensed User
Longtime User
It seems that putting the webview in a pane and using these lines of code is the problem
B4X:
webview2.PrefWidth=Pane2.width-25
webview2.PrefHeight=Pane2.height-25

They are returning the width and height of Pane2 as 0 (zero) therefore the webview is being resized to -25 x -25 so you cant see it.
(prefWidth and prefHeight also return 0)

I had to explicitly set the pane width and height when I added it to the rootpane (f1.rootpane.addnode(p1,0,0,600,600) before the webview was visible.

Below is the log:

Waiting for debugger to connect...
Program started.
file:/C:/temp/ViewerJS/index.html
file:/C:/temp/pdftest.pdf
file:/C:/temp/ViewerJS/index.html#file:/C:/temp/pdftest.pdf
webview2 PrefWidth: 465
webview2 Prefheight : 400
 
Upvote 0

amaxco

Member
Licensed User
Longtime User
Is it possible to test opening a pdf directly in ViewerJS.html? If so, what will be the syntax?
 

Attachments

  • ViewerJs_02.png
    ViewerJs_02.png
    180.5 KB · Views: 206
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
if you have a pdf to try - then its
file:/C:/temp/ViewerJS/index.html#file:/where/your/pdf/file/is.pdf
 
Upvote 0

amaxco

Member
Licensed User
Longtime User
if you have a pdf to try - then its
file:/C:/temp/ViewerJS/index.html#file:/where/your/pdf/file/is.pdf

I found the problem! But, partly solved.

Strangely, the file to be uploaded, pasting the link directly, must be in the insie the ViewerJS folder. The webview is still behind!

It seems the problem is not the webview object but file path issue. Now I do not know how to fix that.
 

Attachments

  • ViewerJs_03.png
    ViewerJs_03.png
    186.3 KB · Views: 201
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
The load method is built into javafx webengine, so can't do anything to that.

If I paste the address file:/C:/temp/ViewerJS/index.html#file:/C:/temp/pdftest.pdf directly into my browser it works as expected.

The pdf can be anywhere on my pc, I don't need it to be in the viewerjs directory.
 
Upvote 0

amaxco

Member
Licensed User
Longtime User
The load method is built into javafx webengine, so can't do anything to that.

If I paste the address file:/C:/temp/ViewerJS/index.html#file:/C:/temp/pdftest.pdf directly into my browser it works as expected.

The pdf can be anywhere on my pc, I don't need it to be in the viewerjs directory.

It seems like I hit on a dead end road! I tried every thing in my capacity to fiddle with the code. Only a complete sample app can help.

Thanks to all who offered their help
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
This is the full code that I have been using. It has calling viewer directly and calling showpdffile(filename) to open a new window with a viewer in.
 

Attachments

  • viewrjs full prog.zip
    2.1 KB · Views: 227
Upvote 0

amaxco

Member
Licensed User
Longtime User
This is the full code that I have been using. It has calling viewer directly and calling showpdffile(filename) to open a new window with a viewer in.

Thank you so much.

Unfortunately, the same situation exists. I must not doubt your code is function. Maybe I relax for some time and try again later.

Regards
 

Attachments

  • ViewerJs_04.png
    ViewerJs_04.png
    115.3 KB · Views: 257
Upvote 0
Top