Comments (14)
Yes, this would be nice to have. The docs say " See corresponding backend surface docs for details about which MIME types it can handle. " I didn’t find such docs for PDF, but looking through the source shows some signs of supporting JPEG and JPEG2000, so that looks good.
As you say, it’s not on pycairo yet. There are a few options:
- Take this to the cairo mailing-list, wait for someone to feel like doing it, then wait for the next pycairo version.
- Take this to the cairo mailing-list, do it ourselves, then wait for the next pycairo version.
- Do it in C in a separated extension that uses the pycairo C API
- Do it in Cython in a separated extension that uses the pycairo C API
Which do you like most?
from weasyprint.
I don't think 3 or 4 are very good options. I've already written to the cairo mailing-list concerning 1, I'd see what they think before digging into the pycairo implementation myself.
from weasyprint.
Great. I subscribed to the cairo ML, we’ll see how it goes.
from weasyprint.
Actually this shouldn’t be too hard to do in pycairo. Accept any object with the buffer protocol, INCREF it in Surface.set_mime_data (on CAIRO_STATUS_SUCCESS ) and register a destroy callback that does a DECREF.
from weasyprint.
It doesn't seem that anybody on the mailing list is picking up on this.
from weasyprint.
Looks like I spoke too soon.
The function should appear in the next version of pycairo. You could
open a bug report if you want to make sure it is not forgotten, and
submit a patch if you are really keen.
The question is then, when will the next version of pycairo come out. By the looks of it once every year, but then we're overdue atm.
from weasyprint.
I’ll have a go at it unless you want to. Assuming we get a working patch, the question remain of when it will be in a release.
By the way, do you use Python 2 or 3? (py2cairo and pycairo are separate code bases.)
from weasyprint.
I won't have time for at least another month, so by all means have a go.
We're currently on python 2.
from weasyprint.
Is there a patch for it?
from weasyprint.
@liujuncn not yet. The plan goes like this:
- Patch pycairo and py2cairo to add
Surface.set_mime_data()
, exposing cairo’s existing function. - Patch WeasyPrint to use it if available (we still want to support older version of pycairo.)
(I think it’s a bad idea to start 2 speculatively before 1 is done at least in a git version of pycairo.)
I intend to work on this at some point but it’s low-priority for me at the moment. Anyone interested is welcome to start on 1.
from weasyprint.
Hi @liujuncn .
For 1. see the CSS for Paged Media spec. (It’s down at the moment but should be back soon.) At some point I plan on writing some documentation that is more author-friendly than a spec, but it’s not there yet :) In brief: @page { size: A5 portrait; margin: 1cm }
- seems related to #9
However both of your questions are unrelated to this bug. If you have further questions, please start a new issue or write to the mailing list or IRC; keep this about embedding JPEG images in PDF.
from weasyprint.
The patch for pycairo is ready:
SimonSapin/py2cairo@ebe487cabd40a3eac
http://lists.cairographics.org/archives/cairo/2012-December/023839.html
The change in WeasyPrint should be easy. What remains is having a pycairo release.
from weasyprint.
Assuming 1 gets accepted! What in WeazyPrint needs to be modified?
from weasyprint.
@mbarkhau, @liujuncn, @seiflotfy: using WeasyPrint’s git version with the py2cairo patch should Just Work (no change in client code.) Please test :)
Ideally, run the test suite (see docs on the website.) Otherwise test with b'/Filter /DCTDecode' in HTML(…).write_pdf()
from weasyprint.
Related Issues (20)
- Firefox problem on showing the rendered SVG in PDFs HOT 4
- Unexpected numbers appear when rendering a footnote with "float: footnote" HOT 2
- Can not save attached files in Acrobat Reader HOT 3
- Crash 'NoneType' object has no attribute 'getBestCmap' HOT 2
- Page margins being ignored when using a single flexbox column
- Segmentation fault when installed through pyenv (brew's python OK, system python OK) HOT 2
- first image of next page not rendered HOT 6
- Error: 'Node' object has no attribute 'text_bounding_box' (since version 61.0) HOT 5
- cannot load library 'gobject-2.0-0' - windows 10 HOT 3
- gobject-2.0.0 missing using nix on m2 MacOS HOT 4
- Improve import startup time HOT 4
- 'PendingProperty' object is not subscriptable HOT 8
- Page-breaks on grid and flexbox items not behaving properly HOT 2
- Parse error HOT 2
- weasyprint.exe v61.0: cannot use unpack() on <cdata 'char *' NULL> HOT 6
- WeasyPrint Deployment on GCP Failing to Support Multiple Languages in PDF Conversion HOT 1
- WeasyPrint v61.1 executable is apparently recognized as Program:Win32/Wacapew.C!ml HOT 2
- Table (td) doesn't respect max-width and text-overflow HOT 2
- Print warnings when bold or italic fonts are missing HOT 11
- Support CSS Nesting
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 weasyprint.