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

Side by Side Diff: fpdfsdk/fpdfview.cpp

Issue 2612243005: Add postscript path (Closed)
Patch Set: Get rid of extra declarations Created 3 years, 11 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
« no previous file with comments | « core/fxge/win32/fx_win32_print.cpp ('k') | public/fpdfview.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium 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 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "public/fpdfview.h" 7 #include "public/fpdfview.h"
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 break; 422 break;
423 } 423 }
424 SetLastError(err_code); 424 SetLastError(err_code);
425 } 425 }
426 426
427 DLLEXPORT void STDCALL FPDF_SetSandBoxPolicy(FPDF_DWORD policy, 427 DLLEXPORT void STDCALL FPDF_SetSandBoxPolicy(FPDF_DWORD policy,
428 FPDF_BOOL enable) { 428 FPDF_BOOL enable) {
429 return FSDK_SetSandBoxPolicy(policy, enable); 429 return FSDK_SetSandBoxPolicy(policy, enable);
430 } 430 }
431 431
432 #if defined(_WIN32) && defined(PDFIUM_PRINT_TEXT_WITH_GDI) 432 #if defined(_WIN32)
433 #if defined(PDFIUM_PRINT_TEXT_WITH_GDI)
433 DLLEXPORT void STDCALL 434 DLLEXPORT void STDCALL
434 FPDF_SetTypefaceAccessibleFunc(PDFiumEnsureTypefaceCharactersAccessible func) { 435 FPDF_SetTypefaceAccessibleFunc(PDFiumEnsureTypefaceCharactersAccessible func) {
435 g_pdfium_typeface_accessible_func = func; 436 g_pdfium_typeface_accessible_func = func;
436 } 437 }
437 438
438 DLLEXPORT void STDCALL FPDF_SetPrintTextWithGDI(FPDF_BOOL use_gdi) { 439 DLLEXPORT void STDCALL FPDF_SetPrintTextWithGDI(FPDF_BOOL use_gdi) {
439 g_pdfium_print_text_with_gdi = !!use_gdi; 440 g_pdfium_print_text_with_gdi = !!use_gdi;
440 } 441 }
441 #endif 442 #endif // PDFIUM_PRINT_TEXT_WITH_GDI
443
444 DLLEXPORT FPDF_BOOL STDCALL FPDF_SetPrintPostscriptLevel(int postscript_level) {
445 if (postscript_level != 0 && postscript_level != 2 && postscript_level != 3)
446 return FALSE;
447 g_pdfium_print_postscript_level = postscript_level;
448 return TRUE;
449 }
450 #endif // defined(_WIN32)
442 451
443 DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path, 452 DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path,
444 FPDF_BYTESTRING password) { 453 FPDF_BYTESTRING password) {
445 // NOTE: the creation of the file needs to be by the embedder on the 454 // NOTE: the creation of the file needs to be by the embedder on the
446 // other side of this API. 455 // other side of this API.
447 CFX_RetainPtr<IFX_SeekableReadStream> pFileAccess = 456 CFX_RetainPtr<IFX_SeekableReadStream> pFileAccess =
448 IFX_SeekableReadStream::CreateFromFilename((const FX_CHAR*)file_path); 457 IFX_SeekableReadStream::CreateFromFilename((const FX_CHAR*)file_path);
449 if (!pFileAccess) 458 if (!pFileAccess)
450 return nullptr; 459 return nullptr;
451 460
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 int rotate, 658 int rotate,
650 int flags) { 659 int flags) {
651 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); 660 CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
652 if (!pPage) 661 if (!pPage)
653 return; 662 return;
654 663
655 CPDF_PageRenderContext* pContext = new CPDF_PageRenderContext; 664 CPDF_PageRenderContext* pContext = new CPDF_PageRenderContext;
656 pPage->SetRenderContext(pdfium::WrapUnique(pContext)); 665 pPage->SetRenderContext(pdfium::WrapUnique(pContext));
657 666
658 std::unique_ptr<CFX_DIBitmap> pBitmap; 667 std::unique_ptr<CFX_DIBitmap> pBitmap;
668 // TODO: This results in unnecessary rasterization of some PDFs due to
669 // HasImageMask() returning true. If any image on the page is a mask, the
670 // entire page gets rasterized and the spool size gets huge.
659 const bool bNewBitmap = 671 const bool bNewBitmap =
660 pPage->BackgroundAlphaNeeded() || pPage->HasImageMask(); 672 pPage->BackgroundAlphaNeeded() || pPage->HasImageMask();
661 if (bNewBitmap) { 673 if (bNewBitmap) {
662 pBitmap = pdfium::MakeUnique<CFX_DIBitmap>(); 674 pBitmap = pdfium::MakeUnique<CFX_DIBitmap>();
663 pBitmap->Create(size_x, size_y, FXDIB_Argb); 675 pBitmap->Create(size_x, size_y, FXDIB_Argb);
664 pBitmap->Clear(0x00ffffff); 676 pBitmap->Clear(0x00ffffff);
665 CFX_FxgeDevice* pDevice = new CFX_FxgeDevice; 677 CFX_FxgeDevice* pDevice = new CFX_FxgeDevice;
666 pContext->m_pDevice = pdfium::WrapUnique(pDevice); 678 pContext->m_pDevice = pdfium::WrapUnique(pDevice);
667 pDevice->Attach(pBitmap.get(), false, nullptr, false); 679 pDevice->Attach(pBitmap.get(), false, nullptr, false);
668 } else { 680 } else {
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
1222 if (!buffer) { 1234 if (!buffer) {
1223 *buflen = len; 1235 *buflen = len;
1224 } else if (len <= *buflen) { 1236 } else if (len <= *buflen) {
1225 memcpy(buffer, utf16Name.c_str(), len); 1237 memcpy(buffer, utf16Name.c_str(), len);
1226 *buflen = len; 1238 *buflen = len;
1227 } else { 1239 } else {
1228 *buflen = -1; 1240 *buflen = -1;
1229 } 1241 }
1230 return (FPDF_DEST)pDestObj; 1242 return (FPDF_DEST)pDestObj;
1231 } 1243 }
OLDNEW
« no previous file with comments | « core/fxge/win32/fx_win32_print.cpp ('k') | public/fpdfview.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698