Example #1
0
 public void WriteData(PDFWriter writer)
 {
     if (null == this._value)
     {
         writer.WriteNullS();
     }
     else
     {
         writer.WriteStringLiteralS(this.Value);
     }
 }
Example #2
0
 /// <summary>
 /// Writes the null string to the writer
 /// </summary>
 /// <param name="writer">The writer to write to</param>
 public void WriteData(PDFWriter writer)
 {
     writer.WriteNullS();
 }
Example #3
0
        //
        // methods
        //

        #region public PDFObjectRef OutputToPDF(PDFWriter writer, PDFRenderContext context)

        /// <summary>
        /// Renderes this destination within the current PDFObject stream of the provided writer.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="writer"></param>
        /// <returns></returns>
        public PDFObjectRef OutputToPDF(PDFRenderContext context, PDFWriter writer)
        {
            PDFComponentArrangement arrange;

            arrange = this.GetFirstArrangementInTree(this.Component);

            if (null == arrange)
            {
                //The component does not have an arrangement so cannot output the destination
                writer.WriteNullS();

                if (context.TraceLog.ShouldLog(TraceLevel.Warning))
                {
                    context.TraceLog.Add(TraceLevel.Warning, "Destination", "Destination to component " + this.Component.UniqueID + " cannot be written as it has no arrangement");
                }

                return(null);
            }

            int          pgindex = arrange.PageIndex;
            PDFObjectRef oref    = writer.PageRefs[pgindex];

            if (null == oref)
            {
                //No page, so cannot output the destination
                writer.WriteNullS();

                if (context.TraceLog.ShouldLog(TraceLevel.Warning))
                {
                    context.TraceLog.Add(TraceLevel.Warning, "Destination", "Destination to component " + this.Component.UniqueID + " cannot be written as it has no page reference");
                }

                return(null);
            }

            writer.BeginArray();

            //Write the page reference
            writer.BeginArrayEntry();
            writer.WriteObjectRef(oref);
            writer.EndArrayEntry();

            //Write the page fit method
            switch (this.Fit)
            {
            case OutlineFit.FullPage:
                writer.BeginArrayEntry();
                writer.WriteName("Fit");
                writer.EndArrayEntry();
                break;

            case OutlineFit.PageWidth:
                writer.BeginArrayEntry();
                writer.WriteName("FitH");
                writer.EndArrayEntry();
                break;

            case OutlineFit.PageHeight:
                writer.BeginArrayEntry();
                writer.WriteName("FitV");
                writer.EndArrayEntry();
                break;

            case OutlineFit.BoundingBox:
                writer.BeginArrayEntry();
                writer.WriteName("FitR");
                writer.EndArrayEntry();

                PDFReal left   = arrange.RenderBounds.X.RealValue;
                PDFReal top    = arrange.RenderBounds.Y.RealValue;
                PDFReal right  = left + arrange.RenderBounds.Width.RealValue;
                PDFReal bottom = top + arrange.RenderBounds.Height.RealValue;
                left   = context.Graphics.GetXPosition(left);
                right  = context.Graphics.GetXPosition(right);
                top    = context.Graphics.GetYPosition(top);
                bottom = context.Graphics.GetYPosition(bottom);
                if (bottom < top)
                {
                    PDFReal temp = top;
                    top    = bottom;
                    bottom = temp;
                }

                if (left > right)
                {
                    PDFReal temp = left;
                    left  = right;
                    right = temp;
                }

                writer.BeginArrayEntry();
                left.WriteData(writer);
                writer.EndArrayEntry();

                writer.BeginArrayEntry();
                bottom.WriteData(writer);
                writer.EndArrayEntry();

                writer.BeginArrayEntry();
                right.WriteData(writer);
                writer.EndArrayEntry();

                writer.BeginArrayEntry();
                top.WriteData(writer);
                writer.EndArrayEntry();
                break;

            default:
                break;
            }
            writer.EndArray();

            if (context.ShouldLogVerbose)
            {
                context.TraceLog.Add(TraceLevel.Verbose, "Destination", "Added a destination to component " + this.Component.UniqueID + " with first arrangment on page " + pgindex + " (" + oref + ") with size fit of " + this.Fit);
            }

            return(null);
        }