コード例 #1
0
ファイル: PdfCreator.cs プロジェクト: jps1974/SaveAsPdf
        public void OutputTrailer()
        {
            FlushOutput();

            foreach (PdfXObject xobj in xObjectsMap.Values)
            {
                resources.AddXObject(xobj);
            }

            xrefTable.Add(doc.Catalog.ObjectId, doc.Writer.Position);
            doc.Writer.WriteLine(doc.Catalog);

            xrefTable.Add(doc.Pages.ObjectId, doc.Writer.Position);
            doc.Writer.WriteLine(doc.Pages);

            foreach (PdfObject o in trailerObjects)
            {
                WritePdfObject(o);
            }

            // output the xref table
            long xrefOffset = doc.Writer.Position;

            xrefTable.Write(doc.Writer);

            // output the file trailer
            PdfFileTrailer trailer = new PdfFileTrailer();

            trailer.Size = new PdfNumeric(doc.ObjectCount + 1);
            trailer.Root = doc.Catalog.GetReference();
            trailer.Id   = doc.FileIdentifier;
            if (info != null)
            {
                trailer.Info = info.GetReference();
            }
            if (info != null && encrypt != null)
            {
                trailer.Encrypt = encrypt.GetReference();
            }
            trailer.XRefOffset = xrefOffset;
            doc.Writer.Write(trailer);
        }
コード例 #2
0
ファイル: PdfCreator.cs プロジェクト: nholik/Fo.Net
        public void outputTrailer()
        {
            output();

            foreach (PdfXObject xobj in xObjectsMap.Values)
            {
                resources.AddXObject(xobj);
            }

            xrefTable.Add(doc.Catalog.ObjectId, doc.Writer.Position);
            doc.Writer.WriteLine(doc.Catalog);

            xrefTable.Add(doc.Pages.ObjectId, doc.Writer.Position);
            doc.Writer.WriteLine(doc.Pages);

            foreach (PdfObject o in trailerObjects)
            {
                WritePdfObject(o);
            }

            // output the xref table
            long xrefOffset = doc.Writer.Position;
            xrefTable.Write(doc.Writer);

            // output the file trailer
            PdfFileTrailer trailer = new PdfFileTrailer();
            trailer.Size = new PdfNumeric(doc.ObjectCount + 1);
            trailer.Root = doc.Catalog.GetReference();
            trailer.Id = doc.FileIdentifier;
            if (info != null)
            {
                trailer.Info = info.GetReference();
            }
            if (info != null && encrypt != null)
            {
                trailer.Encrypt = encrypt.GetReference();
            }
            trailer.XRefOffset = xrefOffset;
            doc.Writer.Write(trailer);
        }