Git Product home page Git Product logo

django-hardcopy's People

Contributors

brenouchoa avatar ckinsey avatar izimobil avatar joeribekker avatar tapionx avatar tyreldenison 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  avatar  avatar  avatar  avatar  avatar  avatar

django-hardcopy's Issues

Bug due to NamedTemporaryFile on windows

Using django-hardcopy, with windows 10, and python 3.6 I have found that it just hangs on the subprocess.call(). I think the reason for this is that, when python creates a NamedTemporaryFile, in NT it is created with the FILE_SHARE_DELETE flag, so that windows (not python) automatically deletes the file after it is closed. It also allows, the file to be opened a second time, when already open but it has to be opened with the FILE_SHARE_DELETE flag. As a result chrome can’t write to it or overwrite it. Fortunately, Django have created there own NamedTemporaryFile, (see here and here)

Replacing this line:
from tempfile import NamedTemporaryFile
with this:
from django.core.files.temp import NamedTemporaryFile
fixes everything for me. I have not tested this on any other operating systems, but it doesn’t look like it would cause any issues.

LICENSE INFO

What is the license for this fantastic library?
Can you kindly add a LICENSE file to your library. It will be useful to add the library for a project.

Fails to create PDF in Docker container

Hi there...I'm using django-hardcopy in Mac OSX natively with no issues. However, with the same Django app codebase I can't get it working in my Docker container. My Dockerfile is pretty basic:

FROM python:2.7.13-onbuild
RUN apt-get -y update && apt-get install -y --no-install-recommends less libboost-all-dev chromium

All I see in the Docker logs is this warning: [1227/175519.609298:WARNING:audio_manager.cc(321)] Multiple instances of AudioManager detected which tells me chromium is at least doing something. But it fails to produce a PDF and all I get when browsing to the view is a Chrome PDF error "Failed to load PDF document." I forked your repo and enabled chromium logging but nothing additional shows up in the logs.

Based on this I made the assumption this library has been used in a Docker container in some form or fashion. Is my Docker container perhaps missing some necessary packages?

DRF Renderer Class

Requested by /u/kennydude on Reddit

Implement a Renderer class which renders PDF and returns them as a FileResponse when ?format=pdf.

Unlike other renderer classes, this will require setting a template that receives the Serializers output as context.

Plans to deal with future deprecation of the --print-to-pdf command arg

@ckinsey

Issue:

  • currently using --print-to-pdf[4] gets the job done but it appears that in the future this will be deprecated [0] [1] , based on my reading of the linked discussion threads.
  • given this future removal is there any plans to move towards using pychrome [2] or other devtool python wrappers that would be able to replicate this functionality?
  • using pychrome or other devtool wrapper would also have a big side benefit of allowing developers to access a lot more functionality provided by the print to pdf [3] as well.

Resources:

[0] https://superuser.com/questions/1281309/how-can-i-print-a-webpage-in-landscape-mode-using-headless-chromium-on-the-comma/1281535#1281535
[1] It is likely that this will lead to deprecation (and eventual removal) of --headless mode command line flags such as --print-to-pdf or --screenshot.
[2] https://github.com/fate0/pychrome
[3] https://chromedevtools.github.io/devtools-protocol/tot/Page/#method-printToPDF
[4] https://github.com/loftylabs/django-hardcopy/blob/master/hardcopy/__init__.py#L31-L34

Security flaw with default settings

The arg --no-sandbox is hardcoded in the get_chrome_args() and can't be overwritten easily. This setting is a huge security flaw. Please make sure that we can override this and remove it from the default settings.

def get_chrome_args(): return [ settings.CHROME_PATH, '--no-sandbox', # Avoids permission issues while dockerized. '--headless', '--disable-extensions', # Reduces startup overhead. '--disable-gpu', # Required by chrome's headless mode for now. ]

Hide date, url and page count in pdf

Is there a way to remove headers and footers on pages in rendered pdf?
I need margins, but they must be blank.
I tried to make it with css:

@page{
    margin: 0;
    size: auto;
}

but so pages are without margin, that I need.

Is there a some key to call chrome?

tried to combine this solution with wrapping page content into div with styles:

.wrapper{
    margin: 15mm 10mm 15mm 15mm; 
}

but this helps only for first and last pages. pages between looks like they have no top and bottom margins.

Project Branching Strategy & Roadmap

I'd like to take a more active role in contribution and wanted to know if we could setup some sort of branching strategy. (Master < Release < Develop < Feature) ... Where Master would represent the active version on PyPI.

Also, having goals in mind and move towards ... Some Ideas:

  • Dynamic Parsing of Templates (as suggested in README.md)
  • Full Testing Coverage (tricky, but not impossible)
  • Travis CI, Tox, Coveralls

Perhaps would could document this in a CONTRIB.md?

No longer works without snap on Ubuntu OS.

According to this blog post and other sources out there, chromium-browser is no longer usable from the apt-get install method. They're forcing everyone to use snap instead. Trying to run chromium-browser form the apti-get install results in this message in the terminal:

chromium-browser --help              

Command '/usr/bin/chromium-browser' requires the chromium snap to be installed.
Please install it with:

snap install chromium

https://ubuntu.com/blog/chromium-in-ubuntu-deb-to-snap-transition

Test Coverage Needed

With more and more PRs coming in for django-hardcopy, I need to start adding test coverage and would welcome any help.

cleanup of process

When hardcopy is used inside some daemon (i.e. rqworker) and called multiple times, it produces a lot of defunct chromium processes.:

687164 ?        SLs    0:03  \_ /usr/local/bin/python -Wd ./manage.py rqworker higher
714982 ?        Z      0:00      \_ [chromium] <defunct>                                                                                                                                                           714983 ?        Z      0:00      \_ [chromium] <defunct>                                                                                                                                                           715003 ?        ZN     0:00      \_ [chromium] <defunct>                                                                                                                                                           718025 ?        Z      0:00      \_ [chromium] <defunct>                                                                                                                                                           718026 ?        Z      0:00      \_ [chromium] <defunct>                                                                                                                                                           718047 ?        ZN     0:00      \_ [chromium] <defunct>                                                                                                                                                           718964 ?        Z      0:00      \_ [chromium] <defunct>                                                                                                                                                           718965 ?        Z      0:00      \_ [chromium] <defunct>                                                                                                                                                           718984 ?        ZN     0:00      \_ [chromium] <defunct>

Is there any way to clean up defunct processes after conversion?

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.