SkPDF:  SkPDFDocument reorganized so that some objects can be serialized early.

No change in output.

BUG=skia:5087
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1802033003

Review URL: https://codereview.chromium.org/1802033003
diff --git a/tests/PDFDocumentTest.cpp b/tests/PDFDocumentTest.cpp
index 995e35f..98d1864 100644
--- a/tests/PDFDocumentTest.cpp
+++ b/tests/PDFDocumentTest.cpp
@@ -33,7 +33,8 @@
 
     doc->abort();
 
-    REPORTER_ASSERT(reporter, stream.bytesWritten() == 0);
+    // Test that only the header is written, not the full document.
+    REPORTER_ASSERT(reporter, stream.bytesWritten() < 256);
 }
 
 static void test_abortWithFile(skiatest::Reporter* reporter) {