1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "printing/printed_document.h"
7 #import <ApplicationServices/ApplicationServices.h>
8 #import <CoreFoundation/CoreFoundation.h>
10 #include "base/logging.h"
11 #include "base/scoped_cftyperef.h"
12 #include "printing/page_number.h"
13 #include "printing/printed_page.h"
17 void PrintedDocument::RenderPrintedPage(
18 const PrintedPage
& page
, gfx::NativeDrawingContext context
) const {
21 // Make sure the page is from our list.
23 DCHECK(&page
== mutable_
.pages_
.find(page
.page_number() - 1)->second
.get());
27 const printing::PageSetup
& page_setup(
28 immutable_
.settings_
.page_setup_device_units());
29 gfx::Rect content_area
;
30 page
.GetCenteredPageContentRect(page_setup
.physical_size(), &content_area
);
32 const printing::NativeMetafile
* metafile
= page
.native_metafile();
33 // Each NativeMetafile is a one-page PDF, and pages use 1-based indexing.
34 const int page_number
= 1;
35 metafile
->RenderPage(page_number
, context
, content_area
.ToCGRect(),
36 true, false, false, false);
38 // TODO(stuartmorgan): Print the header and footer.
41 } // namespace printing