/// <summary> /// Replaces the token in an internal cache that will be returned instead of /// scanning the source PDF data for future requests. /// </summary> /// <param name="reference">The object number for the object to replace.</param> /// <param name="replacer">Func that takes existing token as input and return new token.</param> public void ReplaceIndirectObject(IndirectReference reference, Func <IToken, IToken> replacer) { var obj = pdfScanner.Get(reference); var replacement = replacer(obj.Data); pdfScanner.ReplaceToken(reference, replacement); }
/// <summary> /// Retrieve the tokenized object with the specified object reference number. /// </summary> /// <param name="reference">The object reference number.</param> /// <returns>The tokenized PDF object from the file.</returns> public ObjectToken GetObject(IndirectReference reference) { return(TokenScanner.Get(reference)); }
/// <summary> /// Replaces the token in an internal cache that will be returned instead of /// scanning the source PDF data for future requests. /// </summary> /// <param name="reference">The object number for the object to replace.</param> /// <param name="replacement">Replacement token to use.</param> public void ReplaceIndirectObject(IndirectReference reference, IToken replacement) { pdfScanner.ReplaceToken(reference, replacement); }
/// <summary> /// Retrieve the tokenized object with the specified object reference number. /// </summary> /// <param name="reference">The object reference number.</param> /// <returns>The tokenized PDF object from the file.</returns> public ObjectToken GetObject(IndirectReference reference) { return(TokenScanner.Get(reference) ?? throw new InvalidOperationException($"Could not find the object with reference: {reference}.")); }