• Home
  • Forum
  • Fare Web
  • PHP

[PHP] Stampare dati Form su immagine di sfondo con html

  • Creatore Discussione Creatore Discussione Fuego2806
  • Data di inizio Data di inizio 27 Lug 2016
Prec.
  • 1
  • 2
  • 3
  • 4
Primo Prec. 4 di 4

Fuego2806

Utente Attivo
27 Lug 2016
72
2
8
  • 31 Lug 2016
  • #61
Ah, questo codice non so di dovrebbero aggiustare le variabili per il testo... Perché es.$data non lo accetta....
 

criric

Super Moderatore
Membro dello Staff
SUPER MOD
MOD
21 Ago 2010
5.606
54
48
TN
  • 31 Lug 2016
  • #62
Fuego2806 ha scritto:
(visto che Altervista accetta solo da remoto)
Clicca per allargare...
non capisco, cosa vuol dire ?
 

Fuego2806

Utente Attivo
27 Lug 2016
72
2
8
  • 31 Lug 2016
  • #63
Non è possibile aprire un'immagine "remota" su AlterVista, il file immagine deve essere presente nello spazio web

Ho sbagliato a scrivere
 

criric

Super Moderatore
Membro dello Staff
SUPER MOD
MOD
21 Ago 2010
5.606
54
48
TN
  • 31 Lug 2016
  • #64
te l'avevo scritto nel post #56 terza pagina vai a vedere
 

Fuego2806

Utente Attivo
27 Lug 2016
72
2
8
  • 31 Lug 2016
  • #65
Fuego2806 ha scritto:
Come lo adatteresti questo codice con immagine e font inserite anche tramite FTP e quindi da remoto (visto che Altervista accetta solo da remoto)...
PHP:
<?php
/**
* Returns with of a line.
* @param array $boudning_box Bounding box
* @return Width of the box
*/
function line_width($bounding_box) {
return abs($bounding_box[2] - $bounding_box[0]);
}


/**
* Returns height of a line.
* @param array $boudning_box Bounding box
* @return Height of the box
*/
function line_height($bounding_box) {
return abs($bounding_box[1] - $bounding_box[5]);
}


/**
* Writes a line of text
* @param resrouce $image PHP GD image
* @param int $size Font size
* @param int|string $x X-coordinate or 'LEFT', 'CENTER', 'RIGHT'
* @param int $y Y-coordinate
* @param int $color Color index
* @param string $font Path to the font
* @param string $text Text to write
* @return Bounding box
*/
function write_line($image, $size, $x, $y, $color, $font, $text) {
$bbox = imagettfbbox($size, 0.0, $font, $text);
$width = line_width($bbox);
$height = line_height($bbox);

if ($x == 'LEFT') {
$x = 0;
} else if ($x == 'CENTER') {
$x = (imagesx($image) - $width) / 2.0;
} else if ($x == 'RIGHT') {
$x = imagesx($image) - $width;
}

imagettftext($image, $size, 0.0, $x, $y + $height, $color, $font, $text);

return $bbox;
}

/**
* Writes multiples lines of text.
* @param resrouce $image PHP GD image
* @param int $size Font size
* @param int|string $x X-coordinate or 'LEFT', 'CENTER', 'RIGHT'
* @param int $y Y-coordinate
* @param int $color Color index
* @param string $font Path to the font
* @param array $text Array of lines to write
* @param int $padding Space between lines
*/
function write_lines($image, $size, $x, $y, $color, $font, $text, $padding = 0) {
foreach ($text as $line) {
$bbox = write_line($image, $size, $x, $y, $color, $font, $line);
$y += line_height($bbox) + $padding;
}
}




// Imposta lo header
header('Content-type: image/png');

// Legge i dati
$nome = $_POST['nome'];
$grado = $_POST['grado'];
$officiante = $_POST['officiante'];
$diocesi = $_POST['diofun'];
$arcidiocesi = $_POST['arcifun'];
$data = $_POST['datafun'];

// Legge l'immagine di sfondo ed imposta il colore del testo
$image = imagecreatefromjpeg("http://i.imgur.com/vOZBXEo.jpg");
$color = imagecolorallocate($image, 0x8B, 0x00, 0x00);

// Imposta le righe di testo da scrivere
$text = array(
"Il fedele dell'Altissimo chiamato",
$nome,
"dopo la prematura morte,",
"ha ricevuto il sacramento del funerale,",
"dal $grado$officiante",
"nella Parrocchia di $diocesi, Arcidiocesi di $arcidiocesi,",
"in data $data"
);

// Scrive il testo
write_lines($image, 14, 'CENTER', 350, $color, "http://www.princexml.com/fonts/larabie/kimberle.ttf", $text, 5);

// Mostra l'immagine
imagepng($image);
Clicca per allargare...
 

criric

Super Moderatore
Membro dello Staff
SUPER MOD
MOD
21 Ago 2010
5.606
54
48
TN
  • 31 Lug 2016
  • #66
devi salvare l'immagine nella stessa cartella del file php e modificare la chiamata all'immagine
PHP:
$image = imagecreatefromjpeg("http://i.imgur.com/vOZBXEo.jpg");
con
PHP:
$image = imagecreatefromjpeg("vOZBXEo.jpg");
come avevo scritto, non sprei spiegartelo in altro modo
 

Fuego2806

Utente Attivo
27 Lug 2016
72
2
8
  • 31 Lug 2016
  • #67
Ho salvato sia il file php e sia l'immagine jpeg nella cartella principale del sito.
 

Fuego2806

Utente Attivo
27 Lug 2016
72
2
8
  • 31 Lug 2016
  • #68
Problema risolto: guarda qui: http://iabasic1.altervista.org/certificato-di-funerale

Ho inserito questo codice:

PHP:
<?php
/**
* Returns with of a line.
* @param array $boudning_box Bounding box
* @return Width of the box
*/
function line_width($bounding_box) {
        return abs($bounding_box[2] - $bounding_box[0]);
}


/**
* Returns height of a line.
* @param array $boudning_box Bounding box
* @return Height of the box
*/
function line_height($bounding_box) {
        return abs($bounding_box[1] - $bounding_box[5]);
}


/**
* Writes a line of text
* @param resrouce   $image PHP GD image
* @param int        $size  Font size
* @param int|string $x     X-coordinate or 'LEFT', 'CENTER', 'RIGHT'
* @param int        $y     Y-coordinate
* @param int        $color Color index
* @param string     $font  Path to the font
* @param string     $text  Text to write
* @return Bounding box
*/
function write_line($image, $size, $x, $y, $color, $font, $text) {
        $bbox = imagettfbbox($size, 0.0, $font, $text);
        $width = line_width($bbox);
        $height = line_height($bbox);

        if ($x == 'LEFT') {
                $x = 0;
        } else if ($x == 'CENTER') {
                $x = (imagesx($image) - $width) / 2.0;
        } else if ($x == 'RIGHT') {
                $x = imagesx($image) - $width;
        }

        imagettftext($image, $size, 0.0, $x, $y + $height, $color, $font, $text);

        return $bbox;
}

/**
* Writes multiples lines of text.
* @param resrouce   $image   PHP GD image
* @param int        $size    Font size
* @param int|string $x       X-coordinate or 'LEFT', 'CENTER', 'RIGHT'
* @param int        $y       Y-coordinate
* @param int        $color   Color index
* @param string     $font    Path to the font
* @param array      $text    Array of lines to write
* @param int        $padding Space between lines
*/
function write_lines($image, $size, $x, $y, $color, $font, $text, $padding = 0) {
        foreach ($text as $line) {
                $bbox = write_line($image, $size, $x, $y, $color, $font, $line);
                $y += line_height($bbox) + $padding;
        }
}





header('Content-type: image/jpeg');


$nome        = $_POST['nome'];
$grado       = $_POST['grado'];
$officiante  = $_POST['officiante'];
$diocesi     = $_POST['diofun'];
$arcidiocesi = $_POST['arcifun'];
$data        = $_POST['datafun'];


$image = imagecreatefromjpeg("certificato_funerale.jpg");
$color = imagecolorallocate($image, 0x8B, 0x00, 0x00);


$text = array(
        "Il fedele dell'Altissimo chiamato",
        $nome,
        "dopo la prematura morte,",
        "ha ricevuto il sacramento del funerale,",
        "dal $grado $officiante",
        "nella Parrocchia di $diocesi, Arcidiocesi di $arcidiocesi,",
        "in data $data"
);


write_lines($image, 14, 'CENTER', 350, $color, "Fancy_Caps.ttf", $text, 5);


imagejpeg($image);
 

Fuego2806

Utente Attivo
27 Lug 2016
72
2
8
  • 31 Lug 2016
  • #69
Però.... Mi fa salvare l'immagine.... Ma esce come file php

P.s. E se faccio upload su un sito (es. Tinypic, Imgur, etc) mi compare solo immagine + testo (SENZA IL TESTO COMPILATO NEL FORM).
 

Fuego2806

Utente Attivo
27 Lug 2016
72
2
8
  • 1 Ago 2016
  • #70
Problema risolto, ho inserito solo uno header sotto all altro, questo:
PHP:
header('Content-Disposition: inline; filename=certificato_funerale.jpg');
 
Reactions: criric

Fuego2806

Utente Attivo
27 Lug 2016
72
2
8
  • 16 Ago 2016
  • #71
Mi sai dire come posso far uscire la schermata di login come questo e che template è?

 
Prec.
  • 1
  • 2
  • 3
  • 4
Primo Prec. 4 di 4
Devi accedere o registrarti per poter rispondere.

Discussioni simili

F
[PHP] Stampare dati inviati tramite ajax
  • Fabio_97
  • 11 Ago 2016
  • PHP
Risposte
0
Visite
2K
PHP 11 Ago 2016
Fabio_97
F
Y
Stampare da php su un foglio A6 attraverso una stampante esterna
  • yoyo2210
  • 5 Ott 2021
  • PHP
Risposte
1
Visite
1K
PHP 5 Ott 2021
yoyo2210
Y
G
leggere file txt e stampare con php il contenuto a video
  • giacomo9783
  • 28 Ago 2021
  • PHP
Risposte
7
Visite
3K
PHP 31 Ago 2021
MarcoGrazia
P
[PHP] Aggiungere giorni e stampare risultato da data inserita in input
  • pizzettino
  • 2 Apr 2019
  • PHP
Risposte
3
Visite
4K
PHP 3 Apr 2019
macus_adi
P
[PHP] Stampare record di diverse tabelle ma con nomi uguali
  • prate007
  • 6 Feb 2019
  • PHP
Risposte
6
Visite
2K
PHP 7 Feb 2019
prate007
P
K
[PHP] Stampare tabella da database differenti.
  • kogaijy
  • 22 Nov 2018
  • PHP
Risposte
4
Visite
2K
PHP 23 Nov 2018
Max 1
M
Stampare con php e mysql
  • Marco Candian
  • 6 Mar 2018
  • PHP
Risposte
8
Visite
4K
PHP 6 Mar 2018
macus_adi
L
[PHP] stampare un'array di un database
  • luigi777
  • 17 Feb 2018
  • PHP
Risposte
0
Visite
1K
PHP 17 Feb 2018
luigi777
L
T
PHP+MYSQL: stampare record con numero progressivo
  • theseo
  • 3 Gen 2018
  • PHP
Risposte
3
Visite
3K
PHP 4 Gen 2018
borgo italia
Stampare dei valori XML in PHP
  • cristoforo58
  • 5 Lug 2017
  • PHP
Risposte
0
Visite
2K
PHP 5 Lug 2017
cristoforo58
[PHP] Stampare i valori di una variabile scritta su più righe
  • elpirata
  • 28 Giu 2017
  • PHP
Risposte
1
Visite
3K
PHP 28 Giu 2017
otto9due
K
[PHP] Cancellare e Stampare tabella
  • kogaijy
  • 8 Giu 2017
  • PHP
Risposte
3
Visite
2K
PHP 13 Giu 2017
bubino8
M
[PHP] come stampare un Qr-code in FPDF
  • maxbar
  • 5 Giu 2017
  • PHP
Risposte
8
Visite
6K
PHP 7 Giu 2017
maxbar
M
N
[PHP] stampare pagina html
  • nebbia
  • 28 Dic 2016
  • PHP
Risposte
0
Visite
3K
PHP 28 Dic 2016
nebbia
N
[RISOLTO]Stampare giorno della settimana in tabella php
  • elpirata
  • 9 Ago 2016
  • PHP
Risposte
6
Visite
4K
PHP 9 Ago 2016
elpirata
[PHP] [RISOLTO] Stampare classe css in base al risultato della query
  • elpirata
  • 8 Ago 2016
  • PHP
Risposte
6
Visite
3K
PHP 9 Ago 2016
elpirata
[PHP] Problema: Stampare tutte le occorrenza di una SELECT
  • webmachine
  • 30 Giu 2016
  • PHP
Risposte
2
Visite
2K
PHP 1 Lug 2016
marino51
L
Stampare immagine php
  • Lorenzo Pezzi
  • 7 Ott 2015
  • PHP
Risposte
2
Visite
6K
PHP 7 Ott 2015
Lorenzo Pezzi
L
F
stampare array php
  • Fabio90
  • 8 Gen 2015
  • PHP
Risposte
2
Visite
2K
PHP 8 Gen 2015
Fabio90
F
P
Stampare '<?' in php
  • PHP
  • 18 Giu 2014
  • PHP
Risposte
7
Visite
2K
PHP 22 Giu 2014
PHP
P
Condividi:
Facebook X (Twitter) LinkedIn WhatsApp e-mail Condividi Link
  • Home
  • Forum
  • Fare Web
  • PHP
  • Italiano
  • Termini e condizioni d'uso del sito
  • Policy Privacy
  • Aiuto
  • Home
Community platform by XenForo® © 2010-2024 XenForo Ltd. | Traduzione a cura di XenForo Italia
Menu
Accedi

Registrati

  • Home
  • Forum
    • Nuovi Messaggi
    • Cerca...
  • Novità
    • Featured content
    • Nuovi Messaggi
    • Ultime Attività
X

Privacy & Transparency

We use cookies and similar technologies for the following purposes:

  • Personalized ads and content
  • Content measurement and audience insights

Do you accept cookies and these technologies?

X

Privacy & Transparency

We use cookies and similar technologies for the following purposes:

  • Personalized ads and content
  • Content measurement and audience insights

Do you accept cookies and these technologies?