f
This commit is contained in:
@@ -46,10 +46,8 @@ func (s *ReportPDFService) GenerateReportPDF(ctx context.Context, orderId, order
|
|||||||
var pdfBuf []byte
|
var pdfBuf []byte
|
||||||
err := chromedp.Run(ctxt,
|
err := chromedp.Run(ctxt,
|
||||||
chromedp.Navigate(reportURL),
|
chromedp.Navigate(reportURL),
|
||||||
// 等待报告根节点渲染完成
|
// 等待报告主体区域渲染完成(数据加载并成功渲染后才会出现)
|
||||||
chromedp.WaitVisible(`.pc-report-page`, chromedp.ByQuery),
|
chromedp.WaitVisible(`.pc-report-body`, chromedp.ByQuery),
|
||||||
// 再等待一小段时间以便异步数据加载
|
|
||||||
chromedp.Sleep(500*time.Millisecond),
|
|
||||||
chromedp.ActionFunc(func(ctx context.Context) error {
|
chromedp.ActionFunc(func(ctx context.Context) error {
|
||||||
buf, _, pdfErr := page.PrintToPDF().
|
buf, _, pdfErr := page.PrintToPDF().
|
||||||
WithPrintBackground(true).
|
WithPrintBackground(true).
|
||||||
|
|||||||
Reference in New Issue
Block a user