specifying x-coord does not position in absolute space

Abierto
#1,641 3 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

  • #1748 de @JamBalaya56562 — cerrado sin fusionar

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
55/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Tranquilo
Stack tecnológico
javascript
Área
api

Línea de trabajo

Comienza en el punto de entrada PDFDocument.text y reproduce el ejemplo de navegador proporcionado, centrándote en las llamadas que usan continued: true con coordenadas x explícitas. Compara las posiciones resultantes con la alineación esperada cuando la segunda llamada de texto usa x=0; se considera terminado cuando las coordenadas x e y se comportan como está documentado en los flujos de texto continuados.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Bug Report

Description of the problem

What I noticed is that the x (and potentially the y coord) is not an absolute position in the text function when 'continued' is set to true
As far as I could read there is no mention of relativity of the coord-position in relation to the continuedflag, but maybe I misunderstood the API.

I know a workaround already, but I would love to know where this relativity is comming from (i.e. where does it anchor to?). As when I set x of the second text to 0 it does not line up with the first text on the same line

Code sample

// create a document and pipe to a blob
var doc = new PDFDocument();
var stream = doc.pipe(blobStream());

// this should line up both the first and second text on each line
doc.text('testing',
{
    continued: true
});
doc.text('test', 200, undefined);
doc.text('testing out',
{
    continued: true
});
doc.text('test', 200, undefined);

doc.moveDown().moveDown();

// this is a work around which I would expect with the above code
const x = doc.x
doc.text('testing', x, undefined);
doc.moveUp();
doc.text('test', 200, undefined);
doc.text('testing out', x, undefined);
doc.moveUp();
doc.text('lolz', 200, undefined);


// end and display the document in the iframe to the right
doc.end();
stream.on('finish', function() {
  iframe.src = stream.toBlobURL('application/pdf');
});

Your environment

Currently (18-08-2025) present on the online version of:
https://pdfkit.org/examples/browserify/browser.html
Not sure which version it is using.

Lenguaje dominante
JavaScript
Estrellas
10.7k
Forks
1.2k
Merge medio
21 h 41 min
PR fusionados (30 d)
27

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de foliojs/pdfkit

Todos los issues de foliojs/pdfkit

Issues similares

Más issues de JavaScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.