Configurazione in .NET Framework

Configurazione Web.config

Registra l'HttpHandler nel tuo file web.config.

Below IIS 7
<httpHandlers>
  <add verb="GET,POST" path="DocImage.axd" type="Doconut.DocImageHandler, Doconut" />
</httpHandlers>
IIS 7 and above
<handlers>
  <add name="DocImage" verb="GET,POST" path="DocImage.axd" type="Doconut.DocImageHandler, Doconut" />
</handlers>

Aggiungi licenze

Doconut rileva automaticamente le licenze nella cartella radice, oppure puoi aggiungerle manualmente.

Manual License Path
var licenseFilePath = Server.MapPath("~/Doconut.Viewer.lic");
var docViewer = new Viewer(licenseFilePath);

Configurazione per web.config

Le seguenti voci di configurazione sono necessarie per il file web.config per garantire la compatibilità con Doconut e .NET Framework.

web.config
<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Text.Encodings.Web" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Text.Encoding.CodePages" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Text.Json" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="8.0.3.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Bcl.AsyncInterfaces" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Drawing.Common" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="MessagePack" publicKeyToken="9c7f9b36b37eaddf" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.5.140.0" newVersion="2.5.140.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.1.3.0" newVersion="4.1.4.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

Pacchetti NuGet richiesti

Per garantire che il tuo progetto sia completamente compatibile con Doconut e .NET Framework, i seguenti pacchetti NuGet devono essere inclusi:

  • MessagePack - Version 2.5.140
  • MessagePack.Annotations - Version 2.5.140
  • Microsoft.Bcl.AsyncInterfaces - Version 8.0.0
  • Microsoft.NET.StringTools - Version 17.6.3
  • System.Collections.Immutable - Version 6.0.0
  • System.Drawing.Common - Version 6.0.0
  • System.Memory - Version 4.5.5
  • System.Reflection.Emit - Version 4.7.0
  • System.Reflection.Emit.Lightweight - Version 4.7.0
  • System.Security.Cryptography.Pkcs - Version 8.0.0
  • System.Text.Encoding.CodePages - Version 8.0.0
  • System.Text.Encodings.Web - Version 8.0.0
  • System.Text.Json - Version 8.0.3

Opzioni di configurazione del rendering

Puoi configurare il comportamento di rendering utilizzando le seguenti opzioni:

  • CadConfig: Utilizzato per file DWG, DXF e DGN.
  • EmailConfig: Utilizzato per file EML, EMLX e MSG.
  • EpubConfig: Utilizzato per file EPUB.
  • ExcelConfig: Utilizzato per file Excel e CSV.
  • MhtConfig: Utilizzato per file MHT.
  • PptConfig: Utilizzato per file PowerPoint.
  • ProjectConfig: Utilizzato per file MPP.
  • PsdConfig: Utilizzato per file PSD.
  • TxtConfig: Utilizzato per file TXT.
  • TiffConfig: Utilizzato per file TIFF.
Example usage
var config = new CadConfig { DefaultRender = false }; // or true

Font personalizzati nei documenti Word

La proprietà FontFolders nella classe WordConfig specifica directory personalizzate dove l'applicazione cercherà i font.

Usage
var config = new WordConfig
{
    FontFolders = new string[] { "C:\\CustomFonts", "D:\\SharedFonts" }
};

Aggiornamento relativo ad AjaxControlToolkit nel pacchetto NuGet

Abbiamo apportato modifiche al nostro pacchetto NuGet per migliorare la compatibilità. AjaxControlToolkit non sarà più incluso. Si consiglia agli utenti di installare manualmente la versione 4.1.50508 di AjaxControlToolkit nei loro progetti.

Aggiornamento importante per Doconut 25.2.0

È fondamentale aggiornare il pacchetto System.Text.Json alla versione 8.0.5 in tutti i tuoi progetti.

Codifica email

La proprietà EmailEncoding nella classe EmailConfig specifica la codifica preferita sia per l'oggetto sia per il corpo dell'email.

Usage
var emailConfig = new EmailConfig {
    EmailEncoding = Encoding.UTF8 // Set preferred email encoding
};

Codifica dell'oggetto & del corpo

Le proprietà SubjectEncoding e BodyEncoding nella classe EmailConfig definiscono rispettivamente la codifica usata per l'oggetto e il corpo di un'email.

Usage
var emailConfig = new EmailConfig {
    SubjectEncoding = Encoding.UTF8, // Set encoding for the subject
    BodyEncoding = Encoding.UTF8     // Set encoding for the body
};

Supporto della cultura del visualizzatore Word

La proprietà DocumentCulture nella classe WordConfig consente di definire esplicitamente la cultura per i file DOC e DOCX. Ciò garantisce che i contenuti localizzati — come date, valute e numeri — vengano visualizzati esattamente come avviene in Microsoft Word. È particolarmente utile per le lingue con requisiti di formattazione specifici.

Usage
var config = new WordConfig { DocumentCulture = "he-IL" }; // Hebrew (Israel)
var config = new WordConfig { DocumentCulture = "ar-SA" }; // Arabic (Saudi Arabia)
var config = new WordConfig { DocumentCulture = "th-TH" }; // Thai (Thailand)
var config = new WordConfig { DocumentCulture = "ja-JP" }; // Japanese (Japan)