Specifying HTML resource prefix while rendering a document in .NET

Hi

We are using GroupDocs.Viewer for .NET 17.11 and trying to migrate to the latest version (20.3, 20.4).
Is there anyway to set specifying HTML resource prefix when resources for the document are obtained via some REST API method?

HtmlOptions options = new HtmlOptions();
options.HtmlResourcePrefix = http://example.com/api/pages/{page-number}/resources/{resource-name};
List pages = htmlHandler.GetPages(fileStream, guid, options);
var htmlResoures = list.Where(i => i.PageNumber == page).Select(i => i.HtmlResources);
Stream stream = _viewerHtmlHandler.GetResource(guid, htmlResoures);

Thank you.

1 Like

@AmyK,

Please have a look at these migration notes. They will help you in a quick migration.

We’re investigating this scenario. Your investigation ticket ID is VIEWERNET-2420. As there’s any update, you’ll be notified.

Thank you @atirtahir3.
We have looked into migration notes. However, we still need more information.
Please let us know when a fix has been released.

1 Like

@AmyK,

We are still investigating your scenario.

Sure, you’ll be notified about the investigation outcomes.

Another question, is it possible to retrieve stream when rendering a document as PDF in version 20.4?

// use container.Stream to manipulate pdf representation of the input file.
var container = viewerImageHandler.GetPdfFile(fileStream, fileName);
return container.Stream;

Thank you in advance. @atirtahir3

@AmyK,

We have an update on VIEWERNET-2420. You can specify any resource prefix. Please download this sample_app.zip (309.7 KB). It demonstrates how to set HTML resource path (we shared two options to set resource path), the output will contain your resource path like this html_resources.png (325.9 KB). Both options in the sample application serve the same purpose.

Following documentation articles will help you:

Will try that. Thank you

1 Like

@AmyK,

You are welcome.

Could you please provide some example that implement IFileStreamFactory to return stream when rendering into PDF in version 20.4?

      using (Viewer viewer = new Viewer(() => File.OpenRead("sample.docx")))
      {
         FileStreamFactory fileStream = new FileStreamFactory();
         PdfViewOptions viewOptions = new PdfViewOptions(fileStream);
         viewer.View(viewOptions);
         return stream;
      }

     internal class FileStreamFactory : IFileStreamFactory
         {
             public Stream CreateFileStream()
             {
                 // ?
             }
     
             public void ReleaseFileStream(Stream fileStream)
             {
                 // ?
             }
         }
1 Like

@AmyK,

We’re working on such an example. Your will be notified about the outcomes.

@AmyK,

Have a look at this code example. It demonstrates how to get PDF stream. You can download this open-source project and evaluate this feature.

Great!! Thank you @atirtahir3

1 Like

@AmyK,

You’re welcome.