Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 void STDCALL FPDF_SetPrintPostscriptLevel(int postscript_level) { | |
| 445 g_pdfium_print_postscript_level = postscript_level; | |
|
Tom Sepez
2017/01/09 20:18:20
Do we want to validate this and return an error if
rbpotter
2017/01/10 20:28:24
Done.
| |
| 446 } | |
| 447 #endif // defined(_WIN32) | |
| 442 | 448 |
| 443 DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path, | 449 DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadDocument(FPDF_STRING file_path, |
| 444 FPDF_BYTESTRING password) { | 450 FPDF_BYTESTRING password) { |
| 445 // NOTE: the creation of the file needs to be by the embedder on the | 451 // NOTE: the creation of the file needs to be by the embedder on the |
| 446 // other side of this API. | 452 // other side of this API. |
| 447 CFX_RetainPtr<IFX_SeekableReadStream> pFileAccess = | 453 CFX_RetainPtr<IFX_SeekableReadStream> pFileAccess = |
| 448 IFX_SeekableReadStream::CreateFromFilename((const FX_CHAR*)file_path); | 454 IFX_SeekableReadStream::CreateFromFilename((const FX_CHAR*)file_path); |
| 449 if (!pFileAccess) | 455 if (!pFileAccess) |
| 450 return nullptr; | 456 return nullptr; |
| 451 | 457 |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 649 int rotate, | 655 int rotate, |
| 650 int flags) { | 656 int flags) { |
| 651 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); | 657 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); |
| 652 if (!pPage) | 658 if (!pPage) |
| 653 return; | 659 return; |
| 654 | 660 |
| 655 CPDF_PageRenderContext* pContext = new CPDF_PageRenderContext; | 661 CPDF_PageRenderContext* pContext = new CPDF_PageRenderContext; |
| 656 pPage->SetRenderContext(pdfium::WrapUnique(pContext)); | 662 pPage->SetRenderContext(pdfium::WrapUnique(pContext)); |
| 657 | 663 |
| 658 std::unique_ptr<CFX_DIBitmap> pBitmap; | 664 std::unique_ptr<CFX_DIBitmap> pBitmap; |
| 665 // TODO: This results in unnecessary rasterization of some PDFs due to | |
| 666 // HasImageMask() returning true. If any image on the page is a mask, the | |
| 667 // entire page gets rasterized and the spool size gets huge. | |
| 659 const bool bNewBitmap = | 668 const bool bNewBitmap = |
| 660 pPage->BackgroundAlphaNeeded() || pPage->HasImageMask(); | 669 pPage->BackgroundAlphaNeeded() || pPage->HasImageMask(); |
| 661 if (bNewBitmap) { | 670 if (bNewBitmap) { |
| 662 pBitmap = pdfium::MakeUnique<CFX_DIBitmap>(); | 671 pBitmap = pdfium::MakeUnique<CFX_DIBitmap>(); |
| 663 pBitmap->Create(size_x, size_y, FXDIB_Argb); | 672 pBitmap->Create(size_x, size_y, FXDIB_Argb); |
| 664 pBitmap->Clear(0x00ffffff); | 673 pBitmap->Clear(0x00ffffff); |
| 665 CFX_FxgeDevice* pDevice = new CFX_FxgeDevice; | 674 CFX_FxgeDevice* pDevice = new CFX_FxgeDevice; |
| 666 pContext->m_pDevice = pdfium::WrapUnique(pDevice); | 675 pContext->m_pDevice = pdfium::WrapUnique(pDevice); |
| 667 pDevice->Attach(pBitmap.get(), false, nullptr, false); | 676 pDevice->Attach(pBitmap.get(), false, nullptr, false); |
| 668 } else { | 677 } else { |
| (...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1222 if (!buffer) { | 1231 if (!buffer) { |
| 1223 *buflen = len; | 1232 *buflen = len; |
| 1224 } else if (len <= *buflen) { | 1233 } else if (len <= *buflen) { |
| 1225 memcpy(buffer, utf16Name.c_str(), len); | 1234 memcpy(buffer, utf16Name.c_str(), len); |
| 1226 *buflen = len; | 1235 *buflen = len; |
| 1227 } else { | 1236 } else { |
| 1228 *buflen = -1; | 1237 *buflen = -1; |
| 1229 } | 1238 } |
| 1230 return (FPDF_DEST)pDestObj; | 1239 return (FPDF_DEST)pDestObj; |
| 1231 } | 1240 } |
| OLD | NEW |