Write several texts on the same page with defined Y position
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 42/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- javascript
- Área
- tooling
Línea de trabajo
Reproduce el problema con PDFKit 0.15.0 utilizando el ejemplo writeLine proporcionado, centrándose en doc.text, heightOfString y el salto de página causado por una primera columna larga. Rastree cómo cambia el posicionamiento del texto cuando una columna abarca varias páginas. Se considera completado cuando todas las columnas de una fila permanecen alineadas desde la misma página inicial sin superponerse.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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
- Lenguaje dominante
- JavaScript
- Estrellas
- 10.7k
- Forks
- 1.2k
- Merge medio
- 22 h 55 min
- PR fusionados (30 d)
- 25
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de foliojs/pdfkit
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 65/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
foliojs/pdfkit#1804 · 5 comentarios ·
Los mantenedores suelen responder en 1 día
-
PDFKit crashes when providing fonts as Buffer in tablePosiblemente ocupada @ykw9263 la tomó hace 130 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
foliojs/pdfkit#1743 · 13 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
foliojs/pdfkit#1635 · 4 comentarios ·
Los mantenedores suelen responder en 1 día
-
Get detailed font metricsAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
foliojs/pdfkit#1512 · 1 comentario · 2 reacciones ·
Los mantenedores suelen responder en 1 día
Todos los issues de foliojs/pdfkit
Issues similares
-
ready-for-agent
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
LucasSantana-Dev/Lucky#2945 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
brijeshb42/monaco-vim#175 ·
-
good first issue
Dificultad 2/5 3-5 días Aptitud para principiantes 62/100
paipai1999/POS-system#3 ·
-
good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
r-afael/better-yt-recommendations#36 ·
Los mantenedores suelen responder en 1 día
-
needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
microsoft/playwright#43875 · 1 comentario ·
Los mantenedores suelen responder en 1 día