Skip to content

Commit d18c3d1

Browse files
author
Olivier Bonnaure
committed
fix: remove unused code
1 parent b17b2f5 commit d18c3d1

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

.lua/pdfgenerator.lua

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ function PDFGenerator:splitTextToLines(text, fontSize, maxWidth)
407407
local currentWidth = 0
408408

409409
for i, word in ipairs(words) do
410-
local wordWidth = self:getTextWidth(word, fontSize, self.last_font.fontWeight)
410+
local wordWidth = self:getTextWidth(word, fontSize, self.last_font.fontWeight) or 0
411411
local spaceWidth = self:getTextWidth(" ", fontSize, self.last_font.fontWeight)
412412

413413
-- Check if adding this word would exceed maxWidth
@@ -466,7 +466,6 @@ function PDFGenerator:addText(text, fontSize, color, alignment, width)
466466
-- For justified text, we need to calculate word spacing
467467
if alignment == "justify" then
468468
local spaces = text:gsub("[^ ]", ""):len() -- Count spaces
469-
local words = select(2, text:gsub("%S+", "")) + 1 -- Count words
470469
local available_width = self.page_width - self.margin_x[1] - self.margin_x[2]
471470
local extra_space = available_width - text_width
472471
local word_spacing = extra_space / spaces
@@ -530,7 +529,7 @@ function PDFGenerator:addParagraph(text, options)
530529

531530
for _, text in ipairs(splittedText) do
532531
local lines = self:splitTextToLines(text, options.fontSize, options.width - options.paddingX)
533-
for i, line in ipairs(lines) do
532+
for _, line in ipairs(lines) do
534533
if options.newLine == true then
535534
self.current_y = self.current_y + options.fontSize * 1.2
536535
end
@@ -2073,7 +2072,7 @@ function PDFGenerator:generate()
20732072
string.format("%d 0 obj\n<< /Type /Catalog /Pages %d 0 R >>\nendobj\n", self.root, self.pages_obj)
20742073

20752074
-- Write content streams
2076-
for pageId, content in pairs(self.contents) do
2075+
for _, content in pairs(self.contents) do
20772076
local stream = table.concat(content.streams)
20782077

20792078
self.objects[content.id] =

0 commit comments

Comments
 (0)