blob: cc671e13d2d37760ad8ba332f81ff9642a56d4f6 [file] [log] [blame]
[email protected]b5cf844c2012-06-18 21:49:201// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]b75dca82009-10-13 18:46:212// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "printing/printed_document.h"
6
7#import <ApplicationServices/ApplicationServices.h>
8#import <CoreFoundation/CoreFoundation.h>
9
10#include "base/logging.h"
[email protected]b75dca82009-10-13 18:46:2111#include "printing/page_number.h"
12#include "printing/printed_page.h"
13
14namespace printing {
15
16void PrintedDocument::RenderPrintedPage(
17 const PrintedPage& page, gfx::NativeDrawingContext context) const {
18#ifndef NDEBUG
19 {
20 // Make sure the page is from our list.
[email protected]20305ec2011-01-21 04:55:5221 base::AutoLock lock(lock_);
[email protected]b75dca82009-10-13 18:46:2122 DCHECK(&page == mutable_.pages_.find(page.page_number() - 1)->second.get());
23 }
24#endif
25
[email protected]3b52c982010-09-27 20:40:3626 DCHECK(context);
27
[email protected]d91db112011-10-18 20:58:5128 const PageSetup& page_setup(immutable_.settings_.page_setup_device_units());
[email protected]a12552b02010-07-05 06:45:2129 gfx::Rect content_area;
30 page.GetCenteredPageContentRect(page_setup.physical_size(), &content_area);
[email protected]b75dca82009-10-13 18:46:2131
[email protected]d91db112011-10-18 20:58:5132 const Metafile* metafile = page.metafile();
[email protected]7d7489902011-04-11 21:54:0633 // Each Metafile is a one-page PDF, and pages use 1-based indexing.
[email protected]b75dca82009-10-13 18:46:2134 const int page_number = 1;
[email protected]b5cf844c2012-06-18 21:49:2035 struct Metafile::MacRenderPageParams params;
36 params.autorotate = true;
37 metafile->RenderPage(page_number, context, content_area.ToCGRect(), params);
[email protected]e0598782010-10-07 22:01:5238}
39
[email protected]b75dca82009-10-13 18:46:2140} // namespace printing