Message from discussion
WebPrintAPI Proposal
Received: by 10.68.202.168 with SMTP id kj8mr4742396pbc.1.1333319176787;
Sun, 01 Apr 2012 15:26:16 -0700 (PDT)
Path: r9ni7857pbh.0!nntp.google.com!news2.google.com!news1.google.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.mozilla.org!news.mozilla.org.POSTED!not-for-mail
NNTP-Posting-Date: Sun, 01 Apr 2012 17:26:15 -0500
Return-Path: <rocalla...@gmail.com>
X-Original-To: dev-tech-lay...@lists.mozilla.org
Delivered-To: dev-tech-lay...@lists.mozilla.org
X-Virus-Scanned: amavisd-new at mozilla.org
Authentication-Results: notorious.mozilla.org (amavisd-new); dkim=pass
header...@gmail.com
Received-SPF: pass (gmail.com ... _spf.google.com: 209.85.212.176 is
authorized to use 'rocalla...@gmail.com' in 'mfrom' identity
(mechanism 'ip4:209.85.128.0/17' matched))
receiver=notorious.mozilla.org; identity=mailfrom;
envelope-from="rocalla...@gmail.com";
helo=mail-wi0-f176.google.com; client-ip=209.85.212.176
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
h=mime-version:reply-to:sender:in-reply-to:references:date
:x-google-sender-auth:message-id:subject:from:to:cc:content-type;
bh=cyODQo+43HU6IpxjJ0JTMJQW0S/yUYm+DjXTH8vQ5XI=;
b=GZtftWMbbSoFE17upbvEFueKJoIYzqcFYKBXWarEXfoz096SkUn4ExDk7RSCdSU5cl
bJYGCE6D2XVWjN0yNIN4aGZkd6wT6brtG6zqHmhvV4nN8mz+I9LRwC5AfW4p6pp1VfTh
kPnT/sO48lT/opIkIdSpwOvpLm69NwUvJUDciZINaOL79ZvPLU0oNIWX4cp1LQud9bCu
ib01/wawGUWz4EMSO4nW3/Ik7XgzyS8uIX6w89suz3B2TdH6ctlmKlURCveVjH7iAol3
zAf2NcFvBnAdbtKJjvCFCZIEeYHDJKISHfP1Eayn/kumTkIGlqyDrvCcOFQQRRrNAiiu
5Mng==
MIME-Version: 1.0
Sender: rocalla...@gmail.com
In-Reply-To: <F051DFCF-EC08-4B88-A036-97B2BF0FD67C@gmail.com>
References: <15A1A459-4358-4FAB-ABC4-ED6909133766@gmail.com>
<CAOp6jLaqsp_MO=GYUseQG1w7Qp9+2nRX8gMa5SV2Twu7H+yqtw@mail.gmail.com>
<F4A88E3D-BA69-4E89-9C2C-671D306A6722@gmail.com>
<CAOp6jLZJ7w_3mR87Vo0i7=ctKZg1X1d+SdeiqCo2D1W8w2ci9Q@mail.gmail.com>
<mailman.15333.1331821920.31724.dev-tech-layout@lists.mozilla.org>
<33079878.924.1332284012359.JavaMail.geo-discussion-forums@vbck9>
<mailman.16637.1332296004.31724.dev-tech-lay...@lists.mozilla.org>
<9341138.290.1332968343559.JavaMail.geo-discussion-forums@vbyk7>
<CAOp6jLZu=DWYEU7_vNR968C6_NmLhny8nwtkocGrLFvVWK6...@mail.gmail.com>
<F051DFCF-EC08-4B88-A036-97B2BF0FD...@gmail.com>
Date: Mon, 2 Apr 2012 10:26:07 +1200
Subject: Re: WebPrintAPI Proposal
From: "Robert O'Callahan" <rob...@ocallahan.org>
To: Julian Viereck <julian.vier...@googlemail.com>
X-Content-Filtered-By: Mailman/MimeDel 2.1.14
Cc: dev-tech-lay...@lists.mozilla.org
X-BeenThere: dev-tech-lay...@lists.mozilla.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: rob...@ocallahan.org
List-Id: Web page layout <dev-tech-layout.lists.mozilla.org>
List-Unsubscribe: <https://lists.mozilla.org/options/dev-tech-layout>,
<mailto:dev-tech-layout-requ...@lists.mozilla.org?subject=unsubscribe>
List-Post: <mailto:dev-tech-lay...@lists.mozilla.org>
List-Help: <mailto:dev-tech-layout-requ...@lists.mozilla.org?subject=help>
List-Subscribe: <https://lists.mozilla.org/listinfo/dev-tech-layout>,
<mailto:dev-tech-layout-requ...@lists.mozilla.org?subject=subscribe>
Newsgroups: mozilla.dev.tech.layout
Message-ID: <mailman.18612.1333319175.31724.dev-tech-lay...@lists.mozilla.org>
Lines: 123
X-Usenet-Provider: http://www.giganews.com
NNTP-Posting-Host: 63.245.208.166
X-AuthenticatedUsername: NoAuthUser
X-Trace: sv3-ivYY57Kdxhj9YgNXvKvolSO+WRXgt8s6yPjGv1QFwZiNqAQ4w5dZLEWWbbCAR6g4caFfguPfFyk04Oa!WKyOWcthcrI3gGvz24qHdJfukteXZPKT9NU4AMFE6CLjgCHmuM8ADtBw8hHxw2Tv9X6getrYIevp!i+wXWXEA1uTcA9jubS8gpAxchHYianJB8ztq8ZSY
X-Complaints-To: ab...@mozilla.org
X-DMCA-Complaints-To: ab...@mozilla.org
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
X-Original-Bytes: 8399
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
On Sun, Apr 1, 2012 at 6:16 AM, Julian Viereck <
julian.vier...@googlemail.com> wrote:
> The second argument might look like this:
>
> sndArgument =3D {
> DPI: 200,
> preview: false
> };
>
> It's intended to expose more print related information to the user.
>
Hmm. Can you explain this a bit more?
> -- Is there a way to figure out the DPI resolution of the printout in C++=
?
>>
>
> Yes, cairo_surface_get_fallback_resolution. You should add a wrapper to
> gfxContext to return it.
>
>
> cairo_surface_get_fallback_resolution requires a cairo surface. Therefore
> I've added a new `GetFallbackResolution` on the gfxASurface class.
>
> Calling this function always return 300 by 300 pixels per inch. That's
> independent of the print quality I set on my printer or wether I choose
> "Save as PDF". The cairo documentation states
>
> "This function returns the previous fallback resolution set
> by cairo_surface_set_fallback_resolution(), or default fallback resolutio=
n
> if never set."
>
> Therefore I'm wondering if this is really related to the actual DPI of th=
e
> printer or just picks up some default value.
>
We probably need to set it somewhere.
> -- How can one figure out the actual size of the canvas when printed to
>> paper? I guess I can get some size-information from the CanvasFrame, but=
is
>> that the actual/resulting size on paper?
>>
>
> When printing, CSS units are rendered as physical units if the zoom facto=
r
> is 100%. Each CSS px is 1/96 of an inch. Changing the zoom factor will
> change this of course.
>
> What do you need this for?
>
>
> Imagine you print a canvas that contains some computed image data. If you
> know the actual size of the canvas on the paper and the DPI resolution, o=
ne
> can compute what dimension the image data has to be in order to look good
> on the printout (e.g. if you don't compute a high enough resolution, the
> user will see pixels in the printout).
>
> Even in the case that the DPI of the printer might not be determinable,
> using 300DPI as the default value and multiply it by the size would still
> give a good guess what the image data size has to be.
>
I see. What sort of image data computation are we talking about? Probably
the proposed getImageData extensions, or some other API to get the actual
DPI of the canvas, would cover this.
I've played around with some CSS units (code in [1], resulting PDF in [2]).
> The "mm"-size used for the ctx.font has nothing to do with the actual
> printout size. This feels consistent to me and therefore right, as it
> renders to the same size/way the DOM canvas does, but it can confuse peop=
le
> that expect to get really 5mm on the printout.
>
> What's the way it should be?
>
I see what you mean. The problem is that setting the CSS width and height
of the canvas scales "canvas units", and the font size you specify is in
canvas units.
Changing this would make printing behave differently from normal drawing,
so we probably shouldn't change anything by default.
I looked into this today. I moved the code to swap the surface and call the
> mozPrintCallback function from the nsSimplePageSequence::
> PrintNextPage() into the nsPageFrame::paintPageContent function. Within
> preview the mozPrintCallback gets called now as well.
>
> However, the drawing looks pixeled (like it does without calling the
> callback/printing a normal canvas) and not like the print/"Save as PDF" a=
t
> high/vector resolution. I did a
>
> std::cout << "SurfaceType: " << printSurface->GetType();
>
> and it states the type is the same for printing and print preview.
>
We shouldn't switch the canvas type here, that's just wasteful (since
internally we'd render to a PDF surface or something and then render that
to a raster surface). Print preview should use the same canvas type as
normal screen drawing.
What we really need to do here is render to a higher-resolution backing
surface of the screen type. That's going to require a bit more canvas work.
Rob
--=20
=E2=80=9CYou have heard that it was said, =E2=80=98Love your neighbor and h=
ate your enemy.=E2=80=99
But I tell you, love your enemies and pray for those who persecute you,
that you may be children of your Father in heaven. ... If you love those
who love you, what reward will you get? Are not even the tax collectors
doing that? And if you greet only your own people, what are you doing more
than others?" [Matthew 5:43-47]