You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Message: startIndex ('-1') must be a non-negative value. (Parameter 'startIndex')
Actual value was -1., Extra: ConvertedException { Message = startIndex ('-1') must be a non-negative value. (Parameter 'startIndex')
Actual value was -1., Source = System.Private.CoreLib, StackTrace = at System.ArgumentOutOfRangeException.ThrowNegative[T](T value, String paramName)
at System.String.ThrowSubstringArgumentOutOfRange(Int32 startIndex, Int32 length)
at System.String.Substring(Int32 startIndex)
at PuppeteerSharp.Cdp.CdpPage.ConvertPrintParameterToInches(Object parameter) in /home/runner/work/puppeteer-sharp/puppeteer-sharp/lib/PuppeteerSharp/Cdp/CdpPage.cs:line 1231
at PuppeteerSharp.Cdp.CdpPage.PdfInternalAsync(String file, PdfOptions options) in /home/runner/work/puppeteer-sharp/puppeteer-sharp/lib/PuppeteerSharp/Cdp/CdpPage.cs:line 812
at PuppeteerSharp.Page.PdfStreamAsync(PdfOptions options) in /home/runner/work/puppeteer-sharp/puppeteer-sharp/lib/PuppeteerSharp/Page.cs:line 390
When you use 0 in the measures.
Complete minimal example reproducing the issue
usingPuppeteerSharp;usingPuppeteerSharp.Media;awaitnewBrowserFetcher(SupportedBrowser.Chrome).DownloadAsync();varbrowser=awaitPuppeteer.LaunchAsync(newLaunchOptions{Headless=false});varpage=awaitbrowser.NewPageAsync();awaitpage.SetContentAsync(""" <div>this is a very simple test</div>""");varpdf=awaitpage.PdfStreamAsync(newPdfOptions(){Format=PaperFormat.Legal,Landscape=true,MarginOptions=newMarginOptions(){Top="0",Bottom="0",Left="0",Right="0"}});varfile=File.OpenWrite("test.pdf");awaitpdf.CopyToAsync(file);file.Close();awaitbrowser.CloseAsync();
Expected behavior:
The PDF is generated.
Actual behavior:
It crashes.
Versions
Which version of PuppeteerSharp are you using? I tried radomly some of them, since 9.0.0 to the most recent.
Which .NET runtime and version are you targeting? .NET 8+
Additional Information
This only happens if you don't specify a unit in the margin options, like with the "0" thing here. By using something like "0cm" it works, but the behavior is non-intuitive and error-prone as it is not described anywhere (also, you would expect it to work as it expects a string and in CSS this is perfectly valid).
The text was updated successfully, but these errors were encountered:
Description
All .PdfAsync variants throw an:
When you use 0 in the measures.
Complete minimal example reproducing the issue
Expected behavior:
The PDF is generated.
Actual behavior:
It crashes.
Versions
Additional Information
This only happens if you don't specify a unit in the margin options, like with the "0" thing here. By using something like "0cm" it works, but the behavior is non-intuitive and error-prone as it is not described anywhere (also, you would expect it to work as it expects a string and in CSS this is perfectly valid).
The text was updated successfully, but these errors were encountered: