Write several texts on the same page with defined Y position
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 42/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- javascript
- 領域
- tooling
調査の方向性
提供された writeLine の例を使用して PDFKit 0.15.0 で問題を再現し、doc.text、heightOfString、および長い最初の列によって発生する改ページに焦点を当てます。列が複数ページにまたがるときに、テキストの位置がどのように変化するかを追跡します。完了の条件は、行内のすべての列が同じ開始ページから整列したまま、重ならないことです。
索引モデルが issue の本文から書いたものです。
説明
Hello ! This question is quite important i'm stuck for a professionnal work.
How can I write several texts on the same page with a defined Y position ?
My goal is to create a table and then write the content of the columns on the same line.
Like this : column1 | column2 | column3
Easy you would say :
export type PDFTableLine = { text: string; width: number }
private writeLine = (content: PDFTableLine[]) =>
{
let offsetX = this.doc.page.margins.left;
const startY = this.doc.y;
let maxLineHeight = 0;
//checking what column will be the tallest
for (let i = 0; i < content.length; i++) {
const textHeight = this.doc.heightOfString(content[i].text, {
width: content[i].width,
});
maxLineHeight = Math.max(maxLineHeight, textHeight);
}
//write all the content of columns
for (let i = 0; i < content.length; i++)
{
this.doc.text(content[i].text, offsetX, startY, {
width: content[i].width,
})
offsetX += content[i].width;//set the offset so the next text will be displayed on the next column
}
//avoid overlap text with setting the next line below the tallest column
this.doc.y = startY + maxLineHeight;
this.writeLineSeparator(); //basically create a line with stroke()
}
It's working perfectly ! Unless... If the first text is quite long and pdfkit creates a page to write the rest of the text, then the others column will be displayed on the next page from the Y position from the top of the page. I want all my columns to starts on the same page even if the first text creates a new page. How can I achieve that ?
(Ps: the issue also exist in pdfkit-table package) that's why i'm creating my own class to build tables
- pdfkit version: 0.15.0
- Node version: v20.15.1
- Operating System: Ubuntu linux
- 主要言語
- JavaScript
- スター
- 10.7k
- フォーク
- 1.2k
- 平均マージ
- 21時間 41分
- マージ済み PR(30日)
- 27
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
foliojs/pdfkit のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
foliojs/pdfkit#1804 · コメント 5 件 ·
メンテナーはふだん 1 日以内に返信
-
PDFKit crashes when providing fonts as Buffer in table対応中かも @ykw9263 が 131 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
foliojs/pdfkit#1743 · コメント 13 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
foliojs/pdfkit#1635 · コメント 4 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
foliojs/pdfkit#1512 · コメント 1 件 · リアクション 2 件 ·
メンテナーはふだん 1 日以内に返信
-
Upgrade codemirrorオープン
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
Handle HTTP errors when downloading release binaries対応中かも @mugenkyou が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
neutralinojs/neutralinojs-cli#468 ·
メンテナーはふだん 1 日以内に返信
-
area:ci priority:p0 type:chore
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
lucacasanova/homedeck#2 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
terser/html-minifier-terser#242 ·
-
enhancement good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
MustacheCase/zanadir#516 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
stylelint-scss/stylelint-config-standard-scss#297 · コメント 1 件 ·