OLD | NEW |
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "core/fpdfapi/fpdf_edit/include/cpdf_pagecontentgenerator.h" | 7 #include "core/fpdfapi/fpdf_edit/include/cpdf_pagecontentgenerator.h" |
8 | 8 |
9 #include "core/fpdfapi/fpdf_edit/include/cpdf_creator.h" | 9 #include "core/fpdfapi/fpdf_edit/include/cpdf_creator.h" |
10 #include "core/fpdfapi/fpdf_page/include/cpdf_image.h" | 10 #include "core/fpdfapi/fpdf_page/include/cpdf_image.h" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 if (!data || !size) { | 108 if (!data || !size) { |
109 return; | 109 return; |
110 } | 110 } |
111 CPDF_Stream* pStream = new CPDF_Stream(NULL, 0, NULL); | 111 CPDF_Stream* pStream = new CPDF_Stream(NULL, 0, NULL); |
112 CPDF_Dictionary* pFormDict = new CPDF_Dictionary; | 112 CPDF_Dictionary* pFormDict = new CPDF_Dictionary; |
113 pFormDict->SetAtName("Type", "XObject"); | 113 pFormDict->SetAtName("Type", "XObject"); |
114 pFormDict->SetAtName("Subtype", "Form"); | 114 pFormDict->SetAtName("Subtype", "Form"); |
115 CFX_FloatRect bbox = m_pPage->GetPageBBox(); | 115 CFX_FloatRect bbox = m_pPage->GetPageBBox(); |
116 matrix.TransformRect(bbox); | 116 matrix.TransformRect(bbox); |
117 pFormDict->SetAtRect("BBox", bbox); | 117 pFormDict->SetAtRect("BBox", bbox); |
118 pStream->InitStream((uint8_t*)data, size, pFormDict); | 118 pStream->InitStream(data, size, pFormDict); |
119 buf << "q " << matrix << " cm "; | 119 buf << "q " << matrix << " cm "; |
120 CFX_ByteString name = RealizeResource(pStream, "XObject"); | 120 CFX_ByteString name = RealizeResource(pStream, "XObject"); |
121 buf << "/" << PDF_NameEncode(name) << " Do Q\n"; | 121 buf << "/" << PDF_NameEncode(name) << " Do Q\n"; |
122 } | 122 } |
123 void CPDF_PageContentGenerator::TransformContent(CFX_Matrix& matrix) { | 123 void CPDF_PageContentGenerator::TransformContent(CFX_Matrix& matrix) { |
124 CPDF_Dictionary* pDict = m_pPage->m_pFormDict; | 124 CPDF_Dictionary* pDict = m_pPage->m_pFormDict; |
125 CPDF_Object* pContent = pDict ? pDict->GetDirectObjectBy("Contents") : NULL; | 125 CPDF_Object* pContent = pDict ? pDict->GetDirectObjectBy("Contents") : NULL; |
126 if (!pContent) | 126 if (!pContent) |
127 return; | 127 return; |
128 | 128 |
(...skipping 29 matching lines...) Expand all Loading... |
158 CPDF_StreamAcc contentStream; | 158 CPDF_StreamAcc contentStream; |
159 contentStream.LoadAllData(pStream); | 159 contentStream.LoadAllData(pStream); |
160 ProcessForm(buf, contentStream.GetData(), contentStream.GetSize(), matrix); | 160 ProcessForm(buf, contentStream.GetData(), contentStream.GetSize(), matrix); |
161 } | 161 } |
162 CPDF_Stream* pStream = new CPDF_Stream(NULL, 0, NULL); | 162 CPDF_Stream* pStream = new CPDF_Stream(NULL, 0, NULL); |
163 pStream->SetData(buf.GetBuffer(), buf.GetLength(), FALSE, FALSE); | 163 pStream->SetData(buf.GetBuffer(), buf.GetLength(), FALSE, FALSE); |
164 m_pDocument->AddIndirectObject(pStream); | 164 m_pDocument->AddIndirectObject(pStream); |
165 m_pPage->m_pFormDict->SetAtReference("Contents", m_pDocument, | 165 m_pPage->m_pFormDict->SetAtReference("Contents", m_pDocument, |
166 pStream->GetObjNum()); | 166 pStream->GetObjNum()); |
167 } | 167 } |
OLD | NEW |