Aspose.PDF Running .NET 6 project in Docker throws Globalization.CultureNotFoundException after deployment on linux

HI @sergei.shibanov
I am using below code snippet for ppt , It is working fine for me on local, attached snapshot for same.
If still you are not able to run the code , Can we have screen sharing session from your side on sukhvinder_singh@edwards.com, you can send me meeting invite for the same
docppt.PNG (71.4 KB)

 public async void RenderPptxTemplateAsync(string template)
       {
           try
           {
               //string template as html string read from template 
               var stream = new MemoryStream(Encoding.UTF8.GetBytes(template));
               HtmlLoadOptions options = new HtmlLoadOptions();
               // Set render to single page property
               Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(stream, options);
               // Create page number stamp
               PageNumberStamp pageNumberStamp = new PageNumberStamp();
               // Whether the stamp is background
               pageNumberStamp.Background = false;
               pageNumberStamp.Format = "Page # of " + pdfDocument.Pages.Count;
               pageNumberStamp.BottomMargin = 36;
               pageNumberStamp.HorizontalAlignment = HorizontalAlignment.Center;
               pageNumberStamp.StartingNumber = 1;
               // Set text properties
               pageNumberStamp.TextState.Font = FontRepository.FindFont("Arial");
               pageNumberStamp.TextState.FontSize = 14.0F;
               pageNumberStamp.TextState.FontStyle = FontStyles.Bold;
               pageNumberStamp.TextState.FontStyle = FontStyles.Regular;
               pageNumberStamp.TextState.ForegroundColor = Color.Gray;
               // Add stamp to particular page
               for (int i = 1; i < pdfDocument.Pages.Count; i++)
               {
                   if (pdfDocument.Pages.Count != i && i != 1)
                   {
                        if (pdfDocument.Pages.Count - 1 != i)
                       {
                           pdfDocument.Pages[i].AddStamp(pageNumberStamp);
                       }
                   }
               }
               pdfDocument.Save("output.pptx", Aspose.Pdf.SaveFormat.Pptx);
             

           }
           catch (Exception ex)
           {
           
           }

@Sukhvinder
Thank you for clarifying. I finally understanding that when creating a document, a stream (not a string) is given into which the contents of the file being opened are loaded.
I created a Web Api application (“from the box”) and added the above method there and modified the dockerfile created by the visial studio to match the one you attached. Except for the paths, but I think it doesn’t matter.
However, I haven’t been able to reproduce the exception yet.
Tomorrow I will continue to work on this and write to you.
Although I think it works here that I run the docker from the Visual Studio. It is possible that when you start, there are some peculiarities of your own, there is a locally necessary culture, but not in Azure.

@sergei.shibanov It is working in debug mode our side also, However when we are deploying on aks docker container same method not working and throwing below error on this line Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(stream, options);
objecterror.png (105.2 KB)

@Sukhvinder
Please attach stacktrace as a text.objecterror.png (105.9 KB)

@sergei.shibanov

PFA stack trace for the same
RenderPptxTemplateAsync Document exception: System.Exception: The type initializer for ‘#=znt5o9XIt7lRZOwQjcxv8X8g63Bw6kmo5wQ==’ threw an exception.
—> System.TypeInitializationException: The type initializer for ‘#=znt5o9XIt7lRZOwQjcxv8X8g63Bw6kmo5wQ==’ threw an exception.
—> System.TypeInitializationException: The type initializer for ‘#=ziNiGDyXjY3Ypa8OJZN3njZh2gscL’ threw an exception.
—> System.Globalization.CultureNotFoundException: Only the invariant culture is supported in globalization-invariant mode. See Globalization config settings - .NET | Microsoft Learn for more information. (Parameter ‘name’)
en-US is an invalid culture identifier.
at System.Globalization.CultureInfo…ctor(String name, Boolean useUserOverride)
at System.Globalization.CultureInfo…ctor(String name)
at #=ziNiGDyXjY3Ypa8OJZN3njZh2gscL…cctor()
— End of inner exception stack trace —
at #=znt5o9XIt7lRZOwQjcxv8X8g63Bw6kmo5wQ==…cctor()
— End of inner exception stack trace —
at #=znt5o9XIt7lRZOwQjcxv8X8g63Bw6kmo5wQ==.#=zcu5TFvlFnUGW()
at #=znt5o9XIt7lRZOwQjcxv8X8g63Bw6kmo5wQ==…ctor(#=z410ewA8_XxxVObJqO3aKTBo= #=za9q6HOo=, #=zt1nanRAOsonsVmLSKEweg5P1viWf #=zAtqEnjk=)
at #=zdyeNcYBl8SVKJ87CMy2q_bmBs_D2uuGvSA==.#=z2kwRJ7g=(#=z410ewA8_XxxVObJqO3aKTBo= #=za9q6HOo=, #=zt1nanRAOsonsVmLSKEweg5P1viWf #=zAtqEnjk=)
at #=z410ewA8_XxxVObJqO3aKTBo=.#=z2KV_7jnasYtE.#=zIs_TOoJDdiClI0aV0g==.#=z_ZpAFx_A4o2M01rXUw==()
at #=zwqbe$hjfo6kl$$LhEyUntfU=.#=zYVV0NyY=()
— End of inner exception stack trace —
at #=ziL4NRqm57bNDxY2Ik0G30sGsQYg9.#=znoi8KMY=(Boolean #=z2rwptz0=)
at #=zsXwYCo8lDR2aqKE9o0AQk1Qkx30X.Dispose()
at #=z410ewA8_XxxVObJqO3aKTBo=.#=z5xXPuSo=(#=z7fCVjwkgXVMe #=zVEq2fe4=)
at #=zkcipR3IcqEHu9YdpF$tYrzc=…ctor(#=zVwQTuKAkxWwhnsTwPhplk3xWALUl #=zOIOW9F4=, #=zF_DuspoAZ32$A4tzTz5DA3c= #=zAtqEnjk=, Byte #=zVARJd34=)
at #=zkcipR3IcqEHu9YdpF$tYrzc=…ctor(Stream #=znp8FP8I=, String #=zQXffoAI=, #=zF_DuspoAZ32$A4tzTz5DA3c= #=zAtqEnjk=)
at #=zu1jMUMh7CEeJYwLfOeDaNzqODzCE.#=z_vBY2rX8kAGM(Stream #=zkCd_wMCrVgXE, Document #=zTCsZqG65l6Qv, HtmlLoadOptions #=zeyK3uNu2RdwB, String #=zbL0C9cAY1Tof)
at #=zu1jMUMh7CEeJYwLfOeDaNzqODzCE.#=zs2R79CU=(Stream #=zkCd_wMCrVgXE, Document #=zTCsZqG65l6Qv, HtmlLoadOptions #=zeyK3uNu2RdwB, String #=zbL0C9cAY1Tof)
at #=zu1jMUMh7CEeJYwLfOeDaNzqODzCE.#=zs2R79CU=(Stream #=zkCd_wMCrVgXE, Document #=zTCsZqG65l6Qv, HtmlLoadOptions #=zeyK3uNu2RdwB)
at Aspose.Pdf.Document.#=zsTaJcuo=(Stream #=zOL$RYgQ=, LoadOptions #=zLAt2_$U=)
at Aspose.Pdf.Document…ctor(Stream input, LoadOptions options)
at CI.DataAggregation.Services.PdfExport.PdfTemplateLoader.RenderPptxTemplateAsync(String template) in /src/services/CI.DataAggregation/Services/PdfExport/PdfTemplateLoader.cs:line 132

@Sukhvinder
I don’t have access to Azure, I only added Docker Compose and I couldn’t reproduce the exception. But thanks to the presented stack trace, the possible reason understanding and I can set the task for the development team.
From what I’ve learned (first of all Globalization config settings - .NET | Microsoft Learn) I think you should set the following variables:
InvariantGlobalization to false (not sure here, you can try with true)
PredefinedCulturesOnly to false
and add setting variables primarily to the project file

   <PropertyGroup>
     <InvariantGlobalization>false</InvariantGlobalization>
     <PredefinedCulturesOnly>false</PredefinedCulturesOnly>
   </PropertyGroup>

(and at first it’s better to docker file too).

@Sukhvinder
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): HTMLNET-4438

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@sergei.shibanov After making suggested changes above getting below error - Stack traces
RenderPptxTemplateAsync Document exception: System.PlatformNotSupportedException: System.Drawing.Common is not supported on this platform.
at System.Drawing.Drawing2D.Matrix…ctor(Single m11, Single m12, Single m21, Single m22, Single dx, Single dy)
at #=z5r4vZ7kcB$xtlbZmR5oe5OLYfnzrubYIOA==.#=zYiJfTC4UD3i0uLEoP0efjy8=(SizeF #=zYPfCAnU=)
at #=z5r4vZ7kcB$xtlbZmR5oe5OLYfnzrubYIOA==.#=zEjIcVgQ=(SizeF #=zYPfCAnU=)
at #=zkkCiwiWtU7H2KphWx_VA29Ik2FZq_c3ScA==.Render(#=zAekiust3wvApDkMClJJOYvF8qKGS #=zayd1ksI=, CancellationToken #=z$Cj3hNs=)
at #=zZNs7jACDMPUriDpkiU0MA9Hn4NT_M$APxQ==.#=zKS$fonEz0I7_(#=zap_Ujgf3yJ1bo7KjPqC_Xd8= #=zuRs8sXEHxAzpoGSFYg==, #=zkGGXSQvtJ9KQJ0jnLD8DKWzMCJMR[] #=zp8uwJ4TtkQY8, #=zAekiust3wvApDkMClJJOYvF8qKGS #=zayd1ksI=, CancellationToken #=z2u3N_Vg=)
at #=zlKIjKOpqmX_BvdiX8bMmeDiQV6CE.Render(#=zAekiust3wvApDkMClJJOYvF8qKGS #=zayd1ksI=, CancellationToken #=z2u3N_Vg=, #=z2Xb90SDflNKcgCkElFJaigI=[] #=zsqHrZhg=, #=z410ewA8_XxxVObJqO3aKTBo=[] #=zdpUahS8=)
at #=zlKIjKOpqmX_BvdiX8bMmeDiQV6CE.Render(#=zAekiust3wvApDkMClJJOYvF8qKGS #=zayd1ksI=, TimeSpan #=zBX_kAxo=, #=z410ewA8_XxxVObJqO3aKTBo=[] #=zdpUahS8=)
at #=zwD0lwO3vq8jisH7_mnj9ywslxeIG.Render(#=zAekiust3wvApDkMClJJOYvF8qKGS #=zayd1ksI=, #=z$8t$NHA= #=za9q6HOo=, TimeSpan #=zBX_kAxo=)
at #=zu1jMUMh7CEeJYwLfOeDaNzqODzCE.#=z_vBY2rX8kAGM(Stream #=zkCd_wMCrVgXE, Document #=zTCsZqG65l6Qv, HtmlLoadOptions #=zeyK3uNu2RdwB, String #=zbL0C9cAY1Tof)
at #=zu1jMUMh7CEeJYwLfOeDaNzqODzCE.#=zs2R79CU=(Stream #=zkCd_wMCrVgXE, Document #=zTCsZqG65l6Qv, HtmlLoadOptions #=zeyK3uNu2RdwB, String #=zbL0C9cAY1Tof)
at #=zu1jMUMh7CEeJYwLfOeDaNzqODzCE.#=zs2R79CU=(Stream #=zkCd_wMCrVgXE, Document #=zTCsZqG65l6Qv, HtmlLoadOptions #=zeyK3uNu2RdwB)
at Aspose.Pdf.Document.#=zsTaJcuo=(Stream #=zOL$RYgQ=, LoadOptions #=zLAt2_$U=)
at Aspose.Pdf.Document…ctor(Stream input, LoadOptions options)
at CI.DataAggregation.Services.PdfExport.PdfTemplateLoader.RenderPptxTemplateAsync(String template) in /src/services/CI.DataAggregation/Services/PdfExport/PdfTemplateLoader.cs:line 132

@Sukhvinder
What version of the library are you using?
If Aspose.Pdf, then try Aspose.Pdf.Drawing instead.

@sergei.shibanov Currently we are using Aspose.PDF 23 as per attached sectionasposeversion.PNG (30.9 KB)

Can you please let us know which version we can use as We need to purchase license ,Which product we can buy license Aspose.PDF or Aspose.PDF.Drawing ?Please confirm.

@Sukhvinder
Both libraries work with the same license. When buying, it is better to clarify (specify) it. But technically now so. Aspose.Pdf.Drawing is better for working in Linux systems.

@sergei.shibanov Thanks you, As per your suggestion now culture not found error resolved but now it is failing when we are saving the document and throwing below error
Throwing error on this line - pdfDocument.Save(streamsd, Aspose.Pdf.SaveFormat.Pptx);

Do you have any idea how can we save ppt and return as byte when i am skipping above line then it is returning empty.
Stack Trace

RenderPptxTemplateAsync Document exception: System.IO.IOException: Read-only file system : ‘/tmp/TempFonts’
at System.IO.FileSystem.CreateDirectory(String fullPath)
at #=z74Fq7n$Gl64wbpnfW9MesDaMR9voN28ahQ==.#=zauMb4Wt5DjmD()
at #=z74Fq7n$Gl64wbpnfW9MesDaMR9voN28ahQ==…ctor()
at #=zxcMJNWhEaXXFJp7zsNrx15gu0CFU.#=zfy1V6mc=(String #=zO$fm2lM=, #=zmYkWHgSPEk2G2YygMTYBqkFypBYV #=zg$b4LR4=)
at #=zbS5D3o0o95iypdB$Sd_RNv73aPM2cad4gw==.#=zL0G6SvejW79X(#=zmYkWHgSPEk2G2YygMTYBqkFypBYV #=zg$b4LR4=)
at #=zbS5D3o0o95iypdB$Sd_RNv73aPM2cad4gw==.#=zT$GNo1WPuBg1y7CvSg==(#=zmYkWHgSPEk2G2YygMTYBqkFypBYV #=zg$b4LR4=)
at #=zRGUKcHGury$zDrZudw0JoCKJGSc3dqDGtdpTNV4=.#=ziAVWnZJq9dJyFfNtdJioreLNbINK(#=za0VtmMCe35HuTO$qKIMglsst$1PyshXlQg== #=zbT5$1akeHUx1, #=za0VtmMCe35HuTO$qKIMglsst$1PyshXlQg== #=zi_oVOYlNRmHg)
at #=zRGUKcHGury$zDrZudw0JoCKJGSc3dqDGtdpTNV4=.#=z9X8Ojh6OWax1(#=zrgCSNDnanlcpyvy2fYquewv3apzU #=zvd0uFOc=, Boolean #=zIjiqPnLA16SOSueI0Q==, Boolean #=z8Fuf$yo=)
at #=zRGUKcHGury$zDrZudw0JoCKJGSc3dqDGtdpTNV4=.#=zU2xcXhc=(#=zrgCSNDnanlcpyvy2fYquewv3apzU #=zvd0uFOc=, Boolean #=zIjiqPnLA16SOSueI0Q==)
at #=ztfC1n7uu8ojclO2l0Z9dwIb2vP9AbxA6lw==…ctor(#=zscRVqV1NAej$IF4yFwAStwmnTjrb #=zcqg9ZFM=, #=zK$fBLfaTUno2VAB6Enl7Ck24XJHmXpY$OpZxCSY= #=z9BlIXgs=, List1 #=zXpTsEDg=, List1 #=z04dzXjo=, Boolean #=zUz6EL88j_6yAXKVvWK2m60$uEUB4o27EXg==, Boolean #=ziKukhXusCfdCVN2EWw==)
at #=zKp42sDdBCeeEYwrDGY1KZ_wsvR$8s7NKxw==.#=zzqBFrS_KCTkUf2$fAA==(#=zw1PiL7Ahw0xEELEsb_2JzaU= #=z3McrTS8=, Single #=zK5IEPKvdSpRZ, Single #=zVGlfhIKQ2Dom, #=zK$fBLfaTUno2VAB6Enl7Ck24XJHmXpY$OpZxCSY= #=z9BlIXgs=, Boolean #=zUz6EL88j_6yAXKVvWK2m60$uEUB4o27EXg==, Boolean #=ziKukhXusCfdCVN2EWw==, #=zKp42sDdBCeeEYwrDGY1KZ_wsvR$8s7NKxw== #=ze6VFiEc=)
at #=zKp42sDdBCeeEYwrDGY1KZ_wsvR$8s7NKxw==.#=zzqBFrS_KCTkUf2$fAA==(#=zw1PiL7Ahw0xEELEsb_2JzaU= #=z3McrTS8=, Single #=zK5IEPKvdSpRZ, Single #=zVGlfhIKQ2Dom, #=zKp42sDdBCeeEYwrDGY1KZ_wsvR$8s7NKxw== #=ze6VFiEc=)
at #=zKp42sDdBCeeEYwrDGY1KZ_wsvR$8s7NKxw==.#=z_M185yN6winK6Wa1Bx$Pjss=(#=zw1PiL7Ahw0xEELEsb_2JzaU= #=z3McrTS8=, SizeF #=zEW0qqSo=)
at #=z4c2bNQ96jlP0zE9dMfUiwnUn4fMi$q5N0mYitbY=.#=zINuimrg=(IList1 #=zd04maSBOsEoG, #=zisxCjYoVfthZiHZKKmyWE9KSU2J3jzrsiA== #=zqCRAJ2c=, #=zt$$TpbTPIW2LOxlYHFfW$VkLPL7U7RDjwnA$mcs= #=zC8H9DY8=) at #=zM6R78iELVOUwC6I6Z605bGSV4f6w.#=z0v4AuMbh2MPwA3X_Ag==(List1 #=zbV1UD50=)
at #=zgWwdw$lh_npc4NQkVOD7C6l_wciiE1FMBA==.#=z2chjyOQrOBHt(List`1 #=zd04maSBOsEoG, Stream #=zhGZCK3QA$7Vf, PptxSaveOptions #=zC8H9DY8=)
at #=zgWwdw$lh_npc4NQkVOD7C6l_wciiE1FMBA==.#=zINuimrg=(Document #=zHVmFA6o=, Stream #=zhGZCK3QA$7Vf, PptxSaveOptions #=zC8H9DY8=)
at Aspose.Pdf.Document.#=zEoWK9eIwWhSp(Stream #=z8WYr_7pbgzEv, SaveOptions #=zC8H9DY8=)
at Aspose.Pdf.Document.#=zEoWK9eIwWhSp(Stream #=z8WYr_7pbgzEv, SaveFormat #=zjMZpFjo=)
at Aspose.Pdf.Document.Save(Stream outputStream, SaveFormat format)
at CI.DataAggregation.Services.PdfExport.PdfTemplateLoader.RenderPptxTemplateAsync(String template) in /src/services/CI.DataAggregation/Services/PdfExport/PdfTemplateLoader.cs:line 159

@Sukhvinder
As I understand from Stack Trace, you need the ability to access ‘/tmp/TempFonts’ (I suppose some temporary files are created there). It is necessary to open the possibility of writing to this folder for the library.

@sergei.shibanov Yes , When trying to save it is accessing /tmp/TempFonts path to save and get document object So How can i resolve this? Do we need to add permission in code?OR Do we need to add lines of code in docker file ?Please suggest!

@Sukhvinder
You, in your environment, need to share the folder and give the appropriate rights to the library. So that the library can write and read there. This already applies to the deployment, not the library, and I can’t advise something more specific.

@sergei.shibanov Thanks you for you support, I am able to export PPT. Here I need help for one of the task - The system shall set the ‘VBASigned’ property to ‘False’ to disable macros in the aspose PPT using aspose pdf library, I did not find code references for disable the macros with aspose PDF drawing packages, Can you please help me to give property to disable macros in code while exporting ppt?

@Sukhvinder
Please clarify:
Are you exporting a pdf document to a ppt document and need to disable macros in the resulting ppt document?
Or
Are you reading a ppt document for converting it to pdf?
And you need to not use micros in readed ppt document while convert it to pdf?

@Sukhvinder
Since this is another question (not the one listed in the thread title) a new thread should be created for it. To make it easier for other users to find the discussions they are interested in.

It seems
<PredefinedCulturesOnly>false</PredefinedCulturesOnly>
is enough

@braalias
Perhaps so, I don’t remember if I have already checked this option.
Thanks for the comment, I’ll keep that in mind.