Я хочу напечатать свой HTML в PDF.Все почти нормально, но штрих-код отображается правильно только на странице моего веб-приложения, но в PDF-файле, показанном частично, я не знаю, почему.
мой HTML-код
<div *ngIf="flight" #content>
<div>
<label>departureCity: </label> {{flight.departureCity}}
</div>
<div>
<label>destinationCity: </label> {{flight.destinationCity}}
</div>
<label>List of tickets: </label>
<div *ngFor="let ticket of flight.tickets">
<label>Name: </label> {{ ticket.name }}<br/>
<label>Surname: </label> {{ ticket.surname }}<br/>
</div>
<svg id="barcode1"></svg>
<hr/>
</div>
<button (click)="downloadPDF()"> Download </button>
моя машинописькод
@ViewChild('content') content: ElementRef;
public downloadPDF() {
const doc = new jsPDF(this.getBarcode());
const specialElementHandlers = {
'#editor': function(element, renderer) {
return true;
}
};
const content = this.content.nativeElement;
doc.fromHTML(content.innerHTML, 15, 15, {
'width': 190,
'elementHandlers': specialElementHandlers
});
doc.save('Test.pdf');
}
getBarcode() {
JsBarcode('#barcode1', this.getOrderNumber(), {
format: 'CODE128',
displayValue: true,
<!---->
});
}
getOrderNumber() {
const number = 'R' + Math.floor(Math.random() * 100000000000);
return number;
}
На моей странице веб-приложения все в порядке:
![enter image description here](https://i.stack.imgur.com/RSYSv.png)
Но на штрих-коде PDF, показанном только частично
![enter image description here](https://i.stack.imgur.com/q6c9h.png)