7#include "core/fpdfapi/parser/cfdf_document.h"
13#include "core/fpdfapi/parser/cpdf_dictionary.h"
14#include "core/fpdfapi/parser/cpdf_syntax_parser.h"
15#include "core/fpdfapi/parser/fpdf_parser_utility.h"
16#include "core/fxcrt/cfx_read_only_span_stream.h"
17#include "core/fxcrt/fx_string_wrappers.h"
18#include "third_party/base/containers/span.h"
24std::unique_ptr<CFDF_Document> CFDF_Document::CreateNewDoc() {
25 auto pDoc =
std::make_unique<CFDF_Document>();
26 pDoc->m_pRootDict = pDoc->NewIndirect<CPDF_Dictionary>();
27 pDoc->m_pRootDict->SetNewFor<CPDF_Dictionary>(
"FDF");
31std::unique_ptr<CFDF_Document> CFDF_Document::ParseMemory(
32 pdfium::span<
const uint8_t> span) {
33 auto pDoc =
std::make_unique<CFDF_Document>();
34 pDoc->ParseStream(pdfium::MakeRetain<CFX_ReadOnlySpanStream>(span));
35 return pDoc->m_pRootDict ?
std::move(pDoc) :
nullptr;
39 m_pFile = std::move(pFile);
44 uint32_t objnum = FXSYS_atoui(word_result.word.c_str());
53 if (word_result.word !=
"obj")
62 if (word_result.word !=
"endobj")
65 if (word_result.word !=
"trailer")
69 ToDictionary(parser.GetObjectBody(
this));
71 m_pRootDict = pMainDict->GetMutableDictFor(
"Root");
82 fxcrt::ostringstream buf;
83 buf <<
"%FDF-1.2\r\n";
84 for (
const auto& pair : *
this)
85 buf << pair.first <<
" 0 obj\r\n"
86 << pair.second.Get() <<
"\r\nendobj\r\n\r\n";
88 buf <<
"trailer\r\n<</Root " << m_pRootDict->GetObjNum()
89 <<
" 0 R>>\r\n%%EOF\r\n";
91 return ByteString(buf);
~CFDF_Document() override
ByteString WriteToString() const
bool ReplaceIndirectObjectIfHigherGeneration(uint32_t objnum, RetainPtr< CPDF_Object > pObj)