[Webkit-unassigned] [Bug 21933] New: dataWithPDFInsideRect: and CSS background broken

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Oct 28 14:07:23 PDT 2008


https://bugs.webkit.org/show_bug.cgi?id=21933

           Summary: dataWithPDFInsideRect: and CSS background broken
           Product: WebKit
           Version: 525.x (Safari 3.1)
          Platform: Macintosh
        OS/Version: Mac OS X 10.4
            Status: UNCONFIRMED
          Severity: Normal
          Priority: P2
         Component: New Bugs
        AssignedTo: webkit-unassigned at lists.webkit.org
        ReportedBy: webkit at fi-works.de


Mac OS X 10.4.11 ppc, 10.5.5 i386, system WebKit as well as r37894

I'm trying to create a screenshot of a WebView using -[WebView
dataWithPDFInsideRect:]. When used by itself the CSS media "print" will be
used. So I tried the following:

[Code snippet start]

// webView is a valid WebView* which has loaded a web page (see below).
// filePath is a valid path. For example: @"/Users/mike/Desktop/test.pdf".

NSString *savedMediaStyle = [webView mediaStyle];
[webView setMediaStyle:@"screen"];
NSData *data = [webView dataWithPDFInsideRect:[webView bounds]];
[webView setMediaStyle:savedMediaStyle];
[data writeToFile:filePath atomically:YES];

[Code snippet end]

The web page I used for testing had several style sheets, one of which was
included with the attribute media="print".

The result was not what I saw on screen. It seemed like some of the media
"print" CSS was being applied.


After consulting with Darin Adler on WebKitSDK-DEV I constructed a small test
application. I used a minimal HTML file and one external stylesheet
(media="print") for testing. The bug did not show! The same HTML file also
worked fine in my large application.

Then I added another stylesheet which used the background-color CSS property.
This time the bug was reproducable. It also seems to reproduce with the
background-image CSS property.

In a third test I eliminated the first (media="print") stylesheet (keeping the
second one with the background CSS property). Again the bug was reproducable.

A fourth test showed that the bug also reproduces without any external
stylesheets. A minimal HTML file for demonstarting the bug looks like this:
[File: test.html]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8">
        <title>WebKit PDF Bug</title>
        <style type="text/css">
<!--
h1 { background-color: #dfd; }
-->
        </style>
</head>
<body>
        <h1>Normal style</h1>
</body>
</html>
[EOF]

On screen the h1 element has a light green background. The PDF file written by
the above code has a white background.

PS. Is this related to: <https://bugs.webkit.org/show_bug.cgi?id=11992>?


-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.



More information about the webkit-unassigned mailing list