Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RTL Direction and justify aligment #1447

Open
baravak opened this issue May 16, 2023 · 0 comments
Open

RTL Direction and justify aligment #1447

baravak opened this issue May 16, 2023 · 0 comments

Comments

@baravak
Copy link

baravak commented May 16, 2023

Bug Report

When we want to have right-to-left text, such as Persian or Arabic, and the features are set to rtla or rtlm, and we want to set the align to justify, the alignment is applied from the left side. It seems that there is a need for an additional setting to adjust the text direction as well.

Code sample

import { createWriteStream } from "fs";
import PDFDocument from "pdfkit";

// Create a document
const doc = new PDFDocument({ size: "A4" });
doc.page.margins = { top: 100, bottom: 100, left: 100, right: 100 };
const fonts = {
    regular: "./fonts/DanaFaNum-Regular.ttf",
};

const styles = {
    normal: doc.font(fonts.regular).fontSize(15),
};

doc.pipe(createWriteStream("output.pdf"));

const text =
    "این یک متن فارسی است که ما می‌خواهیم بدانیم آیا این کتابخانه می‌تواند این متن را ساپورت کند یا خیر؟ به عبارت دیگر هیچ زبان برنامه‌نویسی و کتاب‌خانه درستی در دنیا وجود ندارد که از یک متن فارسی یا راست به چپ پشتیبانی کند!";

styles.normal.text(text, {
    features: ["rtla"],
    align: "justify",
});

styles.normal.text(text, {
    features: ["rtla"],
    align: "right",
});

doc.end();

Your environment

  • pdfkit version:0.13.0
  • Node version:v18.16.0
  • Browser version (if applicable):
  • Operating System:ubuntu 22
    image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant