SQL Server - Crear PDF a partir de una consulta y enviarlo por SQL Email

 
Vista:

Crear PDF a partir de una consulta y enviarlo por SQL Email

Publicado por Victor (1 intervención) el 08/12/2016 17:20:02
Buenos dias:

Mi duda es la siguiente espero me puedan ayudar.

Se puede generar un archivo PDF a partir de una consulta de Sql Server y mandarlo por Sql Email.

Lo que pretendo hacer es crear un estado de cuenta por cliente y que cada mes le llegue en automatico, estoy manejando 500 clientes mensuales.

Como le puedo hacer para resolver este requerimiento.


Saludos cordiales!!
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
sin imagen de perfil
Val: 2
Ha aumentado su posición en 11 puestos en SQL Server (en relación al último mes)
Gráfica de SQL Server

Crear PDF a partir de una consulta y enviarlo por SQL Email

Publicado por pedro marciales (1 intervención) el 06/08/2018 02:36:12
disculpa peero no puedo mostrar los resultados de una consulta en php con sql server 2012
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de Isaias
Val: 3.250
Oro
Ha mantenido su posición en SQL Server (en relación al último mes)
Gráfica de SQL Server

Crear PDF a partir de una consulta y enviarlo por SQL Email

Publicado por Isaias (4558 intervenciones) el 08/12/2016 18:14:17
Otra solucion con PHP

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
  $mysqli = new mysqli("localhost", "root", "", "");
   if ($mysqli->connect_errno) {
      echo "Failed to Connect MySQL: (" . $mysqli-     >connect_errno . ") " . $mysqli->connect_error;
     }
 
    require_once 'dompdf-master/dompdf_config.inc.php';
 
  $result=$mysqli->query("SELECT * FROM tbl_name");
 
 
   while ($arr_result = $result->fetch_array())
     {
      $nombre=$arr_result["nombre"];
 
 
 
     $html.= "
        <table>
           <tr>
             <td> $nombre </td>
           </tr></table>
     ";
    $mipdf = new DOMPDF();
 
    $mipdf ->set_paper("A4", "portrait");
    $mipdf ->load_html(utf8_decode($html));
    $mipdf ->render();
    $mipdf ->stream('mipdf.pdf');
       }
    ?>
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de Isaias
Val: 3.250
Oro
Ha mantenido su posición en SQL Server (en relación al último mes)
Gráfica de SQL Server

Crear PDF a partir de una consulta y enviarlo por SQL Email

Publicado por Isaias (4558 intervenciones) el 08/12/2016 18:19:50
Con FPDF, que es una clase de PHP para generar archivos PDF a partir de una consulta hacia SQL


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
define('FPDF_FONTPATH', 'font/');
require('fpdf.php');
 
//Connect to your database
include("conectmysql.php");
 
//Create new pdf file
$pdf=new FPDF();
 
//Open file
$pdf->Open();
 
//Disable automatic page break
$pdf->SetAutoPageBreak(false);
 
//Add first page
$pdf->AddPage();
 
//set initial y axis position per page
$y_axis_initial = 25;
 
//print column titles for the actual page
$pdf->SetFillColor(232, 232, 232);
$pdf->SetFont('Arial', 'B', 12);
$pdf->SetY($y_axis_initial);
$pdf->SetX(25);
$pdf->Cell(30, 6, 'CODE', 1, 0, 'L', 1);
$pdf->Cell(100, 6, 'NAME', 1, 0, 'L', 1);
$pdf->Cell(30, 6, 'PRICE', 1, 0, 'R', 1);
 
$y_axis = $y_axis + $row_height;
 
//Select the Products you want to show in your PDF file
$result=mysql_query('select Code, Name, Price from Products ORDER BY Code', $link);
 
//initialize counter
$i = 0;
 
//Set maximum rows per page
$max = 25;
 
//Set Row Height
$row_height = 6;
 
while($row = mysql_fetch_array($result))
{
    //If the current row is the last one, create new page and print column title
    if ($i == $max)
    {
        $pdf->AddPage();
 
        //print column titles for the current page
        $pdf->SetY($y_axis_initial);
        $pdf->SetX(25);
        $pdf->Cell(30, 6, 'CODE', 1, 0, 'L', 1);
        $pdf->Cell(100, 6, 'NAME', 1, 0, 'L', 1);
        $pdf->Cell(30, 6, 'PRICE', 1, 0, 'R', 1);
 
        //Go to next row
        $y_axis = $y_axis + $row_height;
 
        //Set $i variable to 0 (first row)
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar