Incorrect text display during PDF/A conversion

The attached PDF document has text issures after converting to PDF/A
grafik.png (18.7 KB)

The problem happens with the Aspose PDF Java Library and with the online website: Convert PDF to PDF/A-1A | Online and Free

PDF Document: FAH_AUSWERTFBNEU1-1.pdf (207.4 KB)

@depi
Thank you for contacting support.
Can you attach an example of your code so that we can reproduce the problem?

There is one warning by the convert method:

<Fonts><Problem Severity="Error" Clause="6.3.7" ObjectID="8" Page="1" Convertable="True">Non-symbolic TrueType font 'Arial' contains Encoding entry with Differences array which is prohibited for these kinds of fonts</Problem><Problem Severity="Error" Clause="6.3.7" ObjectID="16" Page="1" Convertable="True">Non-symbolic TrueType font 'Arial' contains Encoding entry with Differences array which is prohibited for these kinds of fonts</Problem></Fonts>

Here is the Java Code:

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.HashSet;
import java.util.Set;

import org.junit.jupiter.api.Test;

import com.aspose.pdf.ConvertErrorAction;
import com.aspose.pdf.Document;
import com.aspose.pdf.Font;
import com.aspose.pdf.FontCollection;
import com.aspose.pdf.FontSubsetStrategy;
import com.aspose.pdf.License;
import com.aspose.pdf.Page;
import com.aspose.pdf.PdfFormat;
import com.aspose.pdf.XForm;
import com.aspose.pdf.XFormCollection;

public class TestCaseAsposePDF {

	@Test
	void testPDFA() throws Exception {

		try ( InputStream is = AsposePlugin.class.getResourceAsStream( "Aspose.Total.Java.lic" )) {
			new License().setLicense( is );
		}

		File source = new File( "FAH_AUSWERTFBNEU1-1.pdf" );
		File target = new File( "FAH_AUSWERTFBNEU1-PDFA.pdf" );

		try ( InputStream is = new FileInputStream( source );
						Document doc = new Document( is )) {

			embedFonts( doc, false );
			
			convert2Pdfa( doc, PdfFormat.PDF_A_2B );
			
			doc.optimizeResources();
			doc.save( target.getAbsolutePath() );

		}
	}

	static void convert2Pdfa ( Document doc, PdfFormat format ) {
		
		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		boolean ok = doc.convert( baos, format, ConvertErrorAction.Delete );

		if ( !ok ) {
			
			String error = baos.toString( StandardCharsets.UTF_8 );
			throw new RuntimeException( error );
		
		} else if ( baos.size() > 0 ) {

			String warn = baos.toString( StandardCharsets.UTF_8 );
			AsposePlugin.log.warn( "PDF/A convert warnings: {}", warn );
		}
	}

	static void embedFonts ( Document doc, boolean subset ) {
		
		Set < String > embedFonts = new HashSet<>();
		
		for ( Page page : doc.getPages() ) {
			FontCollection fonts = page.getResources().getFonts();
			if ( fonts != null ) {
				for ( Font font : fonts ) {
					if ( !font.isEmbedded() ) {
						font.setEmbedded( true );
						embedFonts.add( font.getFontName() );
					}
				}
			}
			XFormCollection forms = page.getResources().getForms();
			for ( XForm form : forms ) {
				FontCollection fonts2 = form.getResources().getFonts();
				if ( fonts2 != null ) {
					for ( Font font : fonts2 ) {
						if ( !font.isEmbedded() ) {
							font.setEmbedded( true );
							embedFonts.add( font.getFontName() );
						}
					}
				}
			}
		}
		// use only subset of fonts
		if ( subset ) {
			doc.getFontUtilities().subsetFonts( FontSubsetStrategy.SubsetEmbeddedFontsOnly );
		}
	}
}

@depi
Thanks! We are checking it and will get back to you shortly.

Are there any new insights? What is the status?

@depi
We have a reshuffle - I’ll look at your question tomorrow. I apologize for the delay.

@depi
I reproduced - I have an exception thrown when calling doc.optimizeResources();
If this line is removed, the document is generated without errors.
Please check - you also?

Sorry, I couldn’t continue the case due to vacation.
The example works without an exception. If I remove the optimizeResource(), the result is the same. The text is illegible. Do you have a T3 font installed?

@depi

With T3 font installed and below code snippet, we obtained attached output and text look fine in it. Have you tried the latest version of the API?

Document doc = new Document(dataDir + "FAH_AUSWERTFBNEU1-1.pdf");
PdfFormatConversionOptions opts = new PdfFormatConversionOptions(dataDir + "logFile1.Txt", PdfFormat.PDF_A_1A, ConvertErrorAction.Delete);
doc.convert(opts);
doc.save(dataDir + "output.pdf");

output.pdf (1.8 MB)