mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
When replacing font references do it in XObjects as well
This commit is contained in:
parent
227679985f
commit
c842a82a0f
@ -46,12 +46,8 @@ ref_as_integer(const PdfReference &ref) { return ref_as_integer(ref.ObjectNumber
|
||||
|
||||
|
||||
static inline void
|
||||
replace_font_references(PDFDoc *self, std::unordered_map<uint64_t, uint64_t> &ref_map) {
|
||||
int num_pages = self->doc->GetPageCount();
|
||||
for (int i = 0; i < num_pages; i++) {
|
||||
PdfPage *page = self->doc->GetPage(i);
|
||||
PdfDictionary &resources = page->GetResources()->GetDictionary();
|
||||
PdfObject* f = resources.GetKey("Font");
|
||||
replace_font_references_in_resources(PdfDictionary &resources, const std::unordered_map<uint64_t, uint64_t> &ref_map) {
|
||||
const PdfObject* f = resources.GetKey("Font");
|
||||
if (f && f->IsDictionary()) {
|
||||
const PdfDictionary &font = f->GetDictionary();
|
||||
PdfDictionary new_font = PdfDictionary(font);
|
||||
@ -68,6 +64,18 @@ replace_font_references(PDFDoc *self, std::unordered_map<uint64_t, uint64_t> &re
|
||||
resources.AddKey("Font", new_font);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
replace_font_references(PDFDoc *self, const std::unordered_map<uint64_t, uint64_t> &ref_map) {
|
||||
const PdfVecObjects &objects = self->doc->GetObjects();
|
||||
for (auto &k : objects) {
|
||||
if (!k->IsDictionary()) continue;
|
||||
PdfDictionary &dict = k->GetDictionary();
|
||||
if (dict.HasKey("Resources") && dict.GetKey("Resources")->IsDictionary()) {
|
||||
PdfDictionary &res = dict.GetKey("Resources")->GetDictionary();
|
||||
replace_font_references_in_resources(res, ref_map);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static bool
|
||||
|
Loading…
x
Reference in New Issue
Block a user