Adds extra cases for PDF CR lists

Adds a new function to detect "Fake lists", in PDF documents
and treats them accordingly.
Enhances the Layout of PDFs with CR-Mode UL/OL lists.
This commit is contained in:
Sean Engelhardt 2019-02-20 11:43:22 +01:00
parent 6eea064862
commit 7f86f3af64
2 changed files with 25 additions and 5 deletions

View File

@ -350,10 +350,8 @@ export class HtmlToPdfService {
margin: [0, 0, 0, 0]
};
// This has the effect that changed complex lists will look good with line numbers,
// but simple lists will be too close. The information in the HTML is highly redundant and
// there is currently no clear way to determine what to do with the lists.
if (classes.includes('os-split-after')) {
// if this is a "fake list" lower put it close to the element above
if (this.isFakeList(element)) {
listCol.margin[3] = -this.LI_MARGIN_BOTTOM;
}
@ -546,6 +544,28 @@ export class HtmlToPdfService {
return false;
}
/**
* Checks if a given UL or LI list (as element) is a "fake list"
* Fake lists in fact lists by should appear like the parent list
* would seamlessly continue.
* This usually happens when a user makes change recommendations in
* lists
*
* @param element the list to check, can be UL or LI
* returns wether the list is fake or not
*/
private isFakeList(element: Element): boolean {
if (element.firstElementChild && element.classList.contains('os-split-after')) {
// either first child has split-before or last child has split-after
const firstChild = element.firstElementChild;
const lastChild = element.childNodes[element.childNodes.length - 1] as Element;
const splitBefore = firstChild.nodeName === 'LI' && firstChild.classList.contains('os-split-before');
const splitAfter = lastChild.nodeName === 'LI' && lastChild.classList.contains('os-split-after');
return splitBefore || splitAfter;
}
return false;
}
/**
* Helper function to safer extract a line number from an element
*

View File

@ -99,7 +99,7 @@ export class MotionPdfCatalogService {
* @returns The motion list title for the PDF document
*/
private createTitle(): object {
const titleText = this.configService.instant<string>('motions_export_title');
const titleText = this.translate.instant(this.configService.instant<string>('motions_export_title'));
return {
text: titleText,
style: 'title'