예제 #1
0
        public async Task CloseAsync(PdfIndirectObject root, PdfIndirectObject info)
        {
            var xrefTableOffset = _stream.Position;

            await WriteXrefTableAsync();
            await WriteTailerAsync(xrefTableOffset, root, info);

            _stream.Close();
        }
예제 #2
0
        private async Task WriteTailerAsync(long xrefTableOffset, PdfIndirectObject root, PdfIndirectObject info)
        {
            var dictionary = new PdfDictionary(new Dictionary <string, PdfObject>());

            dictionary.Add("Size", _xrefEntries.Count);
            dictionary.Add("Root", root.Reference);
            if (info != null)
            {
                dictionary.Add("Info", new PdfIndirectObjectReference(info));
            }

            await _stream.WriteAsync(Encoding.ASCII.GetBytes("trailer\n"));

            await dictionary.WriteAsync(_stream);

            await _stream.WriteAsync(PdfSpec.NewLine);

            await _stream.WriteAsync(Encoding.ASCII.GetBytes("startxref\n"));

            await new PdfInteger(xrefTableOffset).WriteAsync(_stream);
            await _stream.WriteAsync(PdfSpec.NewLine);

            await _stream.WriteAsync(Encoding.ASCII.GetBytes("%%EOF\n"));
        }
 public PdfIndirectObjectReference(PdfIndirectObject value)
 {
     Value = value;
 }