-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEATURE]: Auto Doc | Generate PDF from Template #254
Conversation
+ add open scd event
…ge inside plugins
…dependent-plugin-packages
}); | ||
function getValueFromNestedProperty(publisher: MessagePublisher, key: keyof MessagePublisherFilter): string { | ||
const keyMap: Partial<Record<keyof MessagePublisherFilter, string>> = { | ||
LogicalNodeIEDName: "logicalNodeInofrmation.IEDName", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed a typo here Information
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uh nice spotting. Will rectify it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oups, your linter has gone wild !
This file is out of scope ;P
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mhm maybe because in the beginning I check to see how documentation plugin was handling the pdf generation, I don't recall changing anything in the file though
let y = 10; | ||
const pageHeight = doc.internal.pageSize.height; | ||
const pageSize = doc.internal.pageSize; | ||
const pageWidth = pageSize.width ? pageSize.width : pageSize.getWidth() | ||
const marginBottom = 10; | ||
|
||
const blockHandler: Record<ElementType, (block: Element) => void> = { | ||
text: handleTextBlock, | ||
image: () => {}, | ||
signalList: processSignalListForPdfGeneration | ||
} | ||
|
||
function incrementYPositionForNextLine() { | ||
y+=7; | ||
} | ||
|
||
function contentExceedsCurrentPage(y: number,pageHeight: number,marginBottom: number) { | ||
return (y+10) > (pageHeight-marginBottom); | ||
} | ||
|
||
function handleTextBlock(block: Element){ | ||
const wrappedText : string [] = doc.splitTextToSize(block.textContent ?? "", pageWidth-35); | ||
for(const line of wrappedText){ | ||
if (contentExceedsCurrentPage(y, pageHeight, marginBottom)) { | ||
doc.addPage(); | ||
y = 10; | ||
} | ||
doc.text(line, 10, y); | ||
incrementYPositionForNextLine(); | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a lot of magic number
here, will we be able to understand them in the future ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docs explain it, but I think I can improve on it by using explanatory variables
🗒 Description
When the signal list block element is selected, a pdf is generated based on the rows selected.
In the background signalLists are filtered and prepared for such pdf generation
📷 Demo screen recording or Screenshots
📋 Checklist
You may remove tasks that do not make sense in this PR.
🔦 Useful commits
You can add specific commits which are worth taking a look into