Rank: Newbie Groups: Member
Joined: 2/21/2018 Posts: 3
|
Hi, I'm getting an error 'Operation is not valid due to the current state of the object.'when trying to run HtmlToPdf.ConvertUrl. Here's the code I'm using: Quote: PdfDocument pdf = new PdfDocument(); HtmlToPdf.ConvertUrl("https://www.google.com", doc); doc.Save(@"c:\saved_pdf_" + DateTime.Now.ToString("yyyMMdd"));
As you can see it is failing for even just a basic site. The commented out code
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,221
|
Hi,
This usually occurs when your code does not have permissions to write to the target location (in your case the root directory of your C drive). Try save the result to another folder and see if it works.
Thanks!
|
Rank: Newbie Groups: Member
Joined: 2/21/2018 Posts: 3
|
That could be a problem, but as of now the exception is being thrown even before it has a chance to be saved. Here's a ss of what's going on.
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,221
|
Hi,
Please make sure you use the latest build and then capture and post the stack trace of the exception. We will see what we can find based on the stack trace. Make sure you contains all the information for all InnerException (if any) as well.
Thanks!
|
Rank: Newbie Groups: Member
Joined: 2/21/2018 Posts: 3
|
Yup I checked I have the latest build, here's the entire exception:
at EO.Internal.jo.a(Boolean& A_0, a93[] A_1, String A_2, String A_3) at EO.Internal.jo.a(a93[] A_0, String A_1, String A_2) at EO.Internal.jo.o.c() at EO.Internal.jo.o.f() at EO.Internal.jo.n() at EO.Internal.jo.a(Boolean& A_0, a93[] A_1, String A_2, String A_3) at EO.Internal.jo.a(a93[] A_0, String A_1, String A_2)\r\n at EO.Internal.av6.b() at EO.Internal.av6.a(WindowsIdentity A_0) at EO.WebEngine.Engine.Start(WindowsIdentity user) at EO.Internal.s2.b() at EO.Internal.nr.a(s2& A_0) at EO.Internal.al0.a(av A_0, s2& A_1) at EO.Internal.pd..ctor(av A_0, HtmlToPdfOptions A_1) at EO.Pdf.HtmlToPdfSession.a(HtmlToPdfOptions A_0) at EO.Pdf.HtmlToPdfSession..ctor(HtmlToPdfOptions A_0, Boolean A_1) at EO.Pdf.HtmlToPdf.ConvertUrl(String url, PdfDocument doc, HtmlToPdfOptions options) at EO.Pdf.HtmlToPdf.ConvertUrl(String url, PdfDocument doc) at USCM.Feature.FeaturedHeadline.Repositories.FeaturedHeadlineRepository.getPrintPdf(List`1 urls) in D:\\Projects\\FeaturedHeadlineRepository.cs:line 263 at USCM.Feature.FeaturedHeadline.Controllers.ArticlesCommentController.ContentPreviewPrint(JObject json) in D:\\Projects\\ArticlesCommentController.cs:line 56 at lambda_method(Closure , Object , Object[] ) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)"
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,221
|
Hi, This is probably still due to permission issue. The stack trace indicates that it failed while creating child process (which is needed since EO.Pdf runs the native browser engine inside child processes). You can try to follow the steps here and see if it resolves the issue: https://www.essentialobjects.com/doc/common/eowp.aspxThis would require less permission than the default approach. If that still does not work, we will need to have remote access to your system in order to determine exactly what caused the failure. Thanks!
|