Skip to content

Commit 59a38cd

Browse files
Merge pull request #70 from biswalom22/fix/pdf-ui-fix
Fixed issues in pdf report
2 parents 0f80f79 + 3818723 commit 59a38cd

File tree

1 file changed

+18
-23
lines changed

1 file changed

+18
-23
lines changed

bin/report-generation-cli.js

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -143,45 +143,40 @@ async function createPdfReport(issues, reportDir) {
143143

144144
try {
145145
const logoPath = path.join(__dirname, '..', 'static', 'img', 'logo.png');
146-
const titleText = 'ESLint Issues Report';
147-
const logoHeight = 40;
148146
const logoWidth = 40;
149-
const spacing = 10;
150-
151-
doc.fontSize(20).font('Helvetica-Bold');
152-
const titleWidth = doc.widthOfString(titleText);
153-
const headerBlockWidth = logoWidth + spacing + titleWidth;
147+
const logoHeight = 40;
154148
const pageWidth =
155149
doc.page.width - doc.page.margins.left - doc.page.margins.right;
156-
const startX = doc.page.margins.left + (pageWidth - headerBlockWidth) / 2;
157-
const startY = doc.y;
150+
const logoX = doc.page.margins.left + pageWidth - logoWidth;
151+
const logoY = doc.page.margins.top;
158152

159153
if (fs.existsSync(logoPath)) {
160-
doc.image(logoPath, startX, startY, {
154+
doc.image(logoPath, logoX, logoY, {
161155
width: logoWidth,
162156
height: logoHeight,
163157
});
164158
}
165159

166-
const textHeight = doc.heightOfString(titleText);
167-
const textY = startY + (logoHeight - textHeight) / 2;
168-
169-
doc
170-
.fillColor('red')
171-
.font('Helvetica-Bold')
172-
.fontSize(20)
173-
.text(titleText, startX + logoWidth + spacing, textY);
160+
const titleText = 'ESLint Plugin Hub Issues Report';
161+
doc.fontSize(20).font('Helvetica-Bold');
162+
const titleWidth = doc.widthOfString(titleText);
163+
const titleX = doc.page.margins.left + (pageWidth - titleWidth) / 2;
164+
const titleY =
165+
doc.page.margins.top + (logoHeight - doc.heightOfString(titleText)) / 2;
174166

175-
doc.y = startY + logoHeight;
176-
doc.moveDown(0.5);
167+
doc.fillColor('red').text(titleText, titleX, titleY);
177168

169+
const belowHeaderY = doc.page.margins.top + logoHeight + 5;
178170
const dateText = `Generated on: ${new Date().toLocaleString()}`;
179171
doc
180172
.fontSize(10)
181173
.font('Helvetica')
182174
.fillColor('black')
183-
.text(dateText, { align: 'center' });
184-
doc.moveDown(2);
175+
.text(dateText, doc.page.margins.left, belowHeaderY, {
176+
align: 'center',
177+
width: pageWidth,
178+
});
179+
doc.y = belowHeaderY + doc.heightOfString(dateText) + 10;
185180

186181
if (issues.length === 0) {
187182
doc
@@ -198,7 +193,7 @@ async function createPdfReport(issues, reportDir) {
198193
'Severity',
199194
'File Path',
200195
'Location',
201-
'Rule ID',
196+
'Rule Name',
202197
'Message',
203198
],
204199
columns: [

0 commit comments

Comments
 (0)