/// <summary>Flushes all modified objects which have not been flushed yet.</summary> /// <remarks>Flushes all modified objects which have not been flushed yet. Used in case incremental updates.</remarks> /// <param name="forbiddenToFlush"> /// a /// <see cref="Java.Util.Set{E}"/> /// of /// <see cref="PdfIndirectReference">references</see> /// that are forbidden to be flushed automatically. /// </param> protected internal virtual void FlushModifiedWaitingObjects(ICollection <PdfIndirectReference> forbiddenToFlush ) { PdfXrefTable xref = document.GetXref(); for (int i = 1; i < xref.Size(); i++) { PdfIndirectReference indirectReference = xref.Get(i); if (null != indirectReference && !indirectReference.IsFree() && !forbiddenToFlush.Contains(indirectReference )) { bool isModified = indirectReference.CheckState(PdfObject.MODIFIED); if (isModified) { PdfObject obj = indirectReference.GetRefersTo(false); if (obj != null) { if (!obj.Equals(objectStream)) { obj.Flush(); } } } } } if (objectStream != null && objectStream.GetSize() > 0) { objectStream.Flush(); objectStream = null; } }
/// <summary>Flushes all objects which have not been flushed yet.</summary> /// <param name="forbiddenToFlush"> /// a /// <see cref="Java.Util.Set{E}"/> /// of /// <see cref="PdfIndirectReference">references</see> /// that are forbidden to be flushed automatically. /// </param> protected internal virtual void FlushWaitingObjects(ICollection <PdfIndirectReference> forbiddenToFlush) { PdfXrefTable xref = document.GetXref(); bool needFlush = true; while (needFlush) { needFlush = false; for (int i = 1; i < xref.Size(); i++) { PdfIndirectReference indirectReference = xref.Get(i); if (indirectReference != null && !indirectReference.IsFree() && indirectReference.CheckState(PdfObject.MUST_BE_FLUSHED ) && !forbiddenToFlush.Contains(indirectReference)) { PdfObject obj = indirectReference.GetRefersTo(false); if (obj != null) { obj.Flush(); needFlush = true; } } } } if (objectStream != null && objectStream.GetSize() > 0) { objectStream.Flush(); objectStream = null; } }
public virtual void CheckNumberOfIndirectObjectsWithRandomNumbersTest() { PdfXrefTable table = new PdfXrefTable(); int numberOfReferences = 10; for (int i = 0; i < numberOfReferences; i++) { table.Add(new PdfIndirectReference(null, i * 25)); } NUnit.Framework.Assert.AreEqual(numberOfReferences, table.GetCountOfIndirectObjects()); NUnit.Framework.Assert.AreEqual(226, table.Size()); }
/// <summary>Flushes all modified objects which have not been flushed yet.</summary> /// <remarks>Flushes all modified objects which have not been flushed yet. Used in case incremental updates.</remarks> protected internal virtual void FlushModifiedWaitingObjects() { PdfXrefTable xref = document.GetXref(); for (int i = 1; i < xref.Size(); i++) { PdfIndirectReference indirectReference = xref.Get(i); if (null != indirectReference) { PdfObject obj = indirectReference.GetRefersTo(false); if (obj != null && !obj.Equals(objectStream) && obj.IsModified()) { obj.Flush(); } } } if (objectStream != null && objectStream.GetSize() > 0) { objectStream.Flush(); objectStream = null; } }