Coder Social home page Coder Social logo

wkpdf's People

Contributors

anoopsinha avatar atotic avatar bomeyer avatar ejzn avatar kemitchell avatar plessl avatar ximus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wkpdf's Issues

--save-delay appears to not work

I have a bunch of pages that take a long time to load data (10-15 seconds).

As is, wkpdf appears to render the pdf while a couple of the graphs are still rendering, and so those graphs are not complete. They are shows as graphs where the line is just starting to be rendered.

I'm running MacOS X Lion 10.7.3 on a MacBook Pro.

I tried to use the --save-delay option and it doesn't appear to add any delay to rendering. Also, when I run --debug there is no delay before the exit. I would have guessed that --save-delay would allow the page to finish rendering before starting the pdf. But it appears to make no difference. (A really bad workaround is to keep rendering additional random graphs and then hide them at the end, giving wkpdf extra time to complete the original graphs.)

Same behavior every time.

gem install error

I try to install wkpdf use gem.

sudo apt-get intall ruby
sudo gem update system
sudo gem install wkpdf

Then i got an error like this:

ERROR:  Could not find a valid gem 'wkpdf' (>= 0), here is why:
          Found wkpdf (0.6.11), but was for platform universal-darwin

And,

 #  gem env

RubyGems Environment:
  - RUBYGEMS VERSION: 1.8.23
  - RUBY VERSION: 1.9.3 (2012-04-20 patchlevel 194) [i686-linux]
  - INSTALLATION DIRECTORY: /var/lib/gems/1.9.1
  - RUBY EXECUTABLE: /usr/bin/ruby1.9.1
  - EXECUTABLE DIRECTORY: /usr/local/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-linux
  - GEM PATHS:
     - /var/lib/gems/1.9.1
     - /home/lich/.gem/ruby/1.9.1
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/

How to build wkpdf?

I'm new to Ruby, but not new to programming. I cloned the repo on my Mac (OS X 10.8.2). I have rubygems, rake, and jeweler installed. Running 'rake gemspec' succeeds, but running 'rake' fails with the message "Don't know how to build task 'default'." How do I actually build wkpdf?

Support for arbitrary paper sizes and margins

Feature request suggested by Tobias Rodäbel

Index: CommandlineParser.m
===================================================================
--- CommandlineParser.m (revision 34)
+++ CommandlineParser.m (working copy)
@@ -82,7 +82,7 @@
  //_output = @"/dev/stdout";
  _paperSize = [NSPrintInfo sizeForPaperName:@"A4"];
  _paginate = YES;
-  _margin = [NSDecimalNumber notANumber];
+  _margin = 0;
  _stylesheetMedia = nil;
  _printBackground = NO;
  _paperOrientation = NSPortraitOrientation;
@@ -418,10 +418,19 @@
- (NSSize)parsePaperSize:(char *)arg
{
  NSString * paperName = [NSString stringWithUTF8String:arg];
-  NSSize size = [NSPrintInfo sizeForPaperName:paperName];
-  if ((size.width == 0.0) && (size.height == 0.0)){
-    fprintf(stderr,"%s is not a valid paper format!\n",arg);
-    [Helper terminateWithErrorcode:1 andMessage:@"invalid paper format"];
+  NSSize size;
+  if ([paperName matchesPattern:@"[0-9]*x[0-9]*"]){
+    float point = 2.834645669;
+    NSArray *dim = [paperName componentsSeparatedByString:@"x"];
+    float width = [[dim objectAtIndex:0] floatValue];
+    float height = [[dim objectAtIndex:1] floatValue];
+    size = NSMakeSize(width*point, height*point);
+  } else {
+    size = [NSPrintInfo sizeForPaperName:paperName];
+    if ((size.width == 0.0) && (size.height == 0.0)){
+      fprintf(stderr,"%s is not a valid paper format!\n",arg);
+      [Helper terminateWithErrorcode:1 andMessage:@"invalid paper format"];
+    }
  }
  return size;
}

Support for Mac OS 10.9 Mavericks

I tried to run wkpdf on Mac OS 10.9.
I got the following result:

$ wkpdf --source http://www.apple.com --output apple.pdf
Cannot load RubyCocoa library
wkpdf requires that RubyCocoa is installed, which is shipped by default since
Mac OS X 10.5. If you use Mac OS X 10.4, you have to install RubyCocoa
yourself from http://rubycocoa.sourceforge.net/HomePage

It is obviously a problem with RubyCocoa, but I couldn't investigate further.

Save delay causes an exception

When I add --save-delay I get the following exception:

2010-02-19 11:13:30.960 ruby[53317:60f] Controller#webView_didFinishLoadForFrame: OSX::OCMessageSendException: Can't get Objective-C method signature for selector 'scheduledTimerWithTimeInterval:target:selector:userInfo:repeat:' of receiver OSX::NSTimer
matt@mat/Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/oc_wrapper.rb:50:in ocm_send'matt@mat/Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/oc_wrapper.rb:50:inmethod_missing'
matt@mat/Library/Ruby/Gems/1.8/gems/wkpdf-0.3.8-universal-darwin/bin/../lib/controller.rb:33:in webView_didFinishLoadForFrame'matt@mat/Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/oc_wrapper.rb:50:inocm_send'
matt@mat/Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/oc_wrapper.rb:50:in `method_missing'e pool (/Library/Ruby/Gems/1.8/gems/wkpdf-0.3.8-universal-darwin/bin/../lib/wkpdf.rb:103
2010-02-19 11:13:30.970 ruby[53317:60f] *** WebKit discarded an uncaught exception in the webView:didFinishLoadForFrame: delegate: <RBException_OSX::OCMessageSendException> Can't get Objective-C method signature for selector 'scheduledTimerWithTimeInterval:target:selector:userInfo:repeat:' of receiver OSX::NSTimer

I'm using ruby 1.8.7 (2008-08-11 patchlevel 72) [universal-darwin10.0] on OS X 10.6.2

Snow Leopard warning

Snow leopard gives a warning:

: 2009-09-11 06:02:35.288 ruby[13256:903] *** WARNING: Method sizeForPaperName: in class NSPrintInfo is deprecated. It will be removed in a future release and should no longer be used.

wkpdf and page breaks within table rows

When a table row falls over the page break, it gets positioned oddly on the next page. To see what I mean, go here:

http://joewlarson.com/misc/test.pdf

which is a PDF based on this HTML:

http://joewlarson.com/misc/test.html

which was created using:

wkpdf --source http://joewlarson.com/misc/test.html --paper A4 --print-background --output test.pdf

(though you can also reproduce this without A4 or backgrounds FWIW).

Anyway, if you go to the top of the third page you'll see how the "4 This is an ordinary in a " row is pushed down so it overlays the next row. Can this be fixed in wkpdf or is this a webkit issue?

Can't run on Snow Leopard

Even after installing the latest version, wkpdf barfs with this message:

$ sudo gem update --system
$ sudo gem install plessl-wkpdf --source http://gems.github.com
$ wkpdf --help

Platform not supported: wkpdf runs only on Mac OS X 10.5 and later

$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.6.1
BuildVersion: 10B504

Shrink to fit

Okay, last issue for today, actually a feature request. Unless it's already possible to do this, I'd like to see an option to reduce the horizontal width of the page to fit the selected paper size. Right now, I'm seeing web sites that are wider than letter-sized being cut off on the right edge. This can be mitigated by using a larger paper size, but that creates so very large margins.

(Perhaps a user stylesheet could also fix this, but as of yet I've not been able to get that flag to work.)

User stylesheet not accepted

Using 0.6.9 on OSX 10.8.2, the user-stylesheet flag isn't accepted:

prime-directive:~ don$ wkpdf --source http://www.apple.com --user-stylesheet /Users/don/wkpdf.css --output apple.pdf

2013-01-25 12:13:31.155 ruby[41725:707] -[NSURL length]: unrecognized selector sent to instance 0x7fe0e4444310
/System/Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/oc_wrapper.rb:50:in `ocm_send': NSInvalidArgumentException - -[NSURL length]: unrecognized selector sent to instance 0x7fe0e4444310 (OSX::OCException)
from /System/Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/oc_wrapper.rb:50:in `method_missing'
from /Library/Ruby/Gems/1.8/gems/wkpdf-0.6.9-universal-darwin/bin/../lib/wkpdf.rb:68:in `main'
from /Library/Ruby/Gems/1.8/gems/wkpdf-0.6.9-universal-darwin/bin/wkpdf:5
from /usr/bin/wkpdf:23:in `load'
from /usr/bin/wkpdf:23

wkpdf is broken in Mountain Lion (CFURLGetFSRef was passed this URL which has no scheme)

OS X Mountain Lion changed the way how files are referenced as CFURLs. This results in wkpdf breaking if the --output parameter points to a POSIC file name raising the following error:

CFURLGetFSRef was passed this URL which has no scheme (the URL may not work with other CFURL routines): ./

A workaround is to specify the --output parameter in URL syntax using the file:/// scheme.

The problem should be fixed soon.

Port wkpdf to Swift or Objective-C

wkpdf builds on RubyCocoa, which has been abandoned by Apple in OS X 10.9. Hence, I will stop the support and development of the RubyCocoa version of wkpdf.

There has been a predecessor version to wkpdf, which was implemented in Objective-C. I'm considering porting wkpdf either back to Objective-C or to Apple's new programming language Swift.

If anybody is interested in contributing to this effort, please let me know.

add sample pdfs

Please add sample pdfs to either the homepage or the repo. This looks like a nice utility but there are no screenshots or example files (that i could find) in this repo or on the info page http://plessl.github.com/wkpdf/

nvd3 svg charts with wkhtmltoimage

Sorry this is probably offtopic but I couldn't find any info on this. I made a couple of graphs with nvd3 js library. Basically it uses svg to create charts. But I couldn't generate images using wkhtmltoimage. Although it partly works as I'm able to see text ouput from the graph which is also generated with svg.
I've included Function.prototype.bind which should have solved bugs with svg, and I've also tried flag --debug-javascript which showed no errors. Javascript delay was set to 5 seconds (--javascript-delay 5000)
Probably someone already had such problems. Thanks.

Background color missing when --no-paginate set

Odd. If -no-paginate is set, background colors will not be displayed. For example, this command:

wkpdf --output website-preview.pdf --source file:///Users/bla/Desktop/test.html --paper letter --no-paginate --margins 0 --caching no --print-background --ignore-http-errors

with this as the source file:

<html>
<head>
</head>
<body>
<div style="background-color: grey">
This<br />
is<br />
a<br />
test
</div>
</body>
</html>

will produce a PDF with no grey background. (There also appears to be a font size issue.)

Accept input from stdin

I would like to be able to accept input from stdin so that html can be piped to it. For example, to convert from markdown to pdf, you could:

$ Markdown.pl test.md | wkpdf --output test.pdf

wkpdf doesn't work in Lion

Hi,

Updated rubygems as per explained on the wkpdf homepage then installed wkpdf.

Now when I try to run it, I get the following:

/Library/Ruby/Site/1.8/rubygems/dependency.rb:247:in `to_specs': Could not find wkpdf (>= 0) amongst [] (Gem::LoadError)
    from /Library/Ruby/Site/1.8/rubygems/dependency.rb:256:in `to_spec'
    from /Library/Ruby/Site/1.8/rubygems.rb:1231:in `gem'
    from /usr/bin/wkpdf:22

Any ideas why and how can I fix this?

Thanks!

`require': cannot load such file -- rdoc/usage (LoadError)

CodeBrauer:Desktop gabriel$ wkpdf --source http://www.apple.com --output apple.pdf

Output

/Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- rdoc/usage (LoadError)
    from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /Library/Ruby/Gems/2.0.0/gems/wkpdf-0.6.11-universal-darwin/lib/commandline_parser.rb:1:in `<top (required)>'
    from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /Library/Ruby/Gems/2.0.0/gems/wkpdf-0.6.11-universal-darwin/lib/wkpdf.rb:14:in `<top (required)>'
    from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /Library/Ruby/Gems/2.0.0/gems/wkpdf-0.6.11-universal-darwin/bin/wkpdf:4:in `<top (required)>'
    from /usr/bin/wkpdf:23:in `load'
    from /usr/bin/wkpdf:23:in `<main>'

Installed RubyCocoa 1.2.0

Mac OS 10.10.1
Ruby: ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14]

Error when using an user script

When an user script url is passed as an argument to wkpdf the pdf generation is failing and the following error is returned:

Controller#webView_didFinishLoadForFrame: OSX::OCException: NSInvalidArgumentException - -[NSURL length]: unrecognized selector sent to instance
    /System/Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/oc_wrapper.rb:50:in `ocm_send'
    /System/Library/Frameworks/RubyCocoa.framework/Resources/ruby/osx/objc/oc_wrapper.rb:50:in `method_missing'
    /Library/Ruby/Gems/1.8/gems/wkpdf-0.6.10-universal-darwin/bin/../lib/controller.rb:186:in `loadUserScript
(...)

Upon code inspection, it seems the error's on controller.rb in the loadUserScript method when it expects the location argument to be a string, which it then tries to converts to an NSURL but apparently the argument's already being sent as an NSURL. I've changed the line

theURL = NSURL.URLWithString(location)

to

theURL = location

on my local version of wkpdf and the pdf generation with user script seems to go fine.

Please un-yank the gem

Hello,

I found wkpdf to be very useful. I haven't used it on my new OS X 10.9 system yet, and tried installing it now in the last minute, but it doesn't work. My understanding, per http://plessl.github.io/wkpdf/, is that you have purposefully disabled it, even though it should still be working.

Why disable something that still works, in preparation for the future? Could you please kindly undisable it, or provide instructions for a workaround?

Best regards,
Constantine.

Ampersand when printing URL

When using an URL as --source, if an ampersand (&) is present in the URL, it will be parsed and the remaining parameters (and command line options) will be interpreted as a new command.

I tried unsuccessfully to escape the URL with ' or ", using $a or ^& does not work either. Even setting a variable and using it as source (for example --source $myurl) generates the error.

Example command: wkpdf --output test.pdf --source "http://google.com?param1=1&param2=2"
This happens on Mac OS Server 10.5.8
wkpdf 0.3.5 (0.3.7 breaks on 10.5.8: http://github.com/plessl/wkpdf/issues/#issue/11)

Implement timeout

Terminate wkpdf after an optional, user defined timeout to prevent wkpdf from hanging with resources are not available etc.

Source file from disk

I'm perhaps doing this all wrong. Although I've been successful in using a URL from the 'net as a source, I'm utterly failing at using a file from disk. Although file is a supported protocol, I get nothing output:

prime-directive:~ don$ wkpdf --source file:index.html --output index.pdf
prime-directive:~ don$ wkpdf --source file:/index.html --output index.pdf
prime-directive:~ don$ wkpdf --source file://index.html --output index.pdf
prime-directive:~ don$ wkpdf --source file:///index.html --output index.pdf

(I thought the last command was the correct one, but I tried the others as well.)

I'm using version 0.6.9 on OSX 10.8.2 -- is it possible that the file protocol is broken?

NSURLErrorDomain

When wkpdf encounters some long href url in a page, it exit with
<WebView: 0x1033c20e0> didFailProvisionalLoadWithError "The operation couldn’t be completed. (NSURLErrorDomain error -999.)",
try it with
wkpdf --source http://www.asylumitalia.it/ --stylesheet-media screen --print-background yes --format A4 --portrait --output test.pdf --debug
thanks

Allow for setting the caching policy

Allow the user to specify if wkpdf is allowed to use cached information or if new HTTP requests shall be enforced.

This functionality was already present in the Objective-C version of wkpdf with option: --caching yes|no

Why can't I install this???

I tried the following as per instructions at https://plessl.github.io/wkpdf/:

user$ sudo gem update --system

…
Successfully installed rubygems-update-2.4.1
…

user$ sudo gem install wkpdf

Password:
ERROR:  Could not find a valid gem 'wkpdf' (>= 0) in any repository
ERROR:  Possible alternatives: wkpdf

Checked status:

http://status.rubygems.org/

RubyGems.org Status: UP

Tried:

user$ sudo traceroute rubygems.org

Never completed.

user$ ping rubygems.org

PING rubygems.org (54.186.104.15): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
Request timeout for icmp_seq 2

user$ gem list -r

…
wkhtmltopdf (0.1.2)
…
wkpdf (0.6.11 universal-darwin)

Tried:

user$ sudo gem install wkpdf -s http://production.cf.rubygems.org/

    Password:
    ERROR:  Could not find a valid gem 'wkpdf' (>= 0) in any repository
    ERROR:  Possible alternatives: wkpdf

Nothing worked, yet I was able to install wkhtmltopdf without incident.

Now what?

OS X 10.7 error on first test

Installed and ran the first test command: wkpdf --source http://www.apple.com --output apple.pdf
Received the following error:

sh-3.2# sudo wkpdf --source http://www.apple.com --output apple.pdf
2011-08-03 04:51:51.397 ruby[63461:a07] *** Assertion failure in -[WebHTMLView lockFocusIfCanDraw], /SourceCache/AppKit/AppKit-1138/AppKit.subproj/NSView.m:6068
2011-08-03 04:51:51.398 ruby[63461:a07] lockFocus sent to a view which is not in a window
2011-08-03 04:51:51.402 ruby[63461:a07](0 CoreFoundation 0x00007fff8c941986 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff97ba4d5e objc_exception_throw + 43
2 CoreFoundation 0x00007fff8c9417ba +[NSException raise:format:arguments:] + 106
3 Foundation 0x00007fff950ae14f -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 169
4 AppKit 0x00007fff934d899e -[NSView lockFocusIfCanDraw] + 515
5 AppKit 0x00007fff934d86b7 -[NSView lockFocus] + 39
6 AppKit 0x00007fff934d627b -[NSView _displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:] + 3780
7 AppKit 0x00007fff934cf093 -[NSView displayIfNeeded] + 1676
8 WebKit 0x00007fff8eba6a84 -[WebHTMLView knowsPageRange:] + 36
9 AppKit 0x00007fff93b6ec72 -[NSView%28NSPrinting2%29 _knowsPagesFirst:last:] + 164
10 AppKit 0x00007fff9399b161 -[NSConcretePrintOperation%28NSInternal%29 _validatePagination] + 179
11 AppKit 0x00007fff9399b2af -[NSConcretePrintOperation%28NSInternal%29 _firstPageNumber] + 27
12 AppKit 0x00007fff9399b352 -[NSConcretePrintOperation%28NSInternal%29 _validateJobPageNumbers] + 54
13 AppKit 0x00007fff9399b69e -[NSConcretePrintOperation%28NSInternal%29 _firstRenderPageNumber] + 27
14 AppKit 0x00007fff93be0bf1 -[NSView%28NSPrintingInternal%29 _printForCurrentOperation] + 85
15 AppKit 0x00007fff939999c5 -[NSConcretePrintOperation _renderView] + 224
16 AppKit 0x00007fff939993e1 -[NSConcretePrintOperation runOperation] + 363
17 libffi.dylib 0x00007fff940b1e7c ffi_call_unix64 + 76
18 ??? 0x00007fff66c49d40 0x0 + 140734917549376)

lib/wkpdf.rb should not be required to be executable

Study why lib/wkpdf.rb is required to be executable for a correct function of wkpdf. I think that it should be sufficient to have bin/wkpdf executable, but if the executable bit on lib/wkpdf.rb is missing wkpdf does not produce any output, e.g. when running "wkpdf --version"

SVG dropshadow filter not rendered

version: wkpdf 0.6.1

To replicate:

  1. Create an HTML file with inline SVG content with a dropshadow (see below for example).
  2. Run wkpdf.

expected: Faithfully rendered graphic in PDF.
result: The actual shape is rendered correctly in the PDF but the dropshadow is omitted.

SVG sample:

https://gist.github.com/1994389

Troubles wkpdf-ing from an authenticated url - has anyone else used wkpdf auth successfully?

I'm attempting to created a pdf from an (http basic) authenticated URL. The parameters seem pretty simple, and so my attempt looks something like this:

wkpdf --source http://localhost:5050/test/test.html --output test.pdf --username test --password test

The result is that the request just hangs, never times out (even if I supply a short timeout), never errors, never does anything. The webserver involved is a proprietary one (written from the ground up in java) and so it's possible/likely the problem is something to do with out it does authentication. But before I go bugging the dev responsible for that webserver, I'd like to ask:

Has anyone else used --username --password successfully to wkpdf an authenticated page?

Is it possible the problem is related to cookie usage (our webserver requires cookies to do even basic authentication)?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.