Aspose PDF 22.3 breaks HTMLFragment

Spent all day on this. This issue ONLY happens when I deploy to staging/production. In Visual Studio debugger, all is fine. BUT, this code fails when I deploy to IIS:

’ This can be anything with a tag in it. Normal text works fine
Dim HTML as String = “Any HTML!
Using NewPDF As New Aspose.Pdf.Document
’ Add a page to pages collection of document
Dim CurrentPage As Aspose.Pdf.Page = NewPDF.Pages.Add()
Dim Fragment As New Aspose.Pdf.HtmlFragment(HTML)
CurrentPage.Paragraphs.Add(Fragment)
Dim PDFExportMS As New MemoryStream
NewPDF.Save(PDFExportMS)
End Using
I get this error:

System.ArgumentException: Only formats 0 and 2 have been defined: 128
at #=zx_BzR9NcNH5QBsbIdDGwuKj3rW9g$GSskvhQby8=.#=zoTXvYpxqM_tD(#=zz3D7NDTO$79L5drznQ== #=zvFFapJDeyp9ueiegtg==, #=zj5MmjlqtmgweZk83Ez04o6xIzVYHeguYZg== #=zRlXZpH4=) at offset 118
at #=zx_BzR9NcNH5QBsbIdDGwuKj3rW9g$GSskvhQby8=.#=z1zHCb2cQ$8ytbQ35Vw==(#=zj5MmjlqtmgweZk83Ez04o6xIzVYHeguYZg== #=zRlXZpH4=) at offset 82
at #=zx_BzR9NcNH5QBsbIdDGwuKj3rW9g$GSskvhQby8=…ctor(#=zj5MmjlqtmgweZk83Ez04o6xIzVYHeguYZg== #=zRlXZpH4=, #=zo09Uh82UM4UxTlxSPa3R6nuo72WGm1QwHg== #=zM$GvS9c=) at offset 85
at #=zn7Sq6GNUte9MAfOenSUKa9DaEA_j$l7eNDxpZ8Q=.#=zafVCQJIIfVzi9NIPBg==(#=zo09Uh82UM4UxTlxSPa3R6nuo72WGm1QwHg== #=zM$GvS9c=) at offset 52
at #=zn7Sq6GNUte9MAfOenSUKa9DaEA_j$l7eNDxpZ8Q=.#=z63r26bI=() at offset 0
at #=zn7Sq6GNUte9MAfOenSUKa9DaEA_j$l7eNDxpZ8Q=.#=zartCQbI=(#=z3qws9mC6niHwfnwGPrF99D6qHUDk8D19SA== #=zZqpN_EE=, System.String #=zoAXeViY=) at offset 15
at #=zqEVJfdK0DaozDp6cu268zgiefVYKyBRSRA==.#=zS1TG0Wpx0xff(#=zDbmaHlG1237tF$gTEKoauwMpMssd4ekXOAdgLao= #=zdZk6pIWxCW6M, #=zNeCXnjSvd15XUcKRq$C4w_NbXlUR_F_$d7sCuSY= #=z2zX4hMajmtB$, System.Char #=zJmaiBgs=, #=zOBXjbZk5CiAqQz4W9wbb0sn3PwB0X0t2KSxRlA4= #=zz81Jno8=, #=zC_fnxgTAztUoAJHq0YrKvafLqOE2SU2PVZeicC0=& #=zM$GvS9c=) at offset 87
at #=zMUgtuaJFlT0M9FJQIYpBCngWjF6bbw87MQ_0NR4=.#=zXhFvT9Hm4Ifz$UVitg==(#=zadVjB6w_eVBpUIRRr3tn6_0aiavE5ET2VIj5Ji8= #=zl0ett0kk_BiM, #=zh3TTd39AN390NY_OArE5akugo26idkn9bQ== #=zz81Jno8=, System.Char #=zJmaiBgs=, System.Int32 #=zr43VnkyEYQlT, System.Byte #=z2gNwMDs=) at offset 124
at #=zMUgtuaJFlT0M9FJQIYpBCngWjF6bbw87MQ_0NR4=.#=z3ScVwa8t1ALE(#=zh3TTd39AN390NY_OArE5akugo26idkn9bQ== #=zz81Jno8=, System.Char #=zJmaiBgs=, System.Collections.Generic.List1 #=zgZ8H$iRZTGDQYNKY5w==) at offset 844 at #=zMUgtuaJFlT0M9FJQIYpBCngWjF6bbw87MQ_0NR4=.#=zJrbhSGOfP7_R(#=zh3TTd39AN390NY_OArE5akugo26idkn9bQ== #=zz81Jno8=, System.Char #=zJmaiBgs=) at offset 335 at #=zdvj$j4kxNS0Tw1KKXQy1Jigi15gOhkv7r$wqUts=.#=zj9QY5ZvOGFDV(#=zP8cuR2RHmVVvYBD4CxcC82C4Fj0xBcMDVw== #=z408NtZg=) at offset 99 at #=zdvj$j4kxNS0Tw1KKXQy1Jigi15gOhkv7r$wqUts=.#=zj9QY5ZvOGFDV(#=zP8cuR2RHmVVvYBD4CxcC82C4Fj0xBcMDVw== #=z408NtZg=) at offset 327 at #=zdvj$j4kxNS0Tw1KKXQy1Jigi15gOhkv7r$wqUts=.#=zj9QY5ZvOGFDV(#=zP8cuR2RHmVVvYBD4CxcC82C4Fj0xBcMDVw== #=z408NtZg=) at offset 327 at #=zdvj$j4kxNS0Tw1KKXQy1Jigi15gOhkv7r$wqUts=.#=zj9QY5ZvOGFDV(#=zP8cuR2RHmVVvYBD4CxcC82C4Fj0xBcMDVw== #=z408NtZg=) at offset 327 at #=zdvj$j4kxNS0Tw1KKXQy1Jigi15gOhkv7r$wqUts=.#=zBms9ODj0L2c7(#=zP8cuR2RHmVVvYBD4CxcC82C4Fj0xBcMDVw== #=z408NtZg=) at offset 127 at #=zdvj$j4kxNS0Tw1KKXQy1Jigi15gOhkv7r$wqUts=.#=zBms9ODj0L2c7(#=zP8cuR2RHmVVvYBD4CxcC82C4Fj0xBcMDVw== #=z408NtZg=) at offset 216 at #=zdvj$j4kxNS0Tw1KKXQy1Jigi15gOhkv7r$wqUts=.#=zBms9ODj0L2c7(#=zP8cuR2RHmVVvYBD4CxcC82C4Fj0xBcMDVw== #=z408NtZg=) at offset 216 at #=zdvj$j4kxNS0Tw1KKXQy1Jigi15gOhkv7r$wqUts=..ctor(#=zP8cuR2RHmVVvYBD4CxcC82C4Fj0xBcMDVw== #=z2vnuhbA=) at offset 40 at #=zNLf95IFfifGIoaXKuRzcNOMogpKmXxayyA==.#=zYhUBWpo=(#=z7_CQ4jx0L64Kw9i0mevudu8= #=z02h4SQs=, #=zS6WhK879jmWhCyxbDLDJ7OP8zemEhAkDmg== #=zxhCBbZI=, #=zxsL2y4MBJQUD_UHwIwt5w4kJme$w0vT5GA== #=z$xe$xSN6N_dX, #=zfWlGV7dhTUFkybysb8upcfR5mvh0R7iRKA== #=zNohTa22$0fFWQAvpNw==) at offset 56 at #=zvzmV6bsZ9lk1W7D95g3a85sjw6lgwYWV$g==.#=zKDaqqK5LudoO(#=zeT9mhzEzyN1St21HQXfbBuo= #=zhT4YR1c=, #=z1n7Y2cFVbHS5I0aoI6$Gmll0XhV #=zwUaBFXV9u6Xm2bT6CQ==, #=zcAd9TTWMZv81Q0VnbvGINUxSmlxS #=zfnm8RYQ=, #=zryFLjVczZhHrYgbG4wWou7tX9G3h #=z0DoT0kU=, #=z_0COwcC8iWyOw2KM_fZWCJo_l0mVjepN_b_EMGc= #=zrnJBrRfg7swOHx0nhUjBfNo=, #=zz8Z1Ak5$_lkKxf$MIq5FLu4= #=zCcFHQDZhMzTcQTH3Zg==) at offset 123 at #=zvzmV6bsZ9lk1W7D95g3a85sjw6lgwYWV$g==.#=zMHKqvmg=(#=zcAd9TTWMZv81Q0VnbvGINUxSmlxS #=zfnm8RYQ=, #=zryFLjVczZhHrYgbG4wWou7tX9G3h #=z0DoT0kU=) at offset 189 at #=zryFLjVczZhHrYgbG4wWou7tX9G3h.#=zMHKqvmg=(#=zcAd9TTWMZv81Q0VnbvGINUxSmlxS #=zfnm8RYQ=) at offset 0 at #=zS$w3Ja4sIU045P0g$hUajbukGsE__Z3hEQ==.#=zkJG7s_8=() at offset 23 at #=zS$w3Ja4sIU045P0g$hUajbukGsE__Z3hEQ==.#=zrSmBpsI=() at offset 39 at #=zVHidEbcjPZ7zks5jdhdmbnqa5MQr407GGw==.#=zBZZhg2L2Mb7G(#=zHqBK91uiXO86VZghEDQh$sE= #=z6zn4YxX2ng4gbUTmDg==, #=zryFLjVczZhHrYgbG4wWou7tX9G3h[] #=zBl59zZo_eCZX, #=zcAd9TTWMZv81Q0VnbvGINUxSmlxS #=zfnm8RYQ=, System.TimeSpan #=z_CdeQi8=) at offset 57 at #=zcLPoGGmiWBzXIQRXbu6VCw1rrsGI.Render(#=zcAd9TTWMZv81Q0VnbvGINUxSmlxS #=zfnm8RYQ=, System.TimeSpan #=z_CdeQi8=, #=z7_CQ4jx0L64Kw9i0mevudu8=[] #=zXuYTsco=, #=zeT9mhzEzyN1St21HQXfbBuo=[] #=zI3BJZ6U=) at offset 93 at #=zcLPoGGmiWBzXIQRXbu6VCw1rrsGI.Render(#=zcAd9TTWMZv81Q0VnbvGINUxSmlxS #=zfnm8RYQ=, System.TimeSpan #=z_CdeQi8=, #=zeT9mhzEzyN1St21HQXfbBuo=[] #=zI3BJZ6U=) at offset 22 at #=zr2ZDOEX$GQIbd0pVdCTASIuBmLWl.Render(#=zcAd9TTWMZv81Q0VnbvGINUxSmlxS #=zfnm8RYQ=, #=z1qcNUd8= #=zhT4YR1c=, System.TimeSpan #=z_CdeQi8=) at offset 0 at #=zr2ZDOEX$GQIbd0pVdCTASIuBmLWl.Render(#=zcAd9TTWMZv81Q0VnbvGINUxSmlxS #=zfnm8RYQ=, #=z1qcNUd8= #=zhT4YR1c=) at offset 24 at #=zY5Yo01a0fWkJiiSij13HHu2edcsj.#=zzi80H2DDS4U9(System.IO.Stream #=z4ZcsL8IaiNUL, Aspose.Pdf.Document #=z_k1CuJ9yeqnB, Aspose.Pdf.HtmlLoadOptions #=zxmUwlxaroOGo, System.Collections.Generic.IList1 #=zl$NKiUrUFBsV, System.String #=z23Z1nAoaBVND, Aspose.Pdf.Matrix #=zP7exGBE=) at offset 113
at Aspose.Pdf.FormattedFragment.#=zxXWkfds=(System.Double& #=zWisNBcg=, System.Double& #=zemZyr_o=, System.Boolean #=zM6_HbXlFf7Q4, System.Double #=zYOiNGjs=, System.Double #=zDCv0uqA=, System.Collections.Generic.List1 #=zquj74W0=, System.Collections.Generic.List1 #=zkzS991wdZkGQKRHZUg==, System.Int32& #=zIfYjrKluGjbZkF3lLnjbJOQd0CsU, Aspose.Pdf.Page #=zzXd1$UE=, Aspose.Pdf.MarginInfo #=zKVZ2wH4=, Aspose.Pdf.Table #=zvHSKTYw=, System.Double& #=zQ4evNIJvS9JB, System.Boolean #=zZjDlSmTZFOg8, System.Boolean #=zXvlAhD7MQgA$) at offset 0
at #=zrWR_2hKODD1gTtdvBsPn$ME=.#=zxXWkfds=() at offset 0
at Aspose.Pdf.Page.#=zk8T3gPQ=(Aspose.Pdf.Page #=zzXd1$UE=) at offset 668
at Aspose.Pdf.Page.#=zBn1kv__DWSxu3Af7aA==() at offset 25
at Aspose.Pdf.Document.ProcessParagraphs() at offset 409
at Aspose.Pdf.Document.#=zo8lFaF$NRFRv(System.IO.Stream #=zr0CZUt8=, Aspose.Pdf.SaveOptions #=zCD5lPvK$eX2l) at offset 189
at Aspose.Pdf.Document.Save(System.IO.Stream output) at offset 18

I recently updated to Aspose.PDF 22.4 and got this error in code that was written and tested over a year ago. Again, in Visual Studio 2022 debugger, it works fine. Deployed to webserver (Server 2019, IIS) it fails every time no matter what HTML is included.

This is VB.NET with .NET 4.72

Verified DLL versions etc., no help. Finally rolled back to 22.2 and the problem goes away.

I don’t need anything in 22.4 so I guess I am good, but could not find anyone complaining about this and have never seen this error before.

@edgarecayce

It is quite difficult to determine the reason for this error without replicating it in our environment. However, we will surely investigate it. Can you please share at which particular line the exception occurs?

Hi, thanks for the quick response.

It crashes at NewPDF.Save(PDFExportMS) (see last line of stack trace)

Also note, that this support page is displaying the HTML string I am using as HTML, which means you cant’s see the span tag in my code sample. If you insert simple text there is no problem. but if you put HTML tags in the HTML string, it fails. Let me try showing it as preformatted text:

Dim HTML as String = “<span>Any HTML!</span>”

@edgarecayce

An investigation ticket as PDFNET-51751 has been logged in our issue tracking system to analyze what significant change in new release can cause such issue. We will further let you know in this forum thread as soon as some updates are available regarding ticket resolution. Please be patient and spare us some time.

We are sorry for the inconvenience.

Hi folks, any word on this? 22.6 has same problem.

@edgarecayce

We are afraid that the earlier logged ticket has not been yet resolved due to other issues in the queue. We will definitely investigate and resolve it on a first come first serve basis and let you know as soon as it is resolved. Please be patient and spare us some time.

We are sorry for the inconvenience.

Just FYI, bug is still present in 22.9

@edgarecayce

Because the earlier logged ticket has not been yet resolved, you are facing it in the latest version. We will inform you as soon as we this issue is fixed. Please spare us some time.

We are sorry for the inconvenience.

Just in case anyone is interested, 24.1 seems to have fixed the problem, or some update between 22.9 and 24.1

@edgarecayce

It is nice to know that your issue seems to be resolved. Some internal update must have fixed this issue as well. Nevertheless, we will keep the ticket open and after we’ve found that everything is good to close it, we will close it.