OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/printing/print_job.h" | 5 #include "chrome/browser/printing/print_job.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 | 311 |
312 // Update the rendered document. It will send notifications to the listener. | 312 // Update the rendered document. It will send notifications to the listener. |
313 document_->SetPage(pdf_page_mapping_[page_number], std::move(metafile), | 313 document_->SetPage(pdf_page_mapping_[page_number], std::move(metafile), |
314 scale_factor, pdf_conversion_state_->page_size(), | 314 scale_factor, pdf_conversion_state_->page_size(), |
315 pdf_conversion_state_->content_area()); | 315 pdf_conversion_state_->content_area()); |
316 | 316 |
317 pdf_conversion_state_->GetMorePages( | 317 pdf_conversion_state_->GetMorePages( |
318 base::Bind(&PrintJob::OnPdfPageConverted, this)); | 318 base::Bind(&PrintJob::OnPdfPageConverted, this)); |
319 } | 319 } |
320 | 320 |
| 321 void PrintJob::StartPdfToTextConversion( |
| 322 const scoped_refptr<base::RefCountedMemory>& bytes, |
| 323 const gfx::Size& page_size) { |
| 324 DCHECK(!pdf_conversion_state_); |
| 325 pdf_conversion_state_ = |
| 326 base::MakeUnique<PdfConversionState>(gfx::Size(), gfx::Rect()); |
| 327 const int kPrinterDpi = settings().dpi(); |
| 328 gfx::Rect page_area = gfx::Rect(0, 0, page_size.width(), page_size.height()); |
| 329 PdfRenderSettings settings(page_area, gfx::Point(0, 0), kPrinterDpi, |
| 330 /*autorotate=*/true, |
| 331 PdfRenderSettings::Mode::TEXTONLY); |
| 332 pdf_conversion_state_->Start( |
| 333 bytes, settings, base::Bind(&PrintJob::OnPdfConversionStarted, this)); |
| 334 } |
| 335 |
321 void PrintJob::StartPdfToPostScriptConversion( | 336 void PrintJob::StartPdfToPostScriptConversion( |
322 const scoped_refptr<base::RefCountedMemory>& bytes, | 337 const scoped_refptr<base::RefCountedMemory>& bytes, |
323 const gfx::Rect& content_area, | 338 const gfx::Rect& content_area, |
324 const gfx::Point& physical_offsets, | 339 const gfx::Point& physical_offsets, |
325 bool ps_level2) { | 340 bool ps_level2) { |
326 DCHECK(!pdf_conversion_state_); | 341 DCHECK(!pdf_conversion_state_); |
327 pdf_conversion_state_ = base::MakeUnique<PdfConversionState>( | 342 pdf_conversion_state_ = base::MakeUnique<PdfConversionState>( |
328 gfx::Size(), gfx::Rect()); | 343 gfx::Size(), gfx::Rect()); |
329 const int kPrinterDpi = settings().dpi(); | 344 const int kPrinterDpi = settings().dpi(); |
330 PdfRenderSettings settings( | 345 PdfRenderSettings settings( |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 : document_(document), page_(page), type_(type), job_id_(job_id) {} | 488 : document_(document), page_(page), type_(type), job_id_(job_id) {} |
474 | 489 |
475 JobEventDetails::~JobEventDetails() { | 490 JobEventDetails::~JobEventDetails() { |
476 } | 491 } |
477 | 492 |
478 PrintedDocument* JobEventDetails::document() const { return document_.get(); } | 493 PrintedDocument* JobEventDetails::document() const { return document_.get(); } |
479 | 494 |
480 PrintedPage* JobEventDetails::page() const { return page_.get(); } | 495 PrintedPage* JobEventDetails::page() const { return page_.get(); } |
481 | 496 |
482 } // namespace printing | 497 } // namespace printing |
OLD | NEW |