Skip to content
This repository has been archived by the owner on May 30, 2023. It is now read-only.

Commit

Permalink
OS X: Unsafe patch to fix selectable text on PDF output.
Browse files Browse the repository at this point in the history
  • Loading branch information
ariya committed Jan 11, 2014
1 parent 244cf25 commit 42b3a86
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions patches/osx-pdf-selectable-text.patch
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

0 comments on commit 42b3a86

Please sign in to comment.