Merge PDF/UA

Buongiorno,

ho la necessità di effettuare la merge tra più documenti in formato PDF/UA compliant ma, una volta effettuata la merge, il documento PDF prodotto non risulta essere più PDF/UA compliant.

Grazie

Matteo

@matteos

Puoi fornire maggiori dettagli su come stai eseguendo la fusione dei documenti PDF/UA e quali strumenti o codice stai utilizzando?

Il codice di test su cui sto effettuando i test è il seguente:

    //test 1
    try (Document pdfDocument1 = new Document(basePath + fileName1 + ".pdf")) {
		// Open second document
		Document pdfDocument2 = new Document(basePath + fileName2 + ".pdf");

		pdfDocument1.merge(pdfDocument2);

		// Save concatenated output file
		pdfDocument1.save(destionationBasePath + "ConcatenatePdfFiles_out.pdf");
	}

I pdf relativi a fileName1 e fileName2 sono entrambi PDF/UA compliant, una volta mergiati il documento presenta i seguenti errori (rilevati tramite checker PAC2024):

  • logical structure → structure elements → annotations → nesting of “link” annotations inside “Link” structure elements

  • content → tagged content and artifacts → text object not tagged/path object not tagged

@matteos

Potresti provare a usare il frammento di codice seguente con l’ultima versione dell’API e farci sapere se risolve il problema:

Facades.PdfFileEditor editor = new Facades.PdfFileEditor();
editor.CopyLogicalStructure = true;
editor.CopyOutlines = true;
using (FileStream destination = new FileStream(dataDir + "merged.pdf", FileMode.Create))
{
editor.Concatenate(pdfFiles, destination);
}

Se il problema persiste, condividi i file di origine e di output di esempio per nostro riferimento, in modo che possiamo testare lo scenario nel nostro ambiente e risolverlo di conseguenza.

Ciao,

ho provato la soluzione suggerita ma non ho ottenuto il risultato desiderato (cartella Test with localstructure); ho effettuato un altro test utilizzando il seguente codice:

		com.aspose.pdf.facades.Form pdfForm = new com.aspose.pdf.facades.Form();
		pdfForm.bindPdf(basePath+fileName1+".pdf");
		pdfForm.flattenAllFields();
		pdfForm.save(destionationBasePath + "MergedPdf_flattened_1.pdf");
		
		pdfForm.bindPdf(basePath+fileName2+".pdf");
		pdfForm.flattenAllFields();
		pdfForm.save(destionationBasePath + "MergedPdf_flattened_2.pdf");
		
		Document input1 = new Document(destionationBasePath+"MergedPdf_flattened_1.pdf");
		Document input2 = new Document(destionationBasePath+"MergedPdf_flattened_2.pdf");
		
		input1.getPages().add(input2.getPages());

		OutputStream outstream = new FileOutputStream(destionationBasePath+"MergedPdfTotal.pdf");
		
		input2.close();
		input1.save(destionationBasePath + "MergedPdfTotal.pdf");
		input1.close();
		pdfForm.close();
		
		outstream.close();

ed ho ottenuto risultati differenti in base all’ordine di sottomissione dei pdf:

  • in un caso (folder Test 1 OK) un risultato positivo;

  • invertendo l’ordine dei pdf da mergiare (folder Test 2 KO) ho ottenuto un risultato negativo.

In allegato i pdf originali utilizzati per i test ed i relativi risultati.

Grazie mille

Matteo
Test_PDF_UA.7z (151,4 KB)

@matteos

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): PDFJAVA-44880

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.