תיקון היפוך טקסט בעברית מהסוף להתחלה.
-
אני מתממשק עם ספריה pdfkit-table ליצירת PDF כשהמטרה בסוף לעשות דף סיכום הזמנה, הבעיה שהעברית שם יוצאת לי הפוך מתחיל במילה האחרונה ומסתיים בראשונה.
@yossiz המוכשר בעל החסדים.. בנה לי בעבר קוד שמתקן את זה אבל זה מצריך להריץ את זה על כל טקסט וטקסט, בפועל כעת יש לי בשביל טבלת הפריטים מערך שלם עם פרמטרים, לא יודע אם זה אפשרי, ואם זה הגיוני לעבוד כך. אשמח לעזרה איזה פתרון אחר.function reorder(text) { if (text?.match(/[א-ת]/)) { text = text.split(' ').reverse().join(' ') + ' '; } return text; }זה הקוד של יצירת הדף
export async function createTicket(cardItems) { const rubik = await fetch('https://fonts.gstatic.com/s/rubik/v14/iJWZBXyIfDnIV5PNhY1KTN7Z-Yh-B4i1Uw.woff').then(res => res.buffer()); const bgImageBuffer = await fetch("https://tchumim.com/assets/uploads/system/site-logo.png?v=7nijc2ofpcs").then(res => res.buffer()); let doc = new PDFDocument1({ margin: 30, size: 'A4' }); doc.image(bgImageBuffer, 0, 0, { width: 600 }) .font(rubik) .fontSize(9) .text(reorder(" בדיקה בהצלחה"), 10, 77, { width: 95, align: 'right' }) const table = { title: "רשימת מוצרים", subtitle: "חבילת מוצרים ", headers: [ { label:"Name", property: 'name', width: 60, renderer: null }, { label:"Description", property: 'description', width: 150, renderer: null ,headerAlign:"right"}, { label:"Price 1", property: 'price1', width: 100, renderer: null }, { label:"Price 2", property: 'price2', width: 100, renderer: null }, { label:"Price 3", property: 'price3', width: 80, renderer: null }, { label:"Price 4", property: 'price4', width: 43, renderer: (value, indexColumn, indexRow, row) => { return `U$ ${Number(value).toFixed(2)}` } }, ], // complex data datas: [ { name: 'Name 1', description: 'בדיקה חדשה', price1: '$1', price3: '$ 3', price2: '$2', price4: '4', }, { options: { fontSize: 10, separation: true}, name: 'bold:Name 2', description: reorder(' חייב להיות בצורה הזו' ), price1: 'bold:$1', price3: { label: 'PRICE $3', options: { fontSize: 12 } }, price2: '$2', price4: '4', }, // {...}, ], // simeple data rows: [ [ "Apple", "Nullam ut facilisis mi. Nunc dignissim ex ac vulputate facilisis.", "$ 105,99", "$ 105,99", "$ 105,99", "105.99", ], // , ], }; doc.table(table, { prepareHeader: () => doc.font(rubik).fontSize(8), prepareRow: (row, indexColumn, indexRow, rectRow, rectCell) => { // מידות טקסט תוכן טבלה doc.font(rubik).fontSize(8); // הוספת צבע לטבלה // indexColumn === 0 && doc.addBackground(rectRow, 'blue', 0.15); }, }); doc.table( table, { // A4 595.28 x 841.89 (portrait) (about width sizes) width: 300, //columnsSize: [ 200, 100, 100 ], }); doc.end(); return doc }
שלום! נראה שהשיחה הזו מעניינת אותך, אבל עדיין אין לך חשבון.
נמאס לכם לגלול בין אותם הפוסטים בכל ביקור? כשנרשמים לחשבון, תמיד תחזרו בדיוק למקום שבו הייתם קודם, ותוכלו לבחור לקבל התראות על תגובות חדשות (בין אם במייל, ובין אם בהתראת פוש). תוכלו גם לשמור סימניות ולפרגן ב-upvote לפוסטים כדי להביע הערכה לחברי קהילה אחרים.
בעזרת התרומה שלך, הפוסט הזה יכול להיות אפילו טוב יותר 💗
הרשמה התחברות