Comments (3)
Hi Don
First of all, your HTML does not validate correctly. In this case it probably doesn't matter, but I would generally recommend to feed wkpdf only HTML that validates correctly (i.e. with correct DOCTYPE and character set specification).
I assume that the problem you are seeing is related to the fact that the document width is not defined when no pagination is used and your <div>
doesn't have a width set. I'm not sure whether this is the expected behavior of your HTML/CSS or whether this is a bug in WebKit.
But if you use the following HTML the result renders just fine:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>untitled</title>
</head>
<body>
<p style="background-color: grey; width: 200px;">
This<br />
is<br />
a<br />
test
</p>
</body>
</html>
One more thing: --no-paginate
does not work at least on my machine, but you need to use --paginate no
to suppress pagination.
Hope this helps.
from wkpdf.
Odd. If I remove the width
declaration in your example Safari will display the background color, but when I then preview the page as a PDF ( File > Print… > PDF > Open PDF in Preview ) the background color is not displayed.
BTW, as noted elsewhere, --paginate no
doesn't work on my machine.
from wkpdf.
Your test seems to confirm my theory, that a <div>
element without a width will be treated as zero width by the PDF renderer, but as non-zero width in the WebView that is used by Safari. I'm not sure whether this should be considered a bug in WebKit/Cocoa.
I think assigning a default width could be a workable workaround. But what about filing a bug report with WebKit?
from wkpdf.
Related Issues (20)
- add sample pdfs HOT 3
- wkpdf is broken in Mountain Lion (CFURLGetFSRef was passed this URL which has no scheme) HOT 1
- How to build wkpdf? HOT 2
- wkpdf crashs when running in sandbox HOT 5
- wkpdf doesn't work in Lion HOT 2
- Cannot load RubyCocoa library HOT 19
- Source file from disk HOT 4
- User stylesheet not accepted HOT 1
- Shrink to fit HOT 10
- generate PDFs with outlines/bookmarks HOT 1
- Error when using an user script HOT 1
- gem install error HOT 1
- Support for Mac OS 10.9 Mavericks HOT 16
- Nice ! How about Homebrew formula ? HOT 2
- nvd3 svg charts with wkhtmltoimage HOT 1
- Port wkpdf to Swift or Objective-C
- Why can't I install this??? HOT 7
- `require': cannot load such file -- rdoc/usage (LoadError) HOT 2
- Please un-yank the gem HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wkpdf.