Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(372)

Side by Side Diff: pdf/pdfium/pdfium_engine.cc

Issue 2114583002: Windows: Make it possible to print text with GDI. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "pdf/pdfium/pdfium_engine.h" 5 #include "pdf/pdfium/pdfium_engine.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 #include "third_party/pdfium/public/fpdf_transformpage.h" 56 #include "third_party/pdfium/public/fpdf_transformpage.h"
57 #include "ui/events/keycodes/keyboard_codes.h" 57 #include "ui/events/keycodes/keyboard_codes.h"
58 #include "ui/gfx/geometry/rect.h" 58 #include "ui/gfx/geometry/rect.h"
59 #include "v8/include/v8.h" 59 #include "v8/include/v8.h"
60 60
61 using printing::ConvertUnit; 61 using printing::ConvertUnit;
62 using printing::ConvertUnitDouble; 62 using printing::ConvertUnitDouble;
63 using printing::kPointsPerInch; 63 using printing::kPointsPerInch;
64 using printing::kPixelsPerInch; 64 using printing::kPixelsPerInch;
65 65
66 #if defined(OS_WIN)
67 extern PDFEnsureTypefaceCharactersAccessible g_pdfium_typeface_accessible_func;
68 extern bool g_pdfium_print_text_with_gdi;
69 #endif
70
66 namespace chrome_pdf { 71 namespace chrome_pdf {
67 72
68 namespace { 73 namespace {
69 74
70 const int32_t kPageShadowTop = 3; 75 const int32_t kPageShadowTop = 3;
71 const int32_t kPageShadowBottom = 7; 76 const int32_t kPageShadowBottom = 7;
72 const int32_t kPageShadowLeft = 5; 77 const int32_t kPageShadowLeft = 5;
73 const int32_t kPageShadowRight = 5; 78 const int32_t kPageShadowRight = 5;
74 79
75 const int32_t kPageSeparatorThickness = 4; 80 const int32_t kPageSeparatorThickness = 4;
(...skipping 3755 matching lines...) Expand 10 before | Expand all | Expand 10 after
3831 FPDFBitmap_Destroy(bitmap); 3836 FPDFBitmap_Destroy(bitmap);
3832 } else { 3837 } else {
3833 FPDF_RenderPage(dc, page, dest.x(), dest.y(), dest.width(), dest.height(), 3838 FPDF_RenderPage(dc, page, dest.x(), dest.y(), dest.width(), dest.height(),
3834 rotate, FPDF_ANNOT | FPDF_PRINTING | FPDF_NO_CATCH); 3839 rotate, FPDF_ANNOT | FPDF_PRINTING | FPDF_NO_CATCH);
3835 } 3840 }
3836 RestoreDC(dc, save_state); 3841 RestoreDC(dc, save_state);
3837 FPDF_ClosePage(page); 3842 FPDF_ClosePage(page);
3838 FPDF_CloseDocument(doc); 3843 FPDF_CloseDocument(doc);
3839 return true; 3844 return true;
3840 } 3845 }
3846
3847 void PDFiumEngineExports::SetPDFEnsureTypefaceCharactersAccessible(
3848 PDFEnsureTypefaceCharactersAccessible func) {
3849 g_pdfium_typeface_accessible_func = func;
3850 }
3851
3852 void PDFiumEngineExports::SetPDFUseGDIPrinting(bool enable) {
3853 g_pdfium_print_text_with_gdi = enable;
3854 }
3841 #endif // defined(OS_WIN) 3855 #endif // defined(OS_WIN)
3842 3856
3843 bool PDFiumEngineExports::RenderPDFPageToBitmap( 3857 bool PDFiumEngineExports::RenderPDFPageToBitmap(
3844 const void* pdf_buffer, 3858 const void* pdf_buffer,
3845 int pdf_buffer_size, 3859 int pdf_buffer_size,
3846 int page_number, 3860 int page_number,
3847 const RenderingSettings& settings, 3861 const RenderingSettings& settings,
3848 void* bitmap_buffer) { 3862 void* bitmap_buffer) {
3849 FPDF_DOCUMENT doc = 3863 FPDF_DOCUMENT doc =
3850 FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, nullptr); 3864 FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, nullptr);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
3912 FPDF_DOCUMENT doc = 3926 FPDF_DOCUMENT doc =
3913 FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, nullptr); 3927 FPDF_LoadMemDocument(pdf_buffer, pdf_buffer_size, nullptr);
3914 if (!doc) 3928 if (!doc)
3915 return false; 3929 return false;
3916 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0; 3930 bool success = FPDF_GetPageSizeByIndex(doc, page_number, width, height) != 0;
3917 FPDF_CloseDocument(doc); 3931 FPDF_CloseDocument(doc);
3918 return success; 3932 return success;
3919 } 3933 }
3920 3934
3921 } // namespace chrome_pdf 3935 } // namespace chrome_pdf
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698