เรื่องมีอยู่ว่าต้องทำไฟล์เอกสารเป็น PDF ที่ฝังไฟล์รูปภาพเป็นโลโก้ขององค์กร การทำเอกสารส่วนใหญ่เราทำในโปรแกรมพวก Office อย่าง Word, Excel, PowerPoint ก่อนแล้วค่อย export มาเป็น PDF อีกทีหนึ่ง

ปัญหาคือภาพโลโก้ที่เป็น bitmap (ต่อให้เป็น .png ก็ตาม) เวลาไปอยู่ใน PDF แล้วซูมเข้า ไฟล์มันจะแตกและไม่คม ถ้าพยายามใช้ไฟล์ภาพให้ขนาดใหญ่ขึ้นแล้วย่อรูป ก็มีปัญหาเรื่องเอกสาร PDF ขนาดใหญ่ตามมา

ผมเลยเกิดคำถามว่าในเมื่อฟอร์แมตของ PDF รองรับการแสดงรูปภาพแบบ vector อยู่แล้ว และในเมื่อเรามีไฟล์โลโก้ที่เป็น vector อยู่แล้วเช่นกัน (ในกรณีนี้คือ SVG) ทำไมเราต้องแปลงโลโก้ให้เป็น bitmap ที่ทั้งมีขนาดใหญ่และไม่คมชัดด้วย ก็เลยลองหาคำตอบเรื่องนี้ดู

สิ่งที่พบคือ Microsoft Office ไม่รองรับไฟล์ภาพแบบ SVG โดยตรง แต่กลับรองรับไฟล์ vector แบบที่เรียกว่า .emf (enhanced metafile) ซึ่งมีลักษณะคล้ายกับไฟล์จำพวก postscript

หน้าที่ของเราคือแปลง SVG ให้เป็น EMF นั่นเอง ซึ่งก็สามารถทำได้ง่ายๆ ด้วยโปรแกรม Inkscape ที่เป็นโอเพนซอร์สอยู่แล้ว

วิธีการไม่มีอะไรยากคือเปิดไฟล์ SVG ขึ้นมาใน Inkscape แล้วสั่งเซฟใหม่ทันที เลือกประเภทของไฟล์เป็น EMF

อย่างไรก็ตาม Inkscape จะมีค่าดีฟอลต์ขนาดของ canvas เป็นเอกสารเปล่า ใหญ่กว่าตัวเส้นที่เราวาด ดังนั้นเราต้องปรับขนาดของ canvas ให้พอดี เวลานำไปใช้จะได้มีขนาดของ canvas เล็ก คล่องตัวกว่า

วิธีคือให้เปิดหน้า Document Properties > Page แล้วเลือก Custom Size กดปุ่ม Resize page to drawing or selection

ในกรณีที่มีเรามีข้อความ text ในภาพแบบ vector ด้วย ตอนสั่งเซฟเป็น EMF อาจเอาติ๊กตรงคำว่า convert texts to paths ออก เผื่อจะแก้ข้อความนั้นทีหลังจาก Word โดยตรง แต่ถ้าเป็นเส้น path ล้วนๆ ก็ไม่ต้องไปสนใจอะไรมันครับ

เมื่อเซฟเสร็จแล้ว ก็เปิด Office ขึ้นมา สั่งแทรกภาพตามปกติ เลือกไฟล์ EMF ที่เราแปลงไว้ (จากภาพจะเห็นว่า import ภาพเข้ามาแล้วภาพมันแตกๆ แต่ไม่เป็นไร มันเป็นกับใน Word เท่านั้น)

แก้เอกสารเสร็จก็แปลงเป็น PDF แล้วลองพรีวิวดูในพวก PDF Reader จะเห็นว่าไฟล์โลโก้คมกริบเสมอ ไม่ว่าจะซูมไปแค่ไหนก็ตาม

ไฟล์ต้นฉบับ SVG ของผมมีขนาด 4.1KB พอแปลงเป็น EMF ได้ 31.1KB และไฟล์สุดท้ายที่เป็นเอกสาร PDF (มีภาพ EMF พร้อมข้อความ Test test test แค่นั้น) ขนาด 100KB ก็ถือว่าได้ผลลัพธ์เป็นที่น่าพอใจ

อ้างอิง Inserting SVG files in a Microsoft Word document

Hiring! บริษัทที่น่าสนใจ

Carmen Software company cover
Carmen Software
Hotel Financial Solutions
Next Innovation (Thailand) Co., Ltd. company cover
Next Innovation (Thailand) Co., Ltd.
We are web design with consulting & engineering services driven the future stronger and flexibility.
KKP Dime company cover
KKP Dime
KKP Dime บริษัทในเครือเกียรตินาคินภัทร
Kiatnakin Phatra Financial Group company cover
Kiatnakin Phatra Financial Group
Financial Service
Fastwork Technologies company cover
Fastwork Technologies
Fastwork.co เว็บไซต์ที่รวบรวม ฟรีแลนซ์ มืออาชีพจากหลากหลายสายงานไว้ในที่เดียวกัน
Thoughtworks Thailand company cover
Thoughtworks Thailand
Thoughtworks เป็นบริษัทที่ปรึกษาด้านเทคโนโยลีระดับโลกที่คว้า Great Place to Work 3 ปีซ้อน
Iron Software company cover
Iron Software
Iron Software is an American company providing a suite of .NET libraries by engineer for engineers.
CLEVERSE company cover
CLEVERSE
Cleverse is a Venture Builder. Our team builds several tech companies.
Nipa Cloud company cover
Nipa Cloud
#1 OpenStack cloud provider in Thailand with our own data center and software platform.
Bangmod Enterprise company cover
Bangmod Enterprise
The leader in Cloud Server and Hosting in Thailand.
CIMB THAI Bank company cover
CIMB THAI Bank
MOVING FORWARD WITH YOU - CIMB is the leading ASEAN Bank
Bangkok Bank company cover
Bangkok Bank
Bangkok Bank is one of Southeast Asia's largest regional banks, a market leader in business banking
MuvMi (Urban Mobility Tech Co.,Ltd.) company cover
MuvMi (Urban Mobility Tech Co.,Ltd.)
Shape the future of urban mobility towards affordable, clean, and safe solutions
T.N. Digital Solution Co., Ltd. company cover
T.N. Digital Solution Co., Ltd.
TNDS has been involving in every first move of banking’s major digital transformation.
KBTG - KASIKORN Business-Technology Group company cover
KBTG - KASIKORN Business-Technology Group
KBTG - "The Technology Company for Digital Business Innovation"
Siam Commercial Bank Public Company Limited company cover
Siam Commercial Bank Public Company Limited
"Let's start a brighter career future together"
Icon Framework co.,Ltd. company cover
Icon Framework co.,Ltd.
Global Standard Platform for Real Estate แพลตฟอร์มสำหรับธุรกิจอสังหาริมทรัพย์ครบวงจร มาตรฐานระดับโลก
REFINITIV company cover
REFINITIV
The Financial and Risk business of Thomson Reuters is now Refinitiv
H LAB company cover
H LAB
Re-engineering healthcare systems through intelligent platforms and system design.
The Gang Technology Co., Ltd. company cover
The Gang Technology Co., Ltd.
We're a Digital Agency that helps our customers transform their business into digital with ease.
LTMH company cover
LTMH
LTMH มุ่งเน้นการพัฒนาผลิตภัณฑ์ที่สามารถช่วยพันธมิตรของเราให้บรรลุเป้าหมาย
Seven Peaks company cover
Seven Peaks
We Drive Digital Transformation
Wisesight (Thailand) Co., Ltd. company cover
Wisesight (Thailand) Co., Ltd.
The Best Choice For Handling Social Media · High Expertise in Social Data · Most Advanced and Secure
MOLOG Tech company cover
MOLOG Tech
We are Modern Logistic Platform, Specialize in WMS, OMS and TMS.
Data Wow Co.,Ltd company cover
Data Wow Co.,Ltd
We enable our clients to realize increased productivity by solving their most complex issues by Data
LINE Company Thailand company cover
LINE Company Thailand
LINE, the world's hottest mobile messaging platform, offers free text and voice messaging + Call
LINE MAN Wongnai company cover
LINE MAN Wongnai
Join our journey to becoming No.1 food platform in Thailand

ขออนุญาตเสริมนะครับ เป็นของที่ผมทำบ่อยๆ เหมือนกัน น่าจะใช้ได้เหมือนกัน

ถ้าใช้ inkscape อยู่แล้ว ใช้ select tool เลือกส่วนของภาพที่ต้องการ แล้วสั่ง copy ไป paste ลงใน MS Word ได้เลย ภาพจะถูก import เป็น vector ครับ แต่ถ้าอยากเลือก format ตอน paste ให้เลือก paste special จะมีให้เลือกระหว่าง emf / wmf ครับ

ผมทำบ่อยๆ ทั้งใน word / powerpoint แต่ใน excel ไม่ทราบครับ (ยังใช้ office 2007 อยู่เลย)

โพสต์ไปเสร็จ เจอโพสต์ของคุณ Nozomi ขึ้นมาก่อนล่ะ ฮา

เพิ่มเติมข้อมูลว่า ถ้าเป็น LibreOffice / OpenOffice นี่ใช้วิธี copy แปะแบบ MS Word ไม่ได้ (อันนี้ยอม ฮา)

เพราะแปะแล้วจะกลายเป็น bitmap แตกระแหง

เข้ามาเสริมข้อมูลว่า สำหรับคนที่ใช้ LibreOffice / OpenOffice จะสามารถแทรกไฟล์ svg เข้าไปในเอกสารได้เลย ไม่ต้องแปลงฟอร์แมตก่อน :)

.

.

อันนี้นอกเรื่องล่ะ

inkscape นี่ใช้งานสะดวกมาก ใช้มาหลายปีล่ะครับ เวลามีเหตุจำเป็นที่ต้องกลับไปใช้ Illustrator ของคอมฯ คนอื่นนี่ทำเอางง ทำอะไรไม่ค่อยจะถูกเลย ^^'a

แต่รุ่น 0.91 มีปัญหาใหญ่กับภาษาไทย เรื่องสระอำ ถ้ารุ่นเก่า 0.48.x นี่จะใช้งานได้ปกติ

เห็นว่าจะแก้ปัญหาเรื่องนี้ในรุ่น 0.92 แต่รอมาเป็นปี ก็ยังไม่มีวี่แววว่าจะเข็นออกมาซะที T-T (0.91 ออกมาตั้งแต่มกรา 2015)

ปัญหาเดียวกันเลย เพิ่งรู้ว่าเขาจะแก้ในเวอร์ชันถัดไปด้วย ผมใช้ Inkscape ทีไร เผลอมีปัญหากับสระอำทุกที ทางแก้เบื้องต้นคือใช้ shift+ไม้หันอากาศแทน (คีย์ตัว Y) แล้วเติมสระอาเองอีกทีนึง เล่นเอาปวดหัวไปตั้งนานกว่าจะหาวิธีแก้ได้ (ทั้ง ๆ ที่มันก็ง่าย ๆ แต่ดันนึกไม่ถึง)