B4J Question Use Java code to place PDF view on a pane in b4j

Markos

Active Member
Licensed User
Hi All,

I believe this Java code works but I need to be able to show the Object which in this case is a PDF but it keeps saying :
Compiler Result:
B4J Version: 8.10
Java Version: 11
Parsing code.    (0.00s)
Building folders structure.    (0.01s)
Compiling code.    (0.00s)
Compiling layouts code.    (0.00s)
Organizing libraries.    (0.00s)
Compiling generated Java code.    Error
src\com\progwhiz\testpdf\main.java:119: error: incompatible types: PDFViewerBean cannot be converted to Node
 return new BorderPane(myViewer);
                       ^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output

1 error

javac 11.0.1

The entire source is:

PDF URL Viewer:
#Region Project Attributes
    #MainFormWidth: 600
    #MainFormHeight: 600
'    #AdditionalJar: jPDFViewer.v2019R1.08.jar
    #AdditionalJar: jPDFViewer.jar
#End Region

Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
     Dim inline As JavaObject
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    inline = Me
    MainForm.Show
    ' c:/temp/pdftest.pdf in the following line is the name of the pdf file
    'MainForm.RootPane.AddNode(inline.RunMethod("newViewer",Array("c:/temp/pdftest.pdf")),0,0,600,600)
    MainForm.RootPane.AddNode(inline.RunMethod("newViewer",Array("https://www.progwhiz.com/tester/testpage.pdf")),0,0,600,600)
'    MainForm.RootPane.AddNode(inline.RunMethod("newViewer","https://www.progwhiz.com/tester/testpage.pdf"),0,0,600,600)
End Sub
#if java
import java.net.*;
import java.io.*;
import java.lang.Object;
import java.awt.Component;
import java.awt.Container;
import javax.swing.JComponent;
import javax.swing.JPanel;
import com.qoppa.pdfViewer.PDFViewerBean;
import com.qoppa.pdf.actions.Action;
import com.qoppa.pdf.actions.URLAction;
//import com.qoppa.pdfProcess.PDFDocument;
import com.qoppa.pdf.PDFException;


import javafx.scene.layout.BorderPane;
static PDFViewerBean myViewer;

public static BorderPane newViewer(String pdf){
 myViewer = new PDFViewerBean();


 try{
URL url = new URL(pdf);
    myViewer.loadPDF(url);
 }
 catch (PDFException pdferr){
    System.out.println(pdferr);
 }
 return new BorderPane(myViewer);
}
#end if
'Return true to allow the default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
    Return True
End Sub
 

ivanomonti

Well-Known Member
Licensed User
you've solved the mistake, if you give me some tracks I'd need to make a pdf reader too, Thank
 
Upvote 0
Top