This repository has been archived by the owner on May 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OS X: Unsafe patch to fix selectable text on PDF output.
- Loading branch information
Showing
1 changed file
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
From 0663263bfa748b0933d7eff4b5e49d9ed97bcc84 Mon Sep 17 00:00:00 2001 | ||
From: Illimar Tambek <[email protected]> | ||
Date: Thu, 31 Oct 2013 14:19:23 +0200 | ||
Subject: [PATCH 1/2] Fix for PDF text not being selectable on Mac OSX. | ||
|
||
Produces selectable text when printing/rasterizing to PDF on OSX. | ||
|
||
https://github.com/ariya/phantomjs/issues/10373 | ||
--- | ||
src/webpage.cpp | 8 ++++++++ | ||
1 file changed, 8 insertions(+) | ||
|
||
diff --git a/src/webpage.cpp b/src/webpage.cpp | ||
index 89a34da..fae5855 100644 | ||
--- a/src/webpage.cpp | ||
+++ b/src/webpage.cpp | ||
@@ -1067,6 +1067,14 @@ bool WebPage::renderPdf(const QString &fileName) | ||
QPrinter printer; | ||
printer.setOutputFormat(QPrinter::PdfFormat); | ||
printer.setOutputFileName(fileName); | ||
+ | ||
+ // Fix for PDF prints on Mac OSX. Produces selectable text | ||
+ #ifdef Q_WS_MACX | ||
+ if(fileName.endsWith(".pdf")) { | ||
+ printer.setOutputFormat(QPrinter::NativeFormat); | ||
+ } | ||
+ #endif | ||
+ | ||
printer.setResolution(PHANTOMJS_PDF_DPI); | ||
QVariantMap paperSize = m_paperSize; | ||
|
||
-- | ||
1.8.5.1 | ||
|
||
|
||
From 551caed5164ea0b5dcb1f1522c224186b982839b Mon Sep 17 00:00:00 2001 | ||
From: Illimar Tambek <[email protected]> | ||
Date: Mon, 11 Nov 2013 10:03:15 +0200 | ||
Subject: [PATCH 2/2] Remove file extension check | ||
|
||
--- | ||
src/webpage.cpp | 4 +--- | ||
1 file changed, 1 insertion(+), 3 deletions(-) | ||
|
||
diff --git a/src/webpage.cpp b/src/webpage.cpp | ||
index fae5855..1a15c13 100644 | ||
--- a/src/webpage.cpp | ||
+++ b/src/webpage.cpp | ||
@@ -1070,9 +1070,7 @@ bool WebPage::renderPdf(const QString &fileName) | ||
|
||
// Fix for PDF prints on Mac OSX. Produces selectable text | ||
#ifdef Q_WS_MACX | ||
- if(fileName.endsWith(".pdf")) { | ||
- printer.setOutputFormat(QPrinter::NativeFormat); | ||
- } | ||
+ printer.setOutputFormat(QPrinter::NativeFormat); | ||
#endif | ||
|
||
printer.setResolution(PHANTOMJS_PDF_DPI); | ||
-- | ||
1.8.5.1 | ||
|