Android Question Get File Path of Created PDF frpm WebView with Printmanager

RiverRaid

Active Member
Licensed User
Longtime User
Hi at all!

I create a PDF from my WebView with the following code:

B4X:
Dim jwv As JavaObject = WebCov 'WebView
    Dim jPrintManager As JavaObject = jwv.RunMethodJO("getContext", Null).RunMethod("getSystemService", Array As Object("print"))
 
    Dim jPrintAdapter As JavaObject = jwv .RunMethod("createPrintDocumentAdapter", Array As Object("NegativErgebnis_" & DateTime.GetDayOfMonth(DateTime.Now) & DateTime.GetMonth(DateTime.Now) & DateTime.GetYear(DateTime.Now) & ".pdf"))
    Dim jobName As String = "Document"
    jPrintManager.RunMethod("print", Array As Object(jobName, jPrintAdapter, Null))

and it works quite well, the Print Dialog shows up and im able to save the PDF file.

However, I would like to share the created PDF, is it possible to get the Filename? (or to specifiy a non-changeable Filename so that I know, where the file is? Thank you very much!
 

drgottjr

Expert
Licensed User
Longtime User
you need a listener for print done. when the print done fires, you can save the print document. i don't think you can do it with javaobject the way you've handled the printing. if it were me, i would do the whole thing in inline java and with a single javaobject to call it.
this is where i got my information: https://developer.android.com/training/printing/custom-docs
at the very bottom, it refers to saving the document after printing it. once it's saved somewhere it could be shared.
i hope i understand your question correctly. on the one hand you say you're able to save the file
and im able to save the PDF file.
,
and on the other, you ask about getting the filename.
is it possible to get the Filename

something doesn't sound right.
 
Upvote 0
Top