示例#1
0
        /// <summary>
        /// Dispatches PrepareForSave to the objects that need it.
        /// </summary>
        internal override void PrepareForSave()
        {
            PdfDocumentInformation info = Info;

            // Set Producer if value is undefined
            if (info.Elements[PdfDocumentInformation.Keys.Producer] == null)
            {
                info.Producer = VersionInfo.Producer;
            }

            // Set Application if value is undefined
            if (info.Elements[PdfDocumentInformation.Keys.Application] == null)
            {
                info.Application = VersionInfo.Producer;
            }

            // Prepare used fonts
            if (this.fontTable != null)
            {
                this.fontTable.PrepareForSave();
            }

            // Let catalog do the rest
            Catalog.PrepareForSave();

#if true
            // Remove all unreachable objects (e.g. from deleted pages)
            int removed = this.irefTable.Compact();
            if (removed != 0)
            {
                Debug.WriteLine("PrepareForSave: Number of deleted unreachable objects: " + removed);
            }
            this.irefTable.Renumber();
#endif
        }
示例#2
0
        /// <summary>
        /// Dispatches PrepareForSave to the objects that need it.
        /// </summary>
        internal override void PrepareForSave()
        {
            PdfDocumentInformation info = Info;

            // Add patch level to producer if it is not '0'.
            string pdfSharpProducer = VersionInfo.Producer;

            if (!ProductVersionInfo.VersionPatch.Equals("0"))
            {
                pdfSharpProducer = ProductVersionInfo.Producer2;
            }

            // Set Creator if value is undefined.
            if (info.Elements[PdfDocumentInformation.Keys.Creator] == null)
            {
                info.Creator = pdfSharpProducer;
            }

            // Keep original producer if file was imported.
            string producer = info.Producer;

            if (producer.Length == 0)
            {
                producer = pdfSharpProducer;
            }
            else
            {
                // Prevent endless concatenation if file is edited with PDFsharp more than once.
                if (!producer.StartsWith(VersionInfo.Title))
                {
                    producer = pdfSharpProducer + " (Original: " + producer + ")";
                }
            }
            info.Elements.SetString(PdfDocumentInformation.Keys.Producer, producer);

            // Prepare used fonts.
            if (_fontTable != null)
            {
                _fontTable.PrepareForSave();
            }

            // Let catalog do the rest.
            Catalog.PrepareForSave();

#if true
            // Remove all unreachable objects (e.g. from deleted pages)
            int removed = _irefTable.Compact();
            if (removed != 0)
            {
                Debug.WriteLine("PrepareForSave: Number of deleted unreachable objects: " + removed);
            }
            _irefTable.Renumber();
#endif

            // @PDF/UA
            // Create PdfMetadata now to include the final document information in XMP generation.
            Catalog.Elements.SetReference(PdfCatalog.Keys.Metadata, new PdfMetadata(this));
        }
示例#3
0
        /// <summary>
        /// Dispatches PrepareForSave to the objects that need it.
        /// </summary>
        internal override void PrepareForSave()
        {
            PdfDocumentInformation info = Info;

            // Set Creator if value is undefined
            if (info.Elements[PdfDocumentInformation.Keys.Creator] == null)
            {
                info.Creator = VersionInfo.Producer;
            }

            // Keep original producer if file was imported
            string producer = info.Producer;

            if (producer.Length == 0)
            {
                producer = VersionInfo.Producer;
            }
            else
            {
                // Prevent endless concatenation if file is edited with PDFsharp more than once
                if (!producer.StartsWith(VersionInfo.Title))
                {
                    producer = VersionInfo.Producer + " (Original: " + producer + ")";
                }
            }
            info.Elements.SetString(PdfDocumentInformation.Keys.Producer, producer);

            // Prepare used fonts
            if (this.fontTable != null)
            {
                this.fontTable.PrepareForSave();
            }

            // Let catalog do the rest
            Catalog.PrepareForSave();

#if true
            // Remove all unreachable objects (e.g. from deleted pages)
            int removed = this.irefTable.Compact();
            if (removed != 0)
            {
                Debug.WriteLine("PrepareForSave: Number of deleted unreachable objects: " + removed);
            }
            this.irefTable.Renumber();
#endif
        }