pdf2json
pdf2json copied to clipboard
what's meaning about 'w' and 'sw'
what's meaning about 'w' and 'sw' field in 'Texts' in JSONData
I have the same question, and what units are they in?
Looking at pdffont.js in the /lib folder, on like 337 the comment describes sw as the font space width. w is the width is also defined on line 336, not sure why it isn't the width of the text to be rendered?
I've inserted another member called aw (actual width) to see how the text width compares using:
aw: PDFUnit.toFixedFloat(text.length)
Results, on a typical where the contains the text "394.42", the 'w' is 30.768 and 'aw' is 6.
x/px = PDFUnit.toPixelX( x+0.25)
y/px = PDFUnit.toPixelY( x+0.75)
w/px= PDFUnit.toFixedFloat(maxWidth),
let dpi = 96.0;
let gridXPerInch = 4.0;
let gridYPerInch = 4.0;
let _pixelXPerGrid = dpi/gridXPerInch;
let _pixelYPerGrid = dpi/gridYPerInch;
let _pixelPerPoint = dpi/72;
let TS = [this.faceIdx, this.fontSize, this.bold?1:0, this.italic?1:0];
let clrId = PDFUnit.findColorIndex(color);
let oneText = {x: PDFUnit.toFormX(p.x) - 0.25,
y: PDFUnit.toFormY(p.y) - 0.75,
w: PDFUnit.toFixedFloat(maxWidth),
sw: this.spaceWidth, //font space width, use to merge adjacent text blocks
clr: clrId,
A: "left",
R: [{
T: this.flash_encode(text),
S: this.fontStyleId,
TS: TS
}]
This raises more questions than i think it answers. What is the 'maxWidth'? Is that the width of the text? How do I convert the w property to the same coordinate system as the x/y values? What is the difference between toPixelX/toPixelY/toFixedFloat?
What would be really useful is to know how to convert the w to the equivlient number of pixels in the x direction.. At the moment I have not been able to find a reliable way to do it.
Guys, pardon for impolicy, but are you even still maintaining the project?
I can't see type definitions for the library; people report memory leaks; the documentation lacks such important details like this one.
Are you going to do something with it? I personally find this library super useful, but some issues like this one are frustrating.