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

Unified Diff: pdf/pdfium/pdfium_engine.cc

Issue 376083002: Export a function from the PDF plugin to get the dimensions of a PDF page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
« pdf/pdfium/pdfium_engine.h ('K') | « pdf/pdfium/pdfium_engine.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pdf/pdfium/pdfium_engine.cc
diff --git a/pdf/pdfium/pdfium_engine.cc b/pdf/pdfium/pdfium_engine.cc
index c012dec606898062532c979cb4cd9adbee77d5c6..a72c410240f266c5fe06981efac188ea0149bf32 100644
--- a/pdf/pdfium/pdfium_engine.cc
+++ b/pdf/pdfium/pdfium_engine.cc
@@ -136,19 +136,6 @@ struct PDFFontSubstitution {
bool italic;
};
-PP_BrowserFont_Trusted_Weight WeightToBrowserFontTrustedWeight(int weight) {
Lei Zhang 2014/07/09 02:10:48 Why is this code deleted?
- COMPILE_ASSERT(PP_BROWSERFONT_TRUSTED_WEIGHT_100 == 0,
- PP_BrowserFont_Trusted_Weight_Min);
- COMPILE_ASSERT(PP_BROWSERFONT_TRUSTED_WEIGHT_900 == 8,
- PP_BrowserFont_Trusted_Weight_Max);
- const int kMinimumWeight = 100;
- const int kMaximumWeight = 900;
- int normalized_weight =
- std::min(std::max(weight, kMinimumWeight), kMaximumWeight);
- normalized_weight = (normalized_weight / 100) - 1;
- return static_cast<PP_BrowserFont_Trusted_Weight>(normalized_weight);
-}
-
// This list is for CPWL_FontMap::GetDefaultFontByCharset().
// We pretend to have these font natively and let the browser (or underlying
// fontconfig) to pick the proper font on the system.
@@ -234,9 +221,6 @@ void* MapFont(struct _FPDF_SYSFONTINFO*, int weight, int italic,
// TODO(kochi): Pass the face in UTF-8. If face is not encoded in UTF-8,
// convert to UTF-8 before passing.
description.set_face(face);
-
- description.set_weight(WeightToBrowserFontTrustedWeight(weight));
- description.set_italic(italic > 0);
}
if (!pp::PDF::IsAvailable()) {
@@ -3400,4 +3384,19 @@ bool PDFiumEngineExports::GetPDFDocInfo(const void* pdf_buffer,
return true;
}
+bool PDFiumEngineExports::GetPDFPageSizeByIndex(
+ const void* pdf_buffer,
+ int buffer_size,
+ int index,
+ double* width,
+ double* height) {
+ FPDF_DOCUMENT doc = FPDF_LoadMemDocument(pdf_buffer, buffer_size, NULL);
+ bool success = false;
Lei Zhang 2014/07/09 02:10:48 Can you try following my suggested pattern? There'
+ if (!doc)
+ return success;
+ success = FPDF_GetPageSizeByIndex(doc, index, width, height) != 0;
+ FPDF_CloseDocument(doc);
+ return success;
+}
+
} // namespace chrome_pdf
« pdf/pdfium/pdfium_engine.h ('K') | « pdf/pdfium/pdfium_engine.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698