protected virtual void AddSharedObjectsToBody()
{
// add the fonts
foreach (FontDetails details in documentFonts.Values) {
details.WriteFont(this);
}
// add the form XObjects
AddXFormsToBody();
// add all the dependencies in the imported pages
foreach (PdfReaderInstance rd in readerInstances.Values) {
currentPdfReaderInstance = rd;
currentPdfReaderInstance.WriteAllPages();
}
currentPdfReaderInstance = null;
// add the color
foreach (ColorDetails color in documentColors.Values) {
AddToBody(color.GetSpotColor(this), color.IndirectReference);
}
// add the pattern
foreach (PdfPatternPainter pat in documentPatterns.Keys) {
AddToBody(pat.GetPattern(compressionLevel), pat.IndirectReference);
}
// add the shading patterns
foreach (PdfShadingPattern shadingPattern in documentShadingPatterns.Keys) {
shadingPattern.AddToBody();
}
// add the shadings
foreach (PdfShading shading in documentShadings.Keys) {
shading.AddToBody();
}
// add the extgstate
foreach (KeyValuePair<PdfDictionary, PdfObject[]> entry in documentExtGState) {
PdfDictionary gstate = entry.Key;
PdfObject[] obj = entry.Value;
AddToBody(gstate, (PdfIndirectReference)obj[1]);
}
// add the properties
foreach (KeyValuePair<Object, PdfObject[]> entry in documentProperties) {
Object prop = entry.Key;
PdfObject[] obj = entry.Value;
if (prop is PdfLayerMembership){
PdfLayerMembership layer = (PdfLayerMembership)prop;
AddToBody(layer.PdfObject, layer.Ref);
}
else if ((prop is PdfDictionary) && !(prop is PdfLayer)){
AddToBody((PdfDictionary)prop, (PdfIndirectReference)obj[1]);
}
}
}