Create a PDF/A2-a

@fabio.parise

Sure and yes, we have been working on it and we began this implementation since it was speculated to become a standard. The implementation and improvements to the feature is an on-going process that we tend to continue alongside fixing other reported issues in parallel.

Nevertheless, the ticket has been updated and loaded with all of the concerns your shared with us already. We will consider them for sure and as soon as we have some updates to share, we will inform you in this very thread. Please spare us some time.

We apologize for the inconvenience caused.

@Davide_C

The issue with autogenerated tags can be fixed with the feature added in the last release.

We added option in the class PdfFormatConversionOptions.setAutoTaggingSettings.

Here the code :

Calendar now = Calendar.getInstance();
now.setTimeZone(TimeZone.getTimeZone("UTC"));

Document document = new com.aspose.pdf.Document();

document.getInfo().setTitle("title");
document.getInfo().setAuthor("author");
document.getInfo().setSubject("subject");
document.getInfo().setKeywords("keywords");
document.getInfo().setCreator("creator");
document.getInfo().setCreationDate(now.getTime());
document.getInfo().setModDate(now.getTime());
document.setDisplayDocTitle(true);

document.getTaggedContent().setTitle("Documento PDF Esempio");
document.getTaggedContent().setLanguage("it-IT");

Page page = document.getPages().add();

String text = "TESTO";

TextFragment textFragment = new TextFragment(text);
com.aspose.pdf.Font font = FontRepository.findFont("Arial");
textFragment.setText(text);

page.getParagraphs().add(textFragment);
document.processParagraphs();

PdfFormat format = PdfFormat.PDF_UA_1;
PdfFormatConversionOptions options = new PdfFormatConversionOptions(
                dataDir+"taggedpdf"+version+".xml",format, ConvertErrorAction.Delete);
options.setAutoTaggingSettings(AutoTaggingSettings.getDefault());
document.convert(options);

document.save(dataDir+"outputAsposePDF"+version+"_tagged_PDF_UA_1.pdf");

45040.zip (87.2 KB)

Hi, now with the new version 25.5 the tagging of the simple example above works. Thanks.
On more complex files however, it is not possible to have the tagging, during the convert phase I have an error without a message, this is the stacktrace:

{“declaringClass”:“com.aspose.pdf.internal.l9h.lI”,“methodName”:“lI”,“lineNumber”:-1},
{“declaringClass”:“com.aspose.pdf.internal.l9h.ld”,“methodName”:“\u003cinit\u003e”,“lineNumber”:-1},
{“declaringClass”:“com.aspose.pdf.internal.l9h.lv”,“methodName”:“lj”,“lineNumber”:-1},
{“declaringClass”:“com.aspose.pdf.internal.l9k.l1t”,“methodName”:“le”,“lineNumber”:-1},
{“declaringClass”:“com.aspose.pdf.internal.l9k.l1t”,“methodName”:“lb”,“lineNumber”:-1},
{“declaringClass”:“com.aspose.pdf.internal.l9k.l1t”,“methodName”:“l3n”,“lineNumber”:-1},
{“declaringClass”:“com.aspose.pdf.internal.l9k.l1l”,“methodName”:“l5v”,“lineNumber”:-1},
{“declaringClass”:“com.aspose.pdf.internal.l9k.l1t”,“methodName”:“lI”,“lineNumber”:-1},
{“declaringClass”:“com.aspose.pdf.ADocument”,“methodName”:“lI”,“lineNumber”:-1},
{“declaringClass”:“com.aspose.pdf.ADocument”,“methodName”:“convert”,“lineNumber”:-1},
{“declaringClass”:“com.aspose.pdf.Document”,“methodName”:“convert”,“lineNumber”:-1},

The log file set in the PdfFormatConversionOptions parameter remains empty.
How can I find out where the error occurs?

I have worked with other libraries where it was possible, from code, to insert tags when inserting texts and graphic elements into the PDF, is there a way to do it with Aspose without doing it from covert?

Thank you

@Davide_C

Would you kindly share the sample source file with us along with the code snippet so that we can test in our environment and address it accordingly?

Hi, I can attach the pdf to convert, the data inside it, for privacy, are invented.
The code used is composed of 2500 lines, it converts a jasperprint 1.3 into a pdf.
I repeat as a question, is it possible to insert the tags manually (always from code), as the pdf is built, without using the convert?
Test_x_Assistenza.pdf (113,7 KB)

@Davide_C

We apologize for the over-communication. Are you trying to work with existing document (tagged initially) and want to insert new tagged content from code inside it using Aspose.PDF for Java? For the sample file that you have shared, it was generated using JasperReports?

No, that pdf was created by Aspose.pdf, starting from scratch so with a
document = new com.aspose.pdf.Document();

For each object that is inserted in the Document I would need to insert the corresponding tagging.

FloatingBox with TextSegmentCollection for the text, etc

Thanks

@Davide_C

In that case, if possible - a list of the elements that you are adding to the PDF may be helpful in investigating the feasibility of the requirements that you have. Please try to compile a list of the elements like TextSegments, TextFragment, Table, etc. share with us so that we can log an investigation ticket and share the ID with you.

Hello below the code used to insert the various elements in the pdf, the code is not complete.
The initial part of the document creation is the same as the code already sent

// Add a new page to the main Aspose PDF document
currentAsposePage = document.getPages().add();
currentAsposePage.setPageSize(newPageSize.getWidth(), newPageSize.getHeight()); // Apply page size

        currentAsposePage.getPageInfo().getMargin().setLeft(0);
        currentAsposePage.getPageInfo().getMargin().setRight(0);
        currentAsposePage.getPageInfo().getMargin().setBottom(0);
        currentAsposePage.getPageInfo().getMargin().setTop(0);

        currentAposeGraph = new Graph(currentAsposePage.getPageInfo().getWidth(),
                                            currentAsposePage.getPageInfo().getHeight());

        currentAsposePage.getParagraphs().add(currentAposeGraph);

// add objects
// line
com.aspose.pdf.drawing.Line pdfLine = new com.aspose.pdf.drawing.Line();
pdfLine.getGraphInfo().setLineWidth(1);
pdfLine.getGraphInfo().setColor(toAsposeColor);
pdfLine.setPositionArray(new float[] { startX, startY, endX, endY });

        currentAposeGraph.getShapes().addItem(pdfLine);


        // rectangle
		com.aspose.pdf.drawing.Rectangle rect = new com.aspose.pdf.drawing.Rectangle(strokeBoxX, strokeBoxY, strokeBoxWidth, strokeBoxHeight);
        currentAposeGraph.getShapes().addItem(rect);


        // text
        FloatingBox floatingBox = new FloatingBox();
        floatingBox.setLeft(x);
        floatingBox.setTop(y);
        floatingBox.setWidth(width);
        floatingBox.setHeight(height);
        floatingBox.setNeedRepeating(false);			
		
        com.aspose.pdf.TextFragment fragmentColl = new com.aspose.pdf.TextFragment();
        TextSegmentCollection sc = fragmentColl.getSegments();
        if(lstTextSegment !=  null && lstTextSegment.size() > 0) {
                for (int i = 0; i < lstTextSegment.size(); i++) {
                            com.aspose.pdf.TextSegment segment = lstTextSegment.get(i);
                            sc.add(segment);

                }
                floatingBox.getParagraphs().add(fragmentColl);
        }
        currentAsposePage.getParagraphs().add(floatingBox);						

// end add objects

        PdfFormatConversionOptions options = new PdfFormatConversionOptions(
                "c:\\butta\\taggedpdf2.xml",PdfFormat.PDF_A_1A, ConvertErrorAction.Delete);
        options.setAutoTaggingSettings(AutoTaggingSettings.getDefault());
        document.convert(options);			// error to convert 
		
        document.save(os);	

Thanks

@Davide_C

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-45130

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.

Hello, is there any news regarding the resolution of the problem or at least an indication on how to tag the elements individually without using automatic tagging?
Thanks.

@Davide_C

We are afraid that no update is available at the moment because ticket hasn’t been investigated yet due to other pending issues in the queue. We have already logged your concerns and will definitely consider them during analysis process. As soon as we have some updates, we will inform you. Please be patient and spare us some time.

We are sorry for the inconvenience.

Good morning, I’d like to reiterate my inquiry regarding the status of this report.
What’s the status of the fixes or implementations?
I’m still wondering if it’s possible to tag the elements from code without calling a method that does it automatically.
Thanks

@Davide_C

The ticket is still pending resolution due to earlier issues in the queue. However, your concerns have been noted, and we will promptly update you as progress is made. We kindly ask for your patience and sincerely apologize for any inconvenience caused.

Good morning, have you had any updates regarding this report?
Can we tag the individual elements when creating the PDF?
Thanks.

@Davide_C

We regret to inform you that the ticket has not been resolved yet. Our team is actively working on it; however, there are other tickets in the queue that were submitted earlier. Rest assured, your concerns have been logged, and we will promptly update you as soon as there is progress. We sincerely apologize for any inconvenience caused.

Good morning, any news? How’s the resolution of the open ticket progressing?
Thanks.

@Davide_C

The ticket is currently under investigation and has not yet been resolved. We will notify you as soon as we have definitive updates regarding its resolution. Thank you for your patience and understanding. We sincerely apologize for any inconvenience caused.

Good morning, I’m wondering what the status of the open case is. Is it possible to request a resolution? It’s been open for months.

@Davide_C

The ticket has been under the investigation phase and as it was logged under free support model, it is scheduled on the basis of first-come, first-served policy. Your concerns have already been recorded under the ticket and raised internally. We will surely inform you once we make some significant progress regarding ticket fix. We appreciate your patience and comprehension in this matter. We apologize for the inconvenience.