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

Unified Diff: printing/common/pdf_metafile_utils.cc

Issue 2832633002: Add PDF compositor service (Closed)
Patch Set: rebase Created 3 years, 7 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
« no previous file with comments | « printing/common/pdf_metafile_utils.h ('k') | printing/pdf_metafile_skia.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: printing/common/pdf_metafile_utils.cc
diff --git a/printing/common/pdf_metafile_utils.cc b/printing/common/pdf_metafile_utils.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3a30ad0018d6c32e37a5a7a161c93d52c345cefd
--- /dev/null
+++ b/printing/common/pdf_metafile_utils.cc
@@ -0,0 +1,46 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "printing/common/pdf_metafile_utils.h"
+
+#include "base/time/time.h"
+#include "third_party/skia/include/core/SkTime.h"
+
+namespace {
+
+SkTime::DateTime TimeToSkTime(base::Time time) {
+ base::Time::Exploded exploded;
+ time.UTCExplode(&exploded);
+ SkTime::DateTime skdate;
+ skdate.fTimeZoneMinutes = 0;
+ skdate.fYear = exploded.year;
+ skdate.fMonth = exploded.month;
+ skdate.fDayOfWeek = exploded.day_of_week;
+ skdate.fDay = exploded.day_of_month;
+ skdate.fHour = exploded.hour;
+ skdate.fMinute = exploded.minute;
+ skdate.fSecond = exploded.second;
+ return skdate;
+}
+
+} // namespace
+
+namespace printing {
+
+sk_sp<SkDocument> MakePdfDocument(const std::string& creator,
+ SkWStream* stream) {
+ SkDocument::PDFMetadata metadata;
+ SkTime::DateTime now = TimeToSkTime(base::Time::Now());
+ metadata.fCreation.fEnabled = true;
+ metadata.fCreation.fDateTime = now;
+ metadata.fModified.fEnabled = true;
+ metadata.fModified.fDateTime = now;
+ metadata.fCreator = creator.empty()
+ ? SkString("Chromium")
+ : SkString(creator.c_str(), creator.size());
+ return SkDocument::MakePDF(stream, SK_ScalarDefaultRasterDPI, metadata,
+ nullptr, false);
+}
+
+} // namespace printing
« no previous file with comments | « printing/common/pdf_metafile_utils.h ('k') | printing/pdf_metafile_skia.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698