Jump to content

saving pdf files to the server


lional

Recommended Posts

Hi All

Anyone please help

I am trying to save pdf documents to the server. I would prefer that it is not shown to the user.

What I am trying to achieve is to create a pdf, save it to the server, and then email it as an attachment

 

Is this possible, and if so How is it done?

 

Any help will be appreciated

 

 

Thanks

 

Lional

 

Link to comment
https://forums.phpfreaks.com/topic/44089-saving-pdf-files-to-the-server/
Share on other sites

This is my demo code

require 'PDF.php';                    // Require the class.

$pdf = &PDF::factory('l', 'a4');      // Set up the pdf object.

$pdf->open();                        // Start the document.

$pdf->setCompression(true);          // Activate compression.

$pdf->addPage();                      // Start a page.

$pdf->setFont('Arial', '', 36);      // Set font to courier 8 pt.

$pdf->text(25, 50, 'Supreme Grand Royal Arch Chapter of Scotland');  // Text at x=100 and y=100.

//$pdf->setFontSize(20);                // Set font size to 20 pt.

//$pdf->setFillColor('rgb', 1, 0, 0);  // Set text color to red.

//$pdf->line(200, 100, 200, 100);      // Draw a line.

$pdf->setFont('Arial', '', 12); // Set font to courier 8 pt.

$pdf->text(250, 100, 'DEGREE OF INSTALLED MASTER IN THE MARK DEGREE');  // Text at x=100 and y=100.

$pdf->setFont('Arial', '', 24); // Set font to courier 8 pt.

$pdf->text(275, 130, 'Certificate of Innstallation');  // Text at x=100 and y=100.

//$pdf->setDrawColor('rgb', 0, 0, 1);  // Set draw color to blue.

//$pdf->setFillColor('rgb', 1, 1, 0);  // Set fill/text to yellow.

//$pdf->rect(200, 300, 100, 100, 'fd'); // Draw a filled rectangle.

//$pdf->addPage();                      // Add a new page.

$pdf->setFont('Arial', 'BI', 12);    // Set font to arial bold

//$pdf->text(100, 100, 'Second page');  // Text at x=100 and y=100.

//$pdf->image('sample.jpg', 400, 100);  // Image at x=50 and y=200.

//$pdf->setLineWidth(4);                // Set line width to 4 pt.

//$pdf->circle(200, 300, 150, 'd');    // Draw a non-filled

$pdf->output('foo.pdf');              // Output the file named foo.pdf

 

// Upload file to server

$filename = 'foo.pdf';

 

// Move the file over.

if (move_uploaded_file($_FILES['foo.pdf'], "uploads/$filename")) {

echo '<p>The file has been uploaded!</p>';

} else {

echo '<p><font color="red">The file could not be moved.</font></p>';

}

 

?>

 

What about doing this instead, creatre in the location instead of moving it..

 

require 'PDF.php';                    // Require the class.

$filename = 'foo.pdf';
$fullpath = "uploads/".$filename;

$pdf = &PDF::factory('l', 'a4');      // Set up the pdf object.
$pdf->open();                         // Start the document.
$pdf->setCompression(true);           // Activate compression.
$pdf->addPage();                      // Start a page.
$pdf->setFont('Arial', '', 36);      // Set font to courier 8 pt.
$pdf->text(25, 50, 'Supreme Grand Royal Arch Chapter of Scotland');   // Text at x=100 and y=100.
//$pdf->setFontSize(20);                // Set font size to 20 pt.
//$pdf->setFillColor('rgb', 1, 0, 0);   // Set text color to red.
//$pdf->line(200, 100, 200, 100);       // Draw a line.
$pdf->setFont('Arial', '', 12);               // Set font to courier 8 pt.
$pdf->text(250, 100, 'DEGREE OF INSTALLED MASTER IN THE MARK DEGREE');   // Text at x=100 and y=100.
$pdf->setFont('Arial', '', 24);               // Set font to courier 8 pt.
$pdf->text(275, 130, 'Certificate of Innstallation');   // Text at x=100 and y=100.
//$pdf->setDrawColor('rgb', 0, 0, 1);   // Set draw color to blue.
//$pdf->setFillColor('rgb', 1, 1, 0);   // Set fill/text to yellow.
//$pdf->rect(200, 300, 100, 100, 'fd'); // Draw a filled rectangle.
//$pdf->addPage();                      // Add a new page.
$pdf->setFont('Arial', 'BI', 12);     // Set font to arial bold
//$pdf->text(100, 100, 'Second page');  // Text at x=100 and y=100.
//$pdf->image('sample.jpg', 400, 100);   // Image at x=50 and y=200.
//$pdf->setLineWidth(4);                // Set line width to 4 pt.
//$pdf->circle(200, 300, 150, 'd');     // Draw a non-filled
$pdf->output($fullpath);              // Output the file named foo.pdf

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.