Error with annotation

Hello,

I am trying to update to the new version, but in the annotations part, when invoking the OpenAnnotation() method, I get an error in the browser console.

Uncaught TypeError: $(…)[_0x2343[82]] is not a function
AnnotationUI[_0x2343[80]][_0x2343[133]]/< https://localhost:7222/lib/dnut/annotation.js:13
jQuery 9
_0x2343[80]][_0x2343[133] https://localhost:7222/lib/dnut/annotation.js:13
AnnotationUI[_0x2343[80]][_0x2343[115]]/< https://localhost:7222/lib/dnut/annotation.js:13
jQuery 9
_0x2343[80]][_0x2343[115] https://localhost:7222/lib/dnut/annotation.js:13
AnnotationUI https://localhost:7222/lib/dnut/annotation.js:13
_0x2f5ex1[_0x2cbe[1]][_0x2cbe[0]]/this[_0x2cbe[222]]/< https://localhost:7222/lib/dnut/docViewer.js:13
jQuery 8
_0x2cbe[1]][_0x2cbe[0]]/this[_0x2cbe[222] https://localhost:7222/lib/dnut/docViewer.js:13
_0x2cbe[1]][_0x2cbe[0]]/this[_0x2cbe[381] https://localhost:7222/lib/dnut/docViewer.js:13

@Jorge_Garces,

Thank you for reaching out. To better assist you, could you please provide the following information:

  1. Which version of .NET are you currently using? (.NET Framework, .NET Standard/Core, or .NET 6)?
  2. Additionally, could you please send a small project example where the error occurs?

With this information, I’ll be able to assist you more effectively.

Thanks for your help!

Hello Gabriel,

Attached the example in Asp.Net Core 8,

Test.zip (1.8 MB)

Error doconut.png (78.2 KB)

@Jorge_Garces,

Thank you for sharing the sample project. The project had 2 issues.

The issue was due to missing jQuery UI references. The Annotation plugin relies on jQuery UI. I’ve added the necessary jQuery UI CSS and JavaScript references to the project.

Additionally, the source images used by the Annotation plugin to draw notes were missing from the \wwwroot\images folder. You can find all the required files in the Doconut Samples Zip.

I’ve attached the project with the fixes applied.
Jorge_Garces-Sample.zip (1.9 MB)

Hello Gabriel,

Thank you for the information. Could you help me with another issue? When I try to open the annotation XML, it shows me this error (see the attached picture). I’ve also attached an example

Error doconut 2.png (26.1 KB)

Ejemplo.zip (2.0 MB)

@Jorge_Garces,

Thank you for sharing the details and the example file. I was able to replicate the issue you’re experiencing with the annotation XML, but unfortunately, I couldn’t get the exact cause of the error at this time.

I’ll escalate this to our development team for further review and will update you as soon as we have more information.

@Jorge_Garces,

Our development team has informed me that there are differences in how URLs are handled in .NET Core and .NET 6 compared to .NET Framework version.

For these newer versions, it’s important to provide the complete URL in the annotation, and it should not contain any colons (“:”). Specifically, you should ensure that the URL format starts with "http://" rather than "https!//".

For example, in your annotation.xml file, the line should look like this:

<Note>http!//yourdomain.com/image/f40772cd-512c-443d-b762-c501d64868d1.png</Note>

Please update the URL in your XML file accordingly, and let us know if you need further assistance.

This is a mistake on your part because not all images are public, as is the case with the stamps. Please correct it. If you look at the example you yourselves provide, this is what it says. This is affecting us, and it is urgent. When will you correct it?

This was working fine in the previous version, you can use it as a reference to fix it.

Your code example:
function ImageStamp() {
if (null != objctlDoc.AnnotationController()) {
var objStampImage = new ImageAnnotation({ left: 200, top: 200, width: 260, height: 55 });
objctlDoc.AnnotationController().AddAnnotation(null, objStampImage, null);

    objStampImage.SetNote('/images/Approved_Stamp.png');
    objStampImage.Paint();
}

}

Error doconut 3.png (94.1 KB)

@Jorge_Garces,

I’ve spoken with the development team about this question and I want to give you a detailed explanation of how paths work in .NET 4.7 and .NET Core/NET 6, and why images must be public and use absolute paths.

In .NET Core and .NET 6, it is mandatory to use absolute paths, such as http://domain.com/images/image.png. This is necessary so that resources can be accessed correctly from anywhere. Relative paths, such as images/img.png, are not supported, as the framework does not complete the path automatically.

In previous versions, such as .NET 4.7, although it seems that a relative path (images/img.png) could be used, it is not actually supported directly. What happens is that, in .NET 4.7, Doconut completes the path internally using the HttpContext. This allows us to build the absolute path automatically, but the image is still accessible because the web context provides the full request information.

It is important to note that in both cases, the image must be public and have an absolute path if you need to access it over the web. If the images are not public, our DLL will not be able to download them correctly. This is critical for proper functioning in .NET Core and .NET 6, as there is no mechanism to automatically complete the path in these environments.

To properly implement this behavior in your application, you could use code like the following in .NET Core or .NET 6 to generate an absolute URL based on a relative path:

private readonly IHttpContextAccessor _accessor;

public YourController(IHttpContextAccessor httpContextAccessor)
{
    _accessor = httpContextAccessor;
}

public IActionResult YourMethod()
{
    var request = _accessor.HttpContext.Request;
    string imgUrl = "images/f40772cd-512c-443d-b762-c501d64868d1.png";
    var fullImgUrl = $"{request.Scheme}://{request.Host}/{imgUrl}";
    // You can now use fullImgUrl as an absolute URL
}

I am sorry to read this and see the product deteriorating. On the other hand, the solution you are offering is not legal, as you are violating data protection laws by stating that the images must be exposed in a public and static environment.

Here are some other technical considerations.

  • Statement on Relative Paths in .NET Core/6: The claim that “in .NET Core and .NET 6, it is mandatory to use absolute paths” is incorrect. Relative paths are supported in ASP.NET Core and .NET 6. However, how they are interpreted depends on the request context. When using relative paths in a view or controller, the framework resolves them relative to the current request, just like in .NET Framework. The key difference is that in scenarios like Single Page Applications (SPAs) or when resources are needed outside of the site’s context, absolute paths might be required.
  • Use of HttpContext in .NET 4.7: In .NET Framework 4.7, using relative paths is common and works correctly within the application context, just as it does in .NET Core/6. There’s no explicit need to convert them to absolute paths as long as the web application’s context is well defined.
  • Public Accessibility of Images: The statement “if the images are not public, the DLL will not be able to download them correctly” is somewhat unclear. Accessing images or other resources depends on the authorization policies configured on the server. If an image needs to be publicly accessible, it should be configured as such, but this isn’t directly tied to .NET or its ability to handle paths.

@Jorge_Garces,

Thank you for sharing your feedback. I understand your concerns, and I apologize for any inconvenience this may have caused.

For the current version, 24.8.0, the solution indeed requires the use of absolute URLs for images. This approach was necessary to ensure functionality, but I understand it may not be ideal for your needs.

Our development team is actively working on an improvement for version 24.9.0, where we aim to implement a solution that works similarly to how paths are handled in .NET Framework, allowing for greater flexibility with relative URLs. We appreciate your patience while we work on this update.

If you have any further questions, please feel free to reach out. We are committed to finding the best possible solution.