vcl/qa/cppunit/pdfexport/data/tdf168057.odt |binary
 vcl/qa/cppunit/pdfexport/pdfexport2.cxx     |   13 +++++++++++++
 vcl/source/pdf/pdfwriter_impl.cxx           |   13 ++++++++++---
 3 files changed, 23 insertions(+), 3 deletions(-)

New commits:
commit 5dbf35a932bfa00e17f17b1f2337de7403754b8d
Author:     Xisco Fauli <[email protected]>
AuthorDate: Wed Feb 25 12:54:41 2026 +0100
Commit:     Xisco Fauli <[email protected]>
CommitDate: Wed Feb 25 14:50:11 2026 +0100

    tdf#168057: Don't use aliases in StructElem when exporting to PDF/UA-2
    
    Otherwise, the validator will fail with
    'Non-standard structure type http://iso.org/pdf2/ssn:/Standard is not
    mapped to a standard type'
    because we are using 'Standard' instead of 'P'
    
    Change-Id: Ifa7cff7f6914a2e25a5c31887c191360b810c9b1
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/200312
    Reviewed-by: Xisco Fauli <[email protected]>
    Tested-by: Jenkins

diff --git a/vcl/qa/cppunit/pdfexport/data/tdf168057.odt 
b/vcl/qa/cppunit/pdfexport/data/tdf168057.odt
new file mode 100644
index 000000000000..1090c5e9bfe3
Binary files /dev/null and b/vcl/qa/cppunit/pdfexport/data/tdf168057.odt differ
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport2.cxx 
b/vcl/qa/cppunit/pdfexport/pdfexport2.cxx
index c1611a143b8a..1c09db9ec2b9 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport2.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport2.cxx
@@ -1606,6 +1606,19 @@ CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf139736)
     CPPUNIT_ASSERT_GREATEREQUAL(3, nArtifacts);
 }
 
+CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf168057)
+{
+    uno::Sequence<beans::PropertyValue> aFilterData(
+        comphelper::InitPropertySequence({ { "PDFUACompliance", uno::Any(true) 
},
+                                           { "SelectPdfVersion", 
uno::Any(sal_Int32(20)) } }));
+    comphelper::SequenceAsHashMap aMediaDescriptor;
+    aMediaDescriptor[u"FilterData"_ustr] <<= aFilterData;
+    vcl::filter::PDFDocument aDocument;
+    loadFromFile(u"tdf168057.odt");
+    // Without the fix in place, the validation would have failed
+    save(TestFilter::PDF_WRITER, 
aMediaDescriptor.getAsConstPropertyValueList());
+}
+
 CPPUNIT_TEST_FIXTURE(PdfExportTest2, testTdf152231)
 {
     // Enable PDF/UA
diff --git a/vcl/source/pdf/pdfwriter_impl.cxx 
b/vcl/source/pdf/pdfwriter_impl.cxx
index efbc7ac01ab7..d8262a94c6aa 100644
--- a/vcl/source/pdf/pdfwriter_impl.cxx
+++ b/vcl/source/pdf/pdfwriter_impl.cxx
@@ -1130,10 +1130,17 @@ sal_Int32 PDFWriterImpl::emitStructure( 
PDFStructureElement& rEle )
                 aWriter.writeKeyAndReference("/NS", iterator->second);
         }
         aLine.append("/S/");
-        if( !rEle.m_aAlias.isEmpty() )
-            aLine.append( rEle.m_aAlias );
-        else
+        if (m_aContext.Version >= PDFWriter::PDFVersion::PDF_2_0)
+        {
             aLine.append( getStructureTag(*rEle.m_oType) );
+        }
+        else
+        {
+            if( !rEle.m_aAlias.isEmpty() )
+                aLine.append( rEle.m_aAlias );
+            else
+                aLine.append( getStructureTag(*rEle.m_oType) );
+        }
         if (m_StructElemObjsWithID.find(rEle.m_nObject) != 
m_StructElemObjsWithID.end())
         {
             aLine.append("
/ID ");

Reply via email to