print.php

คุณสามารถส่งออกข้อมูลเป็น PDF ได้ง่ายๆ

ตัวอย่างไฟล์ print.php สำหรับ Backstage

ไฟล์ print.php:

HTML

<!DOCTYPE html>
<html lang="th">
<head>
  <meta charset="UTF-8">
  <title>ตัวอย่างการแปลง HTML เป็น PDF</title>
  <style>
    body {
      font-family: Tahoma, sans-serif;
      font-size: 16px;
    }

    h1 {
      font-size: 24px;
      font-weight: bold;
    }
  </style>
</head>
<body>
  <htmlpageheader name="header">
      <div>Header</div>
  </htmlpageheader>
  <sethtmlpageheader name="header" page="O" value="on" show-this-page="1" />
  <sethtmlpageheader name="header" page="E" value="on" />
  <h1>ตัวอย่างการแปลง HTML เป็น PDF</h1>
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
  <htmlpagefooter name="footer">
      <div>Footer</div>
  </htmlpagefooter>
  <sethtmlpagefooter name="footer" page="O" value="on" show-this-page="1" />
  <sethtmlpagefooter name="footer" page="E" value="on" />
</body>
</html>

คุณสามารถใช้ Tag Html เพื่อกำหนด ค่ากระดาษตามตัวอย่าง

ตัวอย่าง หัวกระดาษ:

<htmlpageheader name="header">
    <div>Header</div>
</htmlpageheader>

ตัวอย่าง ท้ายกระดาษ:

<htmlpagefooter name="footer">
    <div>Footer</div>
</htmlpagefooter>

คำอธิบาย:

  • ไฟล์ print.php:

    • โหลดไลบรารี mPDF (ปกติระบบจะโหลดไว้อยู่แล้ว)

    • แปลง HTML เป็น PDF และเอาต์พุตไปยังหน้าจอ

การเรียกใช้ไฟล์ print.php :

https://domain.com/backstage/pdf/[โมดูลที่อยู่ของ print]/?footer=true&peview=true

// คำอธิบาย
footer=true # ให้ใส่ footer ของระบบไปด้วย

peview=true # ให้แสดงตัวอย่างของพิมพ์

copy=1 # ทำสำเนา

หมายเหตุ:

  • ปรับแต่งตัวอย่างตามความต้องการของคุณ

  • ทดสอบการแปลงของคุณบนเบราว์เซอร์และอุปกรณ์ที่แตกต่างกัน

แหล่งข้อมูล:

Last updated