Pdf | |
The element starts rendering at once - an element that renders a web page or html in the Chromium engine begins that render in the background - and it is placed on the canvas after every element added to the same document before it, in the order the calls were made. So a document built from several html elements renders them at the same time and still lays them out one after the other. The task completes when the element has been placed.
Until then the element's rendering result, and the pages it may have added, are not known. An element positioned from the result of another one (for example below its PdfPageLastRectangle) must await that element first, or be placed on a page of its own. Do not change an element after passing it here until its task has completed.
Save(String), Close, Append(PdfDocument), Add(PdfPageElement) and the members of Pages wait for the pending additions of their document before they run.
PdfDocument doc = new PdfDocument(); PdfPage page1 = doc.AddPage(); PdfPage page2 = doc.AddPage(); // both pages render in parallel and are placed in order Task<PdfRenderingResult> first = page1.AddAsync(new PdfHtmlElement("https://selectpdf.com")); Task<PdfRenderingResult> second = page2.AddAsync(new PdfHtmlElement("https://selectpdf.com/pricing/")); await Task.WhenAll(first, second); doc.Save("document.pdf"); doc.Close();