B4J Question [sithaso] [banano] [jsPDF] how to save a PDF into server folder?

giannimaione

Well-Known Member
Licensed User
Longtime User
hello,
i use banano + sithasodaisy +jspdf

with jsPDF.save, i can save a pdf document "only ?" on desktop pc;
can I save to the server folder?
 

giannimaione

Well-Known Member
Licensed User
Longtime User
I dont think its possible, unless you might be using BANanoServer.
hi,
i use a classic web server;

i found a free php script with this fpdp.org
how to integrate a php script ?
B4X:
<?
php require('fpdf.php');
$pdf = new FPDF(); 
$pdf->AddPage(); 
$pdf->SetFont('Arial','B',16); 
$pdf->Cell(40,10,'Hello World!'); 
$pdf->Output(); ?> 'param I, D, F, S
>
 
Last edited:
Upvote 0

Mashiane

Expert
Licensed User
Longtime User
hi,
i use a classic web server;

i found a free php script with this fpdp.org
how to integrate a php script ?
B4X:
<?
php require('fpdf.php');
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'Hello World!');
$pdf->Output(); ?> 'param I, D, F, S
>
Perhaps this could help.

 
Upvote 0

giannimaione

Well-Known Member
Licensed User
Longtime User
B4X:
Dim result As BANanoObject = banano.Await(pdf.blob)
      Dim f As BANanoObject
    f.Initialize2("File",Array(Array(result), "testpdf.pdf", CreateMap("type": result.getfield("type"))))
    banano.Await(SDUIShared.UploadFileOptionsWait(f, "../assets", "n"))
this is perfect,
in my assets there is a file "testpdf.pdf" !!!

but on log browser there is:
Uncaught (in promise) SyntaxError: Unexpected token '<', "<br />
<b>"... is not valid JSON
at JSON.parse (<anonymous>)
at banano_sithasodaisy_sduishared.uploadfileoptionswait (sithasodaisy.js:33:76209)
at async banano_webciurell_vendita.stampavendita (app1725186203367.js:3:102114)
at async banano_webciurell_vendita.tblvendite_btstampa (app1725186203367.js:3:97980)
B4X:
sithasodaisy.js:33:76209
  _res = await callAjaxWait("./assets/uploadoptions.php", "POST", "", _fd, true, null);
  _result = JSON.parse(_res);
they are errors or they are not important ?
 
Upvote 0

Mashiane

Expert
Licensed User
Longtime User
this is perfect,
in my assets there is a file "testpdf.pdf" !!!

but on log browser there is:

B4X:
sithasodaisy.js:33:76209
  _res = await callAjaxWait("./assets/uploadoptions.php", "POST", "", _fd, true, null);
  _result = JSON.parse(_res);
they are errors or they are not important ?
The error is generated by php.
 
Upvote 0

giannimaione

Well-Known Member
Licensed User
Longtime User
hi,
I cannot reproduce your error
please, see a demo attached.
show log of browser
SORRY:
error is only on local with LARAGON;
on my website IS OK!
 

Attachments

  • demopdf.zip
    320.2 KB · Views: 57
Last edited:
Upvote 0

giannimaione

Well-Known Member
Licensed User
Longtime User
ok;
now i save a pdf file into a folder named "documents" of website;
question:
how to send email with attached a pdf file ?
how to "run" a php script on website?
 
Upvote 0

giannimaione

Well-Known Member
Licensed User
Longtime User
on my website there is this script php
example.php
B4X:
<?php
// Dati per l'email
$to = "destinatario@example.com";  // Indirizzo email del destinatario
$subject = "Oggetto dell'email";    // Oggetto dell'email
$message = "Questo è il contenuto del messaggio.";  // Contenuto del messaggio

// Intestazioni dell'email
$headers = "From: mittente@example.com" . "\r\n" .
           "Reply-To: mittente@example.com" . "\r\n" .
           "X-Mailer: PHP/" . phpversion();

// Invio dell'email
if (mail($to, $subject, $message, $headers)) {
    echo "Email inviata con successo!";
} else {
    echo "Errore nell'invio dell'email.";
}
?>
if type address on browser "https://mywebsite.abc/example.php", it run very well
how to run it with BANano/SithasoDaisy ?
B4X:
Dim headers As Map
    headers.initialize
    headers.put("Content-Type", "application/json")
    headers.Put("Access-Control-Allow-Origin", "*") 
    banano.CallAjax("https://mywebsite.abc/example.php", "GET", "jsonp", "", "ID0", False, headers)
this not send email
 
Upvote 0

Mashiane

Expert
Licensed User
Longtime User
I have prepared a thread here to explain more about BANanoInlinePHP.

 
Last edited:
Upvote 0
Top