Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
cpdf_npagetooneexporter.h
Go to the documentation of this file.
1
// Copyright 2024 The PDFium Authors
2
// Use of this source code is governed by a BSD-style license that can be
3
// found in the LICENSE file.
4
5
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7
#
ifndef
CORE_FPDFAPI_EDIT_CPDF_NPAGETOONEEXPORTER_H_
8
#
define
CORE_FPDFAPI_EDIT_CPDF_NPAGETOONEEXPORTER_H_
9
10
#
include
<
stddef
.
h
>
11
#
include
<
stdint
.
h
>
12
13
#
include
<
map
>
14
#
include
<
memory
>
15
16
#
include
"core/fpdfapi/edit/cpdf_pageorganizer.h"
17
#
include
"core/fpdfapi/parser/cpdf_stream.h"
18
#
include
"core/fxcrt/bytestring.h"
19
#
include
"core/fxcrt/fx_coordinates.h"
20
#
include
"core/fxcrt/retain_ptr.h"
21
#
include
"core/fxcrt/span.h"
22
#
include
"core/fxcrt/unowned_ptr.h"
23
24
class
CPDF_Document
;
25
class
CPDF_Page;
26
27
struct
XObjectContext
{
28
XObjectContext
();
29
~
XObjectContext
();
30
31
UnownedPtr
<
CPDF_Document
>
dest_doc
;
32
RetainPtr
<CPDF_Stream>
xobject
;
33
};
34
35
// Copies pages from a source document into a destination document. Creates 1
36
// page in the destination document for every N source pages. This class is
37
// intended to be used once via ExportNPagesToOne() and then destroyed.
38
class
CPDF_NPageToOneExporter
final
:
public
CPDF_PageOrganizer
{
39
public
:
40
// Struct that stores sub page origin and scale information. When importing
41
// more than one pages onto the same page, most likely the pages will need to
42
// be scaled down, and scale is in range of (0, 1) exclusive.
43
struct
NupPageSettings
{
44
CFX_PointF
sub_page_start_point
;
45
float
scale
= 0.0f;
46
};
47
48
CPDF_NPageToOneExporter
(
CPDF_Document
* dest_doc,
CPDF_Document
* src_doc);
49
~
CPDF_NPageToOneExporter
();
50
51
// For the pages from the source document with `page_indices` as their page
52
// indices, insert them into the destination document, starting at page index
53
// 0.
54
// `page_indices` is 0-based.
55
// `dest_page_size` is the destination document page dimensions, measured in
56
// PDF "user space" units.
57
// `pages_on_x_axis` and `nPagesOnXAxis` together defines how many source
58
// pages fit on one destination page.
59
bool
ExportNPagesToOne
(pdfium::span<
const
uint32_t> page_indices,
60
const
CFX_SizeF
& dest_page_size,
61
size_t pages_on_x_axis,
62
size_t pages_on_y_axis);
63
64
std
::
unique_ptr
<
XObjectContext
>
CreateXObjectContextFromPage
(
65
int
src_page_index);
66
67
// Helper that generates the content stream for a sub-page. Exposed for
68
// testing.
69
static
ByteString
GenerateSubPageContentStreamForTesting
(
70
const
ByteString
& xobject_name,
71
const
NupPageSettings
& settings);
72
73
private
:
74
// Map page object number to XObject object name.
75
using
PageXObjectMap = std::map<uint32_t, ByteString>;
76
77
// Creates an XObject from `src_page`, or find an existing XObject that
78
// represents `src_page`. The transformation matrix is specified in
79
// `settings`.
80
// Returns the XObject reference surrounded by the transformation matrix.
81
ByteString
AddSubPage(
const
RetainPtr
<CPDF_Page>& src_page,
82
const
NupPageSettings
& settings);
83
84
// Creates an XObject from `src_page`. Updates mapping as needed.
85
// Returns the name of the newly created XObject.
86
ByteString
MakeXObjectFromPage(
RetainPtr
<CPDF_Page> src_page);
87
RetainPtr
<CPDF_Stream> MakeXObjectFromPageRaw(
RetainPtr
<CPDF_Page> src_page);
88
89
// Adds `content` as the Contents key in `dest_page_dict`.
90
// Adds the objects in `xobject_name_to_number_map_` to the XObject
91
// dictionary in `dest_page_dict`'s Resources dictionary.
92
void
FinishPage(
RetainPtr
<
CPDF_Dictionary
> dest_page_dict,
93
const
ByteString
& content);
94
95
// Counter for giving new XObjects unique names.
96
uint32_t object_number_ = 0;
97
98
// Keeps track of created XObjects in the current page.
99
// Map XObject's object name to it's object number.
100
std::map<ByteString, uint32_t> xobject_name_to_number_map_;
101
102
// Mapping of source page object number and XObject name of the entire doc.
103
// If there are multiple source pages that reference the same object number,
104
// they can also share the same created XObject.
105
PageXObjectMap src_page_xobject_map_;
106
};
107
108
#
endif
// CORE_FPDFAPI_EDIT_CPDF_NPAGETOONEEXPORTER_H_
ByteString
fxcrt::ByteString ByteString
Definition
bytestring.h:180
DCHECK
#define DCHECK
Definition
check.h:33
CFX_FloatRect
Definition
fx_coordinates.h:185
CFX_Matrix
Definition
fx_coordinates.h:440
CFX_Matrix::Scale
void Scale(float sx, float sy)
Definition
fx_coordinates.cpp:406
CPDF_Array::const_iterator
std::vector< RetainPtr< CPDF_Object > >::const_iterator const_iterator
Definition
cpdf_array.h:29
CPDF_Dictionary::DictMap
std::map< ByteString, RetainPtr< CPDF_Object >, std::less<> > DictMap
Definition
cpdf_dictionary.h:31
CPDF_Document
Definition
cpdf_document.h:29
CPDF_NPageToOneExporter::ExportNPagesToOne
bool ExportNPagesToOne(pdfium::span< const uint32_t > page_indices, const CFX_SizeF &dest_page_size, size_t pages_on_x_axis, size_t pages_on_y_axis)
Definition
cpdf_npagetooneexporter.cpp:155
CPDF_NPageToOneExporter::GenerateSubPageContentStreamForTesting
static ByteString GenerateSubPageContentStreamForTesting(const ByteString &xobject_name, const NupPageSettings &settings)
Definition
cpdf_npagetooneexporter.cpp:214
CPDF_NPageToOneExporter::CPDF_NPageToOneExporter
CPDF_NPageToOneExporter(CPDF_Document *dest_doc, CPDF_Document *src_doc)
Definition
cpdf_npagetooneexporter.cpp:149
CPDF_NPageToOneExporter::~CPDF_NPageToOneExporter
~CPDF_NPageToOneExporter()
CPDF_NPageToOneExporter::CreateXObjectContextFromPage
std::unique_ptr< XObjectContext > CreateXObjectContextFromPage(int src_page_index)
Definition
cpdf_npagetooneexporter.cpp:290
CPDF_Object
Definition
cpdf_object.h:50
CPDF_PageOrganizer
Definition
cpdf_pageorganizer.h:23
CPDF_PageOrganizer::ClearObjectNumberMap
void ClearObjectNumberMap()
Definition
cpdf_pageorganizer.h:43
CPDF_PageOrganizer::CopyInheritable
static bool CopyInheritable(RetainPtr< CPDF_Dictionary > dest_page_dict, RetainPtr< const CPDF_Dictionary > src_page_dict, const ByteString &key)
Definition
cpdf_pageorganizer.cpp:165
CPDF_PageOrganizer::CPDF_PageOrganizer
CPDF_PageOrganizer(CPDF_Document *dest_doc, CPDF_Document *src_doc)
Definition
cpdf_pageorganizer.cpp:25
CPDF_PageOrganizer::UpdateReference
bool UpdateReference(RetainPtr< CPDF_Object > obj)
Definition
cpdf_pageorganizer.cpp:74
CPDF_PageOrganizer::AddObjectMapping
void AddObjectMapping(uint32_t old_page_obj_num, uint32_t new_page_obj_num)
Definition
cpdf_pageorganizer.h:39
CPDF_PageOrganizer::Init
bool Init()
Definition
cpdf_pageorganizer.cpp:31
fxcrt::ByteString::Format
static ByteString Format(const char *pFormat,...)
Definition
bytestring.cpp:79
fxcrt::ByteString::operator+=
ByteString & operator+=(const char *str)
Definition
bytestring.cpp:182
fxcrt::RetainPtr
Definition
retain_ptr.h:28
fxcrt::UnownedPtr
Definition
unowned_ptr.h:76
pdfium::CFDETextOutLargeBitmapTest
Definition
cfde_textout_unittest.cpp:117
CFX_PointF
CFX_PTemplate< float > CFX_PointF
Definition
fx_coordinates.h:51
CFX_SizeF
CFX_STemplate< float > CFX_SizeF
Definition
fx_coordinates.h:115
FX_SAFE_INT32
pdfium::CheckedNumeric< int32_t > FX_SAFE_INT32
Definition
fx_safe_types.h:15
pdfium::page_object
Definition
page_object.cpp:7
pdfium::page_object::kMediaBox
const char kMediaBox[]
Definition
page_object.cpp:14
pdfium::page_object::kContents
const char kContents[]
Definition
page_object.cpp:19
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
ByteStringView
fxcrt::ByteStringView ByteStringView
Definition
string_view_template.h:325
CPDF_NPageToOneExporter::NupPageSettings
Definition
cpdf_npagetooneexporter.h:43
CPDF_NPageToOneExporter::NupPageSettings::sub_page_start_point
CFX_PointF sub_page_start_point
Definition
cpdf_npagetooneexporter.h:44
CPDF_NPageToOneExporter::NupPageSettings::scale
float scale
Definition
cpdf_npagetooneexporter.h:45
XObjectContext
Definition
cpdf_npagetooneexporter.h:27
XObjectContext::~XObjectContext
~XObjectContext()
XObjectContext::dest_doc
UnownedPtr< CPDF_Document > dest_doc
Definition
cpdf_npagetooneexporter.h:31
XObjectContext::xobject
RetainPtr< CPDF_Stream > xobject
Definition
cpdf_npagetooneexporter.h:32
XObjectContext::XObjectContext
XObjectContext()
qtwebengine
src
3rdparty
chromium
third_party
pdfium
core
fpdfapi
edit
cpdf_npagetooneexporter.h
Generated on
for Qt by
1.18.0