Failed Conversion from PDF to PDF/A

@ILikeCranberries
For the project on .Net Core 3.1 via linux container, the conversion went without errors.
What version are you using?

We are using .Net 6

@ILikeCranberries

Thank you for the clarification.

For a .Net 6 project in a new empty Linux container, the error was reproduced.
I added 2 font files to the container and a line in the project indicating their presence - the exception was no longer thrown.
forFontsInLinux.png (5.3 KB)

@sergei.shibanov Hi okay thank you, I will try that out.
In the meantime i noticed i forgot to attach that we actually received the following exception during the conversion:

System.NullReferenceException: Object reference not set to an instance of an object.
   at #=zEOjWsUrBUL8Pcj_V6fVdf0tYyyOFHN5IuNJuJpLK$1LP_CjCFiogs_U=.#=zK1YpxYG62wtlOGyHpA==(#=zZk39x5RElUaoOVKSE_kII5BgCQOqmpAvfyIFAec5nTlP #=z9KTUyJ4HqqwQ, #=zsEvhBYvv6m7RKPi4dKXlqrk= #=zV4ENanOcvXoZ)
   at #=zH7fooEKnY6zLJ4MnVJyKf1FQWI1bigpVII37_sqJlNo85zvObm7qrgs=.#=zNcm$slQ_YPgL(#=zsEvhBYvv6m7RKPi4dKXlqrk= #=z6eNsxxg=, #=zhKkWmN1qtQx$vslPB9K3dozSvvVkWdlpg_G$KoUzyEcAth165Q== #=zDZlq7k8=)
   at #=zH7fooEKnY6zLJ4MnVJyKf1FQWI1bigpVII37_sqJlNo85zvObm7qrgs=.#=zUsqodKm6gf$not5kwA==(#=zxRA8_c_KPEAHOYMbkKxHmIv2X5olN7ZnSRN_UMuqjarp #=z6eNsxxg=, String #=zXvPMbsE=, #=zhKkWmN1qtQx$vslPB9K3dozSvvVkWdlpg_G$KoUzyEcAth165Q== #=zXvkG8WM=)
   at #=zH7fooEKnY6zLJ4MnVJyKf1FQWI1bigpVII37_sqJlNo85zvObm7qrgs=.#=z$Ezw_RghawT2(#=zxRA8_c_KPEAHOYMbkKxHmIv2X5olN7ZnSRN_UMuqjarp #=z6eNsxxg=, String #=zduxLmFg=, String #=zXvPMbsE=, #=zhKkWmN1qtQx$vslPB9K3dozSvvVkWdlpg_G$KoUzyEcAth165Q== #=zXvkG8WM=)
   at #=zH7fooEKnY6zLJ4MnVJyKf1FQWI1bigpVII37_sqJlNo85zvObm7qrgs=.#=zyWrOvVk7WnI4(#=zUG$YB4E5etq4hfKqbcLU4zdHSQ27OMF0CtYg4olmcR9V_U0DUA== #=zkYzAI2M=, #=zNocssjZtn5SQyuMKh3jiwzL51G35Bp6gD9MhMlPDq_rfu7rc3Q== #=zKYVNWquIYgyk, #=zZk39x5RElUaoOVKSE_kII5BgCQOqmpAvfyIFAec5nTlP #=z6eNsxxg=, Int32 #=zs1$g2Qk3j90u, #=zhKkWmN1qtQx$vslPB9K3dozSvvVkWdlpg_G$KoUzyEcAth165Q== #=zXvkG8WM=)
   at #=zH7fooEKnY6zLJ4MnVJyKf1FQWI1bigpVII37_sqJlNo85zvObm7qrgs=.#=zJC_WLvcHg9m8(#=zUG$YB4E5etq4hfKqbcLU4zdHSQ27OMF0CtYg4olmcR9V_U0DUA== #=zkYzAI2M=, #=zNocssjZtn5SQyuMKh3jiwzL51G35Bp6gD9MhMlPDq_rfu7rc3Q== #=zKYVNWquIYgyk)
   at #=zH7fooEKnY6zLJ4MnVJyKf1FQWI1bigpVII37_sqJlNo85zvObm7qrgs=.#=zhZ5wbcs=()
   at #=zH7fooEKnY6zLJ4MnVJyKf1FQWI1bigpVII37_sqJlNo85zvObm7qrgs=.#=zwNSm6Aw=()
   at #=zZqsNo3GMBPPdWMeqAkqvFPFZhDn87f8VZt5Qq2oCIcJGVA6DtrAkUu8=.#=zD04sohU=()
   at #=zH7fooEKnY6zLJ4MnVJyKf1FQWI1bigpVII37_sqJlNo85zvObm7qrgs=.#=zOwHks24=(XmlTextWriter #=zmswCD_A=, PdfFormat #=zUWJSRPQ=, Document #=zyal4fvY=, Boolean #=zMgXPSA090REv, ConvertErrorAction #=zYc3OMXs=)
   at Aspose.Pdf.Document.Convert(Stream outputLogStream, PdfFormat format, ConvertErrorAction action)

Is this also related to the font issue?

@ILikeCranberries
Unfortunately, at the moment I do not have the opportunity to decrypt the attached stack trace. But I again maked the .Net6 project with Docker, and even if I just add the Fonts folder with font files, the conversion works, if I remove it, an exception occurs.
And by the way, I’ll create a task for the development team so that a FontNotFoundException is thrown, not a NullReference one.

1 Like

@ILikeCranberries
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): PDFNET-57695

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.

1 Like

We do actually add some fonts via docker image already. Is this not sufficient?

COPY Source/Fonts/arial.ttf /usr/share/fonts/Arial.ttf

COPY Source/Fonts/arialbd.ttf /usr/share/fonts/Arial_Bold.ttf

COPY Source/Fonts/ariali.ttf /usr/share/fonts/Arial_Italic.ttf 

@ILikeCranberries
I will offer you a simpler and more reliable method.
forFontsInLinux.png (5.3 KB)

@ILikeCranberries
I get clarification from the development team.

We don’t throw FontNotFoundException when converting. If there is no font, we simply write an error to the log with the Convertable=“False” attribute, and the conversion fails.
This is an error that occurs when there are no fonts. We plan to fix this in the 24.08 release

May I ask what exactly will be fixed?
The behavior when it fails or that it fails in the first place?

With this approach i assume we can still point to the folder where we copy the fonts right? So as per my example new FolderFontSource(“usr/share/fonts”), right?

@ILikeCranberries
The error is that when there are no fonts in the system during conversion, an exception occurs. And it should “write an error to the log with the Convertable=“False” attribute, and the conversion fails”. This is exactly what will be fixed in 24.08: behavior when there are no fonts in the system.

But for conversion you still need fonts and you can use the option you mentioned for this.

1 Like

Okay thank you, will try that out and I will let you know if it works!

@sergei.shibanov So I tried a few approaches and it only worked once both Arial and Times fonts were included in the fonts folder. However we also have font subsitution defined from timesnewroman to arial, but it still failed when times font was not in font source. Is this expected?

@ILikeCranberries
To use font substitution you should use the line like

// Replace the inaccessible MinionPro-Regular with the user chosen font
FontRepository.Substitutions.Add(new SimpleFontSubstitution("MinionPro-Regular", "Arial"));

Yes we already have added this. This is my point that it doesnt seem to work.

@ILikeCranberries
Please check that the font you are using for substitution is available in the environment using the code

var fonts = new InstalledFontCollection();
Console.WriteLine("installed fonts:");
foreach (FontFamily family in fonts.Families)
{
Console.WriteLine(family.Name);
}

I mean yes we added Arial via your font source suggestion (which is then also the font for substitution) and then it still failed.

@ILikeCranberries
Please provide the full code snippet (with font substitution), dockerfile and font files used in the docker image so that we can reproduce the problem. Is the document you are converting the same as the one attached earlier?

So in the end we were able to make it work by simply installing times new roman fonts also in the docker image. Font source definition was actually not needed. We also opted for this route as times is apparently the default fallback font chosen by Aspose in case a font is not available. As such this was the safest way. Font substitutions did not work because we would need to specify each font variant of times new roman (or any font family) in order to make it work. So installing the font family itself seems easier and more reliable.