Failed Conversion from PDF to PDF/A

Hi Aspose Team,
We are unable to convert this file.pdf into PDF/A. Portion of the error log can be found in
Conversion_error_log.docx (13.4 KB)

It works correctly if we exclude first and last pages of the file. And we encountered this issue with the latest Aspose version(24.6.0).

Please take a look at the issue.

@ILikeCranberries
Please specify which version of PDF/A you are converting to?

@sergei.shibanov We are converting to PDF_A_1B.

@ILikeCranberries
When the license is connected, the code

var doc = new Document(dataDir + "12345.pdf");
doc.Convert(new MemoryStream(), PdfFormat.PDF_A_1B, ConvertErrorAction.Delete);
doc.Save(dataDir + "12345-out.pdf");

generated a valid PDF/A document.
Without a license, an exception is thrown: System.IndexOutOfRangeException: “At most 4 elements (for any collection) can be viewed in evaluation mode.” - which is due to the limitations of the trial version.

I mean we have a valid license so that is not the issue.
The exact library we are using is Aspose.PDF.Drawing 24.6.0. Maybe that makes the difference?
Otherwise our code is the same as yours.

I just noticed that when hosted in windows it works but when hosted via linux containers it breaks.

Can you retry with that version on linux env?

@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"));