FontManager in .NET 6 (InsertingHtmlExample or saving as PDF)

0
lukacs.akos posted this 29 August 2022

Hi!

Looks like inserting HTML fragment doesn't work in .NET 6, I get the following exception when I try to insert an HTML fragment:

    System.Exception
  HResult=0x80131500
  Message=Cannot initialize FontManager because no font sources have been set and hence no fonts are available. Use the 'FontManager.SetFontsSources' method to specify font sources.
  Source=Docentric.Documents
  StackTrace:
   at Docentric.Drawing.FontManager.#=zTgWLiDZvlCQj(FontSourceBase[] #=zyvlazPyp5Vcf, Boolean #=zYWifBPr6XMgi)
   at Docentric.Drawing.FontManager.#=z7sJkdCML8u7y()
   at Docentric.Documents.ObjectModel.Document.#=zOaxWb_dkK7QE()
   at Docentric.Documents.ObjectModel.Document.#=z7uBIuHlCnP4B()
   at #=zSk3IvmTEkdQTShSb6fzb$EDgJpmtuy_8IsQMCI7$Il7P.#=z5k_3C47tnJmZfFcX_B8qNsOAsWis(String #=znVk9d2TW9hZg)
   at #=zSk3IvmTEkdQTShSb6fzb$EDgJpmtuy_8IsQMCI7$Il7P.#=zSdYOONAH01BJmasHBA==(XElement #=z2s7Zolv6llWr)
   at #=zSk3IvmTEkdQTShSb6fzb$EDgJpmtuy_8IsQMCI7$Il7P.#=zmpUToG5W7uh5(CharacterFormat #=zMe1sp3DauFZP, XElement #=zFx$E$as=)
   at #=zSk3IvmTEkdQTShSb6fzb$EDgJpmtuy_8IsQMCI7$Il7P.#=zV1Ta3oSIwzf6(XElement #=zFx$E$as=, Boolean #=zE0sN$gOAsqM3)
   at #=zSk3IvmTEkdQTShSb6fzb$EDgJpmtuy_8IsQMCI7$Il7P.#=zzEIJdYA=(XElement #=zoZDdOhM=)
   at #=zSk3IvmTEkdQTShSb6fzb$EDgJpmtuy_8IsQMCI7$Il7P.#=z504oqTQ=(XNode #=zhVa_BXU=)
   at #=zx_lpCTQVgWwjSaKq1eoJuMpONVLRHIAYx8X_ZFQ=.#=zaQnR0B4=(XElement #=zFx$E$as=)
   at #=zSk3IvmTEkdQTShSb6fzb$EDgJpmtuy_8IsQMCI7$Il7P.#=z504oqTQ=(XNode #=zhVa_BXU=)
   at #=zx_lpCTQVgWwjSaKq1eoJuMpONVLRHIAYx8X_ZFQ=.#=zaQnR0B4=(XElement #=zFx$E$as=)
   at #=zSk3IvmTEkdQTShSb6fzb$EDgJpmtuy_8IsQMCI7$Il7P.#=z504oqTQ=(XNode #=zhVa_BXU=)
   at #=zx_lpCTQVgWwjSaKq1eoJuMpONVLRHIAYx8X_ZFQ=.#=zaQnR0B4=(XElement #=zFx$E$as=)
   at #=zSk3IvmTEkdQTShSb6fzb$EDgJpmtuy_8IsQMCI7$Il7P.#=z504oqTQ=(XNode #=zhVa_BXU=)
   at #=zSk3IvmTEkdQTShSb6fzb$EDgJpmtuy_8IsQMCI7$Il7P.#=zcguNbzw=()
   at #=z6bm_hoK7p48R2hlT$ge1u_pkPdaBdwapSo26DS4=.#=zFbYzP1Q=(Stream #=zlxcq41zLzPfh)
   at Docentric.Documents.Reporting.DocumentGenerator.dje_zVLAVBAP3WBT38RA_ejd.#=z5A$mXXTGZZZjbcfBzQ==(SdtElement #=ztLucqU1tJ3mf, SubDocumentElement #=ziNAKgtNktxKK, Paragraph #=zNSwvGlFDM0bW)
   at Docentric.Documents.Reporting.DocumentGenerator.dje_zVLAVBAP3WBT38RA_ejd.#=zrimxtaLwYF5nLA6P4Q==(SdtElement #=ztLucqU1tJ3mf, SubDocumentElement #=ziNAKgtNktxKK, DataContext #=zluzxVf8=, ElementBase #=zl069hIvnsGoe)
   at Docentric.Documents.Reporting.DocumentGenerator.dje_zVLAVBAP3WBT38RA_ejd.#=zmNhL3QWiROwTWlQtXnL5Y1kx5$BT0rty2Q==(SdtElement #=z8lWU38zB6dMW, DataContext #=zluzxVf8=, ElementBase #=zl069hIvnsGoe)
   at Docentric.Documents.Reporting.DocumentGenerator.dje_zVLAVBAP3WBT38RA_ejd.#=zAB_6$syvBn$YbYq7AA==(List`1 #=z25WpCjAK5GYL, DataContext #=zrt9rvG3L6w3LgV5tUQ==, ElementBase #=zcqLxiLhOKlghOYS5Cg==)
   at Docentric.Documents.Reporting.DocumentGenerator.#=z4EK6$bNToGMW(WordprocessingDocument #=z6LVUtBg=, SaveOptions #=zkH6GNuM_hLmH, XmlDocument #=zXbGXD4XZztSH8m3nfYnZuwJeXpb5)
   at Docentric.Documents.Reporting.DocumentGenerator.GenerateDocument(Stream templateStream, Stream outputDocumentStream, SaveOptions saveOptions)
   at Docentric.Examples.Browser.InsertingHtmlExample.GenerateReport() in C:\Users\Public\Documents\Docentric\Toolkit\Example Browser\src\SubDocNet6\Examples\InsertingHtmlExample.cs:line 37
   at Program.<main>$(String[] args) in C:\Users\Public\Documents\Docentric\Toolkit\Example Browser\src\SubDocNet6\Program.cs:line 7

Here is a minimal repro in .NET 6 based on the .NET 4 examples: https://dev.azure.com/nffku/pub/_git/DocentricSubDocNet6

Just dotnet run it.

Last edited 29 August 2022

10 Posts
10 Points
3 Comments
Order By: Standard | Newest | Votes
0
lukacs.akos posted this 29 August 2022

Oh, another issue with the FontManager: When I try to save a document (without sub document, so saving as docx does work) as PDF, I get the same exception :( Just a line like this: var result = dg.GenerateDocument(srcFilePath, PdfOutputFilePath, new Docentric.Documents.ObjectModel.PdfSaveOptions()); instead of var result = dg.GenerateDocument(srcFilePath, OutputDocumentFilePath);

10 Posts
10 Points
0
jles posted this 29 August 2022

Hi Lukacs,

In a .NET Core + project you need to initialize FontManager. You will find the answer in this thread: https://www.docentric.com/forum/chat/cannot-initialize-fontmanager-because-no-font-sources-have-been-set

Regards, Jure

155 Posts
295 Points
0
lukacs.akos posted this 01 September 2022

Ah, thank you. Searching is difficult :D

10 Posts
10 Points

Our 229035 members have posted 345 times in 102 discussions