summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp23
-rw-r--r--fpdfsdk/fpdfeditimg_unittest.cpp1
2 files changed, 15 insertions, 9 deletions
diff --git a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp
index ad1ffaf687..20b4ea6eaf 100644
--- a/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp
+++ b/core/fpdfapi/edit/cpdf_pagecontentgenerator.cpp
@@ -94,16 +94,21 @@ void CPDF_PageContentGenerator::ProcessImage(CFX_ByteTextBuf& buf,
return;
}
buf << "q " << pImageObj->m_Matrix << " cm ";
+
CPDF_Image* pImage = pImageObj->GetImage();
- if (!pImage->IsInline()) {
- CPDF_Stream* pStream = pImage->GetStream();
- uint32_t dwSavedObjNum = pStream->GetObjNum();
- CFX_ByteString name = RealizeResource(pStream, "XObject");
- if (dwSavedObjNum == 0) {
- pImageObj->SetUnownedImage(m_pDocument->GetPageData()->GetImage(pStream));
- }
- buf << "/" << PDF_NameEncode(name) << " Do Q\n";
- }
+ if (pImage->IsInline())
+ return;
+
+ CPDF_Stream* pStream = pImage->GetStream();
+ if (!pStream)
+ return;
+
+ bool bWasInline = pStream->IsInline();
+ CFX_ByteString name = RealizeResource(pStream, "XObject");
+ if (bWasInline)
+ pImageObj->SetUnownedImage(m_pDocument->GetPageData()->GetImage(pStream));
+
+ buf << "/" << PDF_NameEncode(name) << " Do Q\n";
}
void CPDF_PageContentGenerator::ProcessForm(CFX_ByteTextBuf& buf,
diff --git a/fpdfsdk/fpdfeditimg_unittest.cpp b/fpdfsdk/fpdfeditimg_unittest.cpp
index a844e7ec71..ae4af2591e 100644
--- a/fpdfsdk/fpdfeditimg_unittest.cpp
+++ b/fpdfsdk/fpdfeditimg_unittest.cpp
@@ -43,6 +43,7 @@ TEST_F(PDFEditTest, NewImgeObj) {
FPDF_PAGEOBJECT page_image = FPDFPageObj_NewImgeObj(doc);
FPDFPage_InsertObject(page, page_image);
EXPECT_EQ(1, FPDFPage_CountObject(page));
+ EXPECT_TRUE(FPDFPage_GenerateContent(page));
FPDF_ClosePage(page);
FPDF_CloseDocument(doc);