/// <summary> /// Mark a slot in the cross-reference table as occupied by an object that has been written to a particular address in the output stream. /// </summary> /// <param name="value">The object to be listed in the table. Its ID must be an ID previously allocated by a call to <see cref="ClaimSlot" />.</param> /// <param name="offset">The address of the object within the output, as a zero-based offset in bytes from the start of the strean.</param> /// <exception cref="ArgumentException">Thrown if the object ID of the value parameter is out of range for this cross-ref table.</exception> /// <exception cref="ArgumentNullException">Thrown if the value parameter is null.</exception> public void SetSlot(IPdfIndirectObject value, int offset) { if (value == null) { throw new ArgumentNullException(nameof(value)); } if (value.ObjectId >= _contents.Count || value.ObjectId < 0) { throw new ArgumentException(Resources.Structural_PdfCrossRefTable_SetSlot_Invalid_ObjectId_Error, nameof(value)); } PdfCrossRefTableEntry entry = new PdfCrossRefTableEntry(value, offset); _contents[value.ObjectId] = entry; }
private int WriteEntry(PdfCrossRefTableEntry entry, Stream stream) { byte[] bytes = Encoding.ASCII.GetBytes(string.Format(CultureInfo.InvariantCulture, "{0:d10} {1:d5} n \xa", entry.Offset, entry.Value.Generation)); stream.Write(bytes, 0, bytes.Length); return(bytes.Length); }