Skip to content
This repository has been archived by the owner. It is now read-only.

Running the pdf example produces a pdf with no selectable text #10373

Open
ghost opened this issue Feb 7, 2012 · 50 comments

Comments

@ghost
Copy link

@ghost ghost commented Feb 7, 2012

bla...@gmail.com commented:

Which version of PhantomJS are you using? Tip: run 'phantomjs --version'.
1.4.1

What steps will reproduce the problem?

  1. phantomjs rasterize.js 'http://en.wikipedia.org/w/index.php?title=Jakarta&printable=yes' jakarta.pdf
  2. Look at result and try to select text
  3. Impossible to select text

What is the expected output? What do you see instead?
output is a pdf. i expect to see pdf and ability to select the text.

Which operating system are you using?
osx

Did you use binary PhantomJS or did you compile it from source?
binary

Please provide any additional information below.
Are you supposed to be able to select the text for the pdf? If not then what is the purpose? Thanks!

Disclaimer:
This issue was migrated on 2013-03-15 from the project's former issue tracker on Google Code, Issue #373.
🌟   14 people had starred this issue at the time of migration.

@thomasbachem

This comment has been minimized.

Copy link

@thomasbachem thomasbachem commented May 20, 2012

m...@thomasbachem.com commented:

Same on Debian with the 1.5.0 binary. Tried it with several websites. That's a pretty big issue :/

@thomasbachem

This comment has been minimized.

Copy link

@thomasbachem thomasbachem commented May 22, 2012

m...@thomasbachem.com commented:

This issue seems very similar to http://code.google.com/p/wkhtmltopdf/issues/detail?id=886, where rendering with the newest static build of wkhtmltopdf leads to unselectable text, but using an older binary works well. May be that helps, since wkhtmltopdf is also relying on QtWebKit.

@veeneck

This comment has been minimized.

Copy link

@veeneck veeneck commented Aug 16, 2012

veen...@gmail.com commented:

Using 1.6 now, this issue is still here, and doesn't appear to be one of the milestones for 1.7. Wanted to check in and see if anyone found a workaround?

@trainiac

This comment has been minimized.

Copy link

@trainiac trainiac commented Aug 22, 2012

adkison....@gmail.com commented:

It turns out that phantomjs 1.6 running on Linux does output PDFs with selectable text. I can confirm that phantomjs 1.6 on Mac OS X 10.7.4 does not output pdfs with selectable text.

@wachunga

This comment has been minimized.

Copy link

@wachunga wachunga commented Nov 10, 2012

david.hi...@pulseenergy.com commented:

Also an issue on phantomjs 1.7.0 on OSX 10.6.8 using the same jakarta example.

@andineck

This comment has been minimized.

Copy link

@andineck andineck commented Feb 14, 2013

andin...@gmail.com commented:

I have got the same problem on phantomjs 1.8.1 on OSX 10.8.2

@andineck

This comment has been minimized.

Copy link

@andineck andineck commented Feb 15, 2013

andin...@gmail.com commented:

I can confirm that text is selectable inside the PDF with phantomjs 1.8.1 on Ubuntu 12.04. It looks like it really is a Mac OSX problem.

@ragekit

This comment has been minimized.

Copy link

@ragekit ragekit commented Apr 29, 2013

using an old version of wkhtmltopdf seems to work (like this one) http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-OSX-0.10.0_rc2-static.tar.bz2

@ragulka

This comment has been minimized.

Copy link

@ragulka ragulka commented Sep 23, 2013

I can also confirm that running phantomjs 1.8.2 on OSX 10.8.5 results in text not being selectable and links not clickable.

@bruno-c

This comment has been minimized.

Copy link

@bruno-c bruno-c commented Oct 4, 2013

OSX 10.7.5 here, same issue.

@ianpetzer

This comment has been minimized.

Copy link

@ianpetzer ianpetzer commented Oct 9, 2013

There is a pull request for a fix here: #11509

ragulka added a commit to ragulka/phantomjs that referenced this issue Oct 31, 2013
Produces selectable text when printing/rasterizing to PDF on OSX.

ariya#10373
bruno-c pushed a commit to Acquisio/phantomjs that referenced this issue Dec 9, 2013
Produces selectable text when printing/rasterizing to PDF on OSX.

ariya#10373
bruno-c pushed a commit to Acquisio/phantomjs that referenced this issue Dec 10, 2013
Produces selectable text when printing/rasterizing to PDF on OSX.

ariya#10373
@TooBug

This comment has been minimized.

Copy link

@TooBug TooBug commented Aug 25, 2014

any progress on this?

@marcbachmann

This comment has been minimized.

Copy link

@marcbachmann marcbachmann commented Aug 25, 2014

I guess this will be fixed in version phantomjs v2.
It's using QT5 which shouldn't have the problem.

@nickcmaynard

This comment has been minimized.

Copy link

@nickcmaynard nickcmaynard commented Nov 21, 2014

Backing up @andi-neck - definitely an OSX issue. Identical NPM/phantomjs versions show this working on Linux (Ubuntu 14.04), but not on OSX (Yosemite).

@aidos

This comment has been minimized.

Copy link

@aidos aidos commented Dec 2, 2014

I'm running 2.0.0 (development) on linux and I'm seeing the issue. While trying to render an svg containing embedded fonts all the text is rasterized (it looks correct, but it isn't text).

@AnthonyClink

This comment has been minimized.

Copy link

@AnthonyClink AnthonyClink commented Jan 3, 2015

I experience the same issue same code runs great on windows 8, except, the viewport seems to be better respected on my windows box and the text just is not selectable.

@josebalius

This comment has been minimized.

Copy link

@josebalius josebalius commented Jan 5, 2015

What is the resolution for this? Is it confirmed that it works on Linux but not Mac?

@aidos

This comment has been minimized.

Copy link

@aidos aidos commented Jan 5, 2015

It's not working on Linux for me (2.0.0).

I discovered that as long as you don't embed the fonts in the SVG they render as text. I guess you need to have them registered and available within the system but that gets into some Linux font madness that I couldn't quite figure out.

I was trying to take my embedded fonts, strip them from the SVG, register them temporarily as system fonts, render the PDF, then deregister the fonts again. I think there's a work around there - hopefully someone who knows a little more about font management in Linux knows how to make this pattern work.

@coud

This comment has been minimized.

Copy link

@coud coud commented Jan 31, 2015

I confirm this bug too using phantomjs 2 in Ubuntu 14.04

astefanutti added a commit to astefanutti/phantomjs that referenced this issue Jul 17, 2015
…n QCoreTextFontEngine

Fix bugs generating PDF on Cocoa

Provide real implementations of:
	properties(), faceId() and getUnscaledGlyph

Task-number: QTBUG-10094

ariya#10373
@leeight

This comment has been minimized.

Copy link
Contributor

@leeight leeight commented Jul 20, 2015

I confirm this bug too using phantomjs 2 in Mac

astefanutti added a commit to astefanutti/phantomjs that referenced this issue Aug 6, 2015
…n QCoreTextFontEngine

Fix bugs generating PDF on Cocoa

Provide real implementations of:
	properties(), faceId() and getUnscaledGlyph

Task-number: QTBUG-10094

ariya#10373
astefanutti added a commit to astefanutti/phantomjs that referenced this issue Aug 6, 2015
…n QCoreTextFontEngine

Fix bugs generating PDF on Cocoa

Provide real implementations of:
	properties(), faceId() and getUnscaledGlyph

Task-number: QTBUG-10094

ariya#10373
@abecks

This comment has been minimized.

Copy link

@abecks abecks commented Aug 26, 2015

I can confirm this is happening when building PhantomJS 2.0.0 from source on CentOS 6

@XadillaX

This comment has been minimized.

Copy link

@XadillaX XadillaX commented Sep 24, 2015

+1 same issue

@travis5555

This comment has been minimized.

Copy link

@travis5555 travis5555 commented Sep 29, 2015

+1 with PhantomJS 2.0.0 on Mac. Any workarounds?

@ali-habibzadeh

This comment has been minimized.

Copy link

@ali-habibzadeh ali-habibzadeh commented Nov 16, 2015

+1 Same issue

@astefanutti

This comment has been minimized.

Copy link
Contributor

@astefanutti astefanutti commented Nov 17, 2015

Given the externalisation of Qt Base as a submodule, PR #13243 is superseded by vitallium/qtbase#2.

@anantshri

This comment has been minimized.

Copy link

@anantshri anantshri commented Nov 17, 2015

@astefanutti do you have instructions on how this pull request could be tested. I am interested in doing the test just need proper instructions.

@astefanutti

This comment has been minimized.

Copy link
Contributor

@astefanutti astefanutti commented Nov 17, 2015

@anantshri just rebuild PhantomJS with vitallium/qtbase#2 on Mac OS and run the usual rasterize.js example with output PDF.

@travis5555

This comment has been minimized.

Copy link

@travis5555 travis5555 commented Dec 3, 2015

@astefanutti does that also include hyperlink support (#10196)? Given the warning in the compilation instructions (http://phantomjs.org/build.html), any chance you would mind posting a compiled binary for Mac OS? Thanks a ton for your fixes!

@astefanutti

This comment has been minimized.

Copy link
Contributor

@astefanutti astefanutti commented Dec 3, 2015

@travis5555 you can get a Mac OS binary from here: https://github.com/astefanutti/decktape#install. It contains hyperlink support as well.

@travis5555

This comment has been minimized.

Copy link

@travis5555 travis5555 commented Dec 3, 2015

thanks for the quick reply @astefanutti! I hadn't seen decktape before - it looks pretty awesome. since it has all of the awesomeness of embedded text, hyperlink, support, etc, is there any reason it can't be used for generic HTML > PDF conversion as opposed to slide decks specifically?

@astefanutti

This comment has been minimized.

Copy link
Contributor

@astefanutti astefanutti commented Dec 3, 2015

@travis5555 you're right. DeckTape depends on the improved version of PhantomJS that I maintain here https://github.com/astefanutti/phantomjs and that can be used for general purpose HTML to PDF conversion. Ideally, all the improvements will be integrated in PhantomJS upstream so that DeckTape value remains for slide decks specifically.

@kilianc

This comment has been minimized.

Copy link

@kilianc kilianc commented Dec 13, 2015

@astefanutti how do I npm i your fork ?

@astefanutti

This comment has been minimized.

Copy link
Contributor

@astefanutti astefanutti commented Feb 24, 2016

Some progress related to that issue can be found at #13997 (mostly Linux).

@Tin-Nguyen

This comment has been minimized.

Copy link

@Tin-Nguyen Tin-Nguyen commented Apr 20, 2016

+1 same issue. Any workaround to fix this?

@robinfhu

This comment has been minimized.

Copy link

@robinfhu robinfhu commented May 9, 2017

Wanted to post my solution to this problem. It turns out that loading a web font from a remote URL will cause PhantomJS to rasterize the font in the PDF. This creates a PDF where the text cannot be highlighted, since it is an image. This causes the PDF file size to grow 10 times.

We were using Proxima Nova, and our CSS file looked like this:

@font-face
    font-family ProximaNovaReg
    font-style normal
    font-weight 100
    src url("/assets/fonts/ProximaNova-ThinWeb.woff") format("woff")

body
   font-family ProximaNovaReg

To fix the issue, we installed the Proxima Nova TTF files directly onto our Ubuntu box. This means copying the TTF files to /usr/share/fonts/truetype, and running fc-cache -fv.

Now we can change our CSS to just the following:

body
   font-family "Proxima Nova"

PhantomJS now treats Proxima Nova as a natively installed font, and renders a smaller sized PDF with selectable text. This is the right solution.

Note: I only encountered this problem on Linux. Mac OS worked fine.

@jpbochi

This comment has been minimized.

Copy link

@jpbochi jpbochi commented May 10, 2017

@robinfhu I was going to try your solution and realised that upgrading my dependencies was enough. I think there was a bug, and it got fixed at some point. Regardless of that, the case you found is a very good one to know.

FWIW, I'm using phantomjs indirectly via https://www.npmjs.com/package/markdown-pdf.

@SWGFL

This comment has been minimized.

Copy link

@SWGFL SWGFL commented May 24, 2017

1.9.8 works for me on Centos7. 2.1.1 rasterizes the output

@liwonder

This comment has been minimized.

Copy link

@liwonder liwonder commented Aug 31, 2017

@robinfhu your solution works for me.
environment:
phantomjs: 2.1.1
os: Ubuntu 16.04 LTS

I installed the font used in my pdf to the machine. Now the pdf output is as normal as the output in my Mac.

But the thing is I need to run some pdf render test in the CI with Ubuntu OS. I don't want to install font before run the test, and that is not a good solution.

Maybe with some fix the linux version of Phantomjs can fix this issue. I am still watching this, if there are any updates.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
You can’t perform that action at this time.