diff --git a/widget/gtk/nsDeviceContextSpecG.cpp b/widget/gtk/nsDeviceContextSpecG.cpp index f0de247407f0..93401134a11e 100644 --- a/widget/gtk/nsDeviceContextSpecG.cpp +++ b/widget/gtk/nsDeviceContextSpecG.cpp @@ -295,8 +295,14 @@ nsDeviceContextSpecGTK::BeginDocument(const nsAString& aTitle, const nsAString& aPrintToFileName, int32_t aStartPage, int32_t aEndPage) { - mTitle.Truncate(); - AppendUTF16toUTF8(aTitle, mTitle); + // Print job names exceeding 255 bytes are safe with GTK version 3.18.2 or + // newer. This is a workaround for old GTK. + if (gtk_check_version(3,18,2) != nullptr) { + PrintTarget::AdjustPrintJobNameForIPP(aTitle, mTitle); + } else { + CopyUTF16toUTF8(aTitle, mTitle); + } + return NS_OK; }