DocImage.axd View Method "NO" Response

I am currently evaluating the Doconut viewer version 24.12.0 for use in our .NET Framework 4.7.2 MVC web application and I am encountering an peculiar problem.

Our application has stored images and documents and has an API to return a byte array containing the image/document. Using an AJAX call in the javascript OpenDocument method in the page, I am calling an OpenDocument method in the controller which makes a call to our API and the byte array it returns is then passed to the viewer OpenDocument method. This returns a token that is in turn returned to the AJAX call that calls the View method in DocImage.axd. The status code for the response is 200, but the response is simply “NO”.

Here is the payload being passed to the method:
image.png (9.9 KB)

And here is the response:
image.png (3.6 KB)

I am assuming I have something configured incorrectly, but I am not certain what that could be. I am using a trial license for Doconut if that makes any difference.

@swilsonibtapps,

Thank you for reaching out and providing detailed information about the issue you’re facing. Our team has thoroughly tested the scenario but was unable to replicate the issue on our end.

To help us investigate and resolve the issue more effectively, I would kindly ask you to provide a minimal sample project where the issue can be replicated.

Looking forward to your response and thank you for your cooperation.

@gabriel.vega,

The project for the application we are trying to implement the control into is quite large so it will require some time to come up with a scaled down project that mimics the circumstances under which we are attempting to use the control and returns the same response.

In the meantime, I revisited the Doconut sample projects and I see that it returns the same response. The difference between the sample project and the implementation in our application project is that the sample project continues with a series of further requests (image.png (47.5 KB)) to return the requested document while in our application it only does one further request (image.png (74.9 KB)) and then stops. This implies to me we missed something in our implementation of the Doconut control and just need to track down what it is we missed.

Thanks.

@swilsonibtapps,

Thank you for the detailed information. To better assist you, could you please specify the file format you’re trying to open? Additionally, it would be helpful if you could share the source code for the configuration related to your file type, such as PdfConfig or WordConfig, depending on your implementation.

If possible, please also attach a sample file (without any confidential information) that you’re trying to open. This will help us replicate the issue and provide more precise support.

Thanks again for your collaboration!

@gabriel.vega,

While we intend to use this for multiple file formats, my initial testing has been with a JPG file (18414.jpg (10.3 KB)).

As for the config, we are using what is in the sample projects. Our internal image API returns a byte array which we are passing to the viewer OpenDocument method along with the file extension and config:

		[Route("Common/GetDocumentImage")]
		[HttpPost]
		public async Task<ContentResult> GetDocumentImage(string filename)
		{
			var imageApiClient = this.GetImageApiClient();
			var response = await imageApiClient.GetDocumentImage(filename);

			if (!response.Success)
			{
				Log.Error(response.Exception?.Message, response.Exception);
				return null;
			}

			if (response.Data.Length == 0)
			{
				Log.Error("Empty document byte array");
				return null;
			}

			var viewer = new Viewer
			{
				ID = "ctlDummyDoc",
				DebugMode = true,
			};

			BaseConfig config = null;

			switch (new FileInfo(filename).Extension.ToUpper())
			{
				case ".DOC":
				case ".DOCX":
				case ".DOT":
				case ".DOTX":
				case ".ODT":
					config = new WordConfig { DefaultRender = false, }; // turn off, if you don't want hyperlinks
					var pdfConfig = (config as WordConfig).PdfConfig;
					pdfConfig.ExtractHyperlinks = true;
					pdfConfig.HyperlinksPageCount = 5; // check hyperlinks for first 5 pages only; specify 0 for all.
					break;
				case ".XLS":
				case ".XLSX":
				case ".ODS":
				case ".CSV":
					config = new ExcelConfig
					{
						DefaultRender = false,
						SplitWorksheets = true,
						ShowEmptyWorkSheets = false,
						PaperSize = ExcelPaperSize.PaperA3,
						PaperLandscape = true,
						CalculateFormula = true,
						AutoFitContents = true,
						RemoveEmptyContent = false,
						CustomStyles = new ExcelConfig.CustomStyleCell
						{
							CustomStyleDateTime = "dd-MM-yyyy",
						},
						DocumentCulture = "en-US",
					};
					break;
				case ".PPT":
				case ".PPTX":
				case ".ODP":
					config = new PptConfig() { DefaultRender = true };
					break;
				case ".DWG":
				case ".DXF":
					config = new CadConfig { DefaultRender = false, ShowColor = false, WhiteBackground = true, ShowModel = true, ShowLayouts = true, LineWidth = 1, Check3DSolid = false };
					break;
				case ".DGN":
					config = new CadConfig { DefaultRender = false, ShowColor = false, WhiteBackground = true, ShowModel = true, ShowLayouts = true, LineWidth = 1, Check3DSolid = false };
					break;
				case ".EML":
				case ".MSG":
					config = new EmailConfig { EmailEncoding = Encoding.UTF8, DefaultRender = false, RemoveLastWhitePage = true, TimeZoneOffset = new TimeSpan(-3, 0, 0) };
					break;
				case ".PDF":
					config = new PdfConfig { DefaultRender = false, ExtractHyperlinks = true, HyperlinksPageCount = 5 }; // specify true if you need hyperlinks
					break;
				case ".PNG":
				case ".BMP":
				case ".JPG":
				case ".JPEG":
				case ".GIF":
				case ".CDR":
				case ".CMX":
				case ".DNG":
				case ".EPS":
				case ".ICO":
				case ".TGA":
				case ".WEBP":
					config = new ImageConfig { MaxImagePixelSize = 2000, TransparentPng = false };
					break;
				case ".TIF":
				case ".TIFF":
					config = new TiffConfig();
					break;
				case ".PSD":
					config = new PsdConfig { MaxImagePixelSize = 2000 };
					break;
				case ".TXT":
					config = new TxtConfig { PaperSize = DocPaperSize.A4, FileEncoding = Encoding.UTF8 };
					break;
				case ".MPP":
				case ".MPPX":
					config = new ProjectConfig { ExportPdfA = true, DefaultRender = false, PaperSize = MppPaperSize.A3 };
					break;
				case ".VSD":
				case ".VSDX":
					config = new VisioConfig { ExportPdfA = true, DefaultRender = false };
					break;
				case ".DCM":
					config = new DicomConfig { ShowAnimation = true };
					break;
				case ".MHT":
					config = new MhtConfig { DefaultRender = false };
					break;
				case ".XPS":
					config = new XpsConfig { DefaultRender = false };
					break;
			}

			var token = viewer.OpenDocument(response.Data, new FileInfo(filename).Extension.ToUpper(), config);

			if (string.IsNullOrWhiteSpace(token))
			{
				return this.Content($"Error : {viewer.InternalError}");
			}

			return this.Content(token);
		}

Thanks.

@gabriel.vega,

After further evaluation, I have discovered that response from the AJAX call is being interpreted as JSON and is resulting in a parse error that is stopping the execution of the call. I think if I can determine how to avoid the response from being treated as JSON, it should start working.

Thanks.

@swilsonibtapps,

After investigating your issue, our development team has identified the cause of the behavior you’re experiencing.

The “NO” response occurs because the ExtractHyperlinks property, when set to true, retrieves all hyperlinks from the document. If the document you’re opening does not contain any hyperlinks, the response will simply be “NO”. This is not a processing error but the expected behavior. If hyperlinks are present, they are serialized to JSON and returned in the response. This functionality is supported for both Word and PDF files.

Regarding the series of additional requests, these correspond to each page of the document and their respective thumbnails. Additionally, for each page, a list of hyperlinks is retrieved, if available.

As for the configuration you provided, it appears to be correctly implemented.

If you have any further questions or concerns, please don’t hesitate to contact us.