private void Write(PdfIndirectReference indirectReference) { if (document != null && !indirectReference.GetDocument().Equals(document)) { throw new PdfException(PdfException.PdfIndirectObjectBelongsToOtherPdfDocument); } if (indirectReference.IsFree()) { ILog logger = LogManager.GetLogger(typeof(iText.Kernel.Pdf.PdfOutputStream)); logger.Error(iText.IO.LogMessageConstant.FLUSHED_OBJECT_CONTAINS_FREE_REFERENCE); Write(PdfNull.PDF_NULL); } else { if (indirectReference.GetRefersTo() == null) { ILog logger = LogManager.GetLogger(typeof(iText.Kernel.Pdf.PdfOutputStream)); logger.Error(iText.IO.LogMessageConstant.FLUSHED_OBJECT_CONTAINS_REFERENCE_WHICH_NOT_REFER_TO_ANY_OBJECT); Write(PdfNull.PDF_NULL); } else { if (indirectReference.GetGenNumber() == 0) { WriteInteger(indirectReference.GetObjNumber()).WriteBytes(endIndirectWithZeroGenNr); } else { WriteInteger(indirectReference.GetObjNumber()).WriteSpace().WriteInteger(indirectReference.GetGenNumber()) .WriteBytes(endIndirect); } } } }
public virtual SerializedObjectContent SerializeObject(PdfObject obj) { if (!obj.IsStream() && !obj.IsDictionary()) { return(null); } PdfIndirectReference indRef = obj.GetIndirectReference(); System.Diagnostics.Debug.Assert(indRef != null); IDictionary <PdfIndirectReference, byte[]> serializedCache = indRef.GetDocument().serializedObjectsCache; byte[] content = serializedCache.Get(indRef); if (content == null) { ByteBuffer bb = new ByteBuffer(); int level = 100; try { SerObject(obj, bb, level, serializedCache); } catch (SmartModePdfObjectsSerializer.SelfReferenceException) { return(null); } content = bb.ToByteArray(); } return(new SerializedObjectContent(content)); }
/// <summary>Calculates hash code for the indirect reference taking into account the document it belongs to.</summary> /// <param name="indRef">object to be hashed.</param> /// <returns>calculated hash code.</returns> protected internal static int CalculateIndRefKey(PdfIndirectReference indRef) { int result = indRef.GetHashCode(); result = 31 * result + indRef.GetDocument().GetHashCode(); return(result); }
private void Write(PdfIndirectReference indirectReference) { if (document != null && !indirectReference.GetDocument().Equals(document)) { throw new PdfException(PdfException.PdfInderectObjectBelongToOtherPdfDocument); } if (indirectReference.GetRefersTo() == null) { Write(PdfNull.PDF_NULL); } else { if (indirectReference.GetGenNumber() == 0) { WriteInteger(indirectReference.GetObjNumber()).WriteBytes(endIndirectWithZeroGenNr); } else { WriteInteger(indirectReference.GetObjNumber()).WriteSpace().WriteInteger(indirectReference.GetGenNumber()) .WriteBytes(endIndirect); } } }