Merge pull request #1029 from ispyisail/fix/bugtracker-340-pdfxid

Fix bugtracker #340: small PDF text drawn too bold in Adobe Acrobat
This commit is contained in:
Laurent Trinques
2026-09-25 14:35:43 +02:00
committed by GitHub
4 changed files with 34 additions and 0 deletions
+1
View File
@@ -227,6 +227,7 @@ int exportPdf(QETProject &project, const QString &output,
// Rewrite the URI link annotations into native internal GoTo actions, so
// the cross-references jump inside the document in any PDF viewer.
PdfLinks::convertUriToGoTo(output);
PdfLinks::removeUnusedPdfxNamespace(output);
out << "Exported " << diagrams.size() << " page(s) -> " << output << "\n";
return 0;
+23
View File
@@ -388,6 +388,29 @@ void convertUriToGoTo(const QString &pdfPath)
out.close();
}
void removeUnusedPdfxNamespace(const QString &pdfPath)
{
QFile f(pdfPath);
if (!f.open(QIODevice::ReadOnly)) return;
QByteArray data = f.readAll();
f.close();
// Qt only fills the pdfxid namespace in when it writes PDF/X-4.
if (data.contains("pdfxid:GTS_PDFXVersion")) return;
static const QByteArray decl =
" xmlns:pdfxid=\"http://www.npes.org/pdfx/ns/id/\"";
const int pos = data.indexOf(decl);
if (pos == -1) return;
// Same length, so the stream /Length and the xref offsets stay valid.
data.replace(pos, decl.size(), QByteArray(decl.size(), ' '));
if (!f.open(QIODevice::WriteOnly | QIODevice::Truncate)) return;
f.write(data);
f.close();
}
void convertComponentInfoAnnotations(const QString &pdfPath,
const QList<ComponentInfo> &annotations)
{
+9
View File
@@ -74,6 +74,15 @@ namespace PdfLinks {
*/
void convertUriToGoTo(const QString &pdfPath);
/**
Post-process a Qt-generated PDF file: blank out the PDF/X namespace
declaration Qt 6 writes into the XMP metadata of every PDF. Adobe
Acrobat draws small text too bold when it is present (bugtracker #340).
Replaced in place with spaces, so no offset changes. No-op for a real
PDF/X file or when the declaration is absent.
*/
void removeUnusedPdfxNamespace(const QString &pdfPath);
struct ComponentInfo {
QString contents;
};
+1
View File
@@ -874,6 +874,7 @@ void ProjectPrintWindow::print()
// Convert URI link annotations into native internal GoTo/FitR
// actions so cross-references jump inside the document.
PdfLinks::convertUriToGoTo(pdfFile);
PdfLinks::removeUnusedPdfxNamespace(pdfFile);
this->close();
});