////////////////////////////////////////////////////////////////////
        // Define Tiling Pattern Resource
        ////////////////////////////////////////////////////////////////////
        private void DefineTilingPatternResource(
			PdfDocument Document
			)
        {
            // create empty tiling pattern
            WaterMark = new PdfTilingPattern(Document);

            // the pattern will be PdfFileWriter laied out in brick pattern
            String Mark = "PdfFileWriter";

            // text width and height for Arial bold size 18 points
            Double FontSize = 18.0;
            Double TextWidth = ArialBold.TextWidth(FontSize, Mark);
            Double TextHeight = ArialBold.LineSpacing(FontSize);

            // text base line
            Double BaseLine = ArialBold.DescentPlusLeading(FontSize);

            // the overall pattern box (we add text height value as left and right text margin)
            Double BoxWidth = TextWidth + 2 * TextHeight;
            Double BoxHeight = 4 * TextHeight;
            WaterMark.SetTileBox(BoxWidth, BoxHeight);

            // save graphics state
            WaterMark.SaveGraphicsState();

            // fill the pattern box with background light blue color
            WaterMark.SetColorNonStroking(Color.FromArgb(230, 244, 255));
            WaterMark.DrawRectangle(0, 0, BoxWidth, BoxHeight, PaintOp.Fill);

            // set fill color for water mark text to white
            WaterMark.SetColorNonStroking(Color.White);

            // draw PdfFileWriter at the bottom center of the box
            WaterMark.DrawText(ArialBold, FontSize, BoxWidth / 2, BaseLine, TextJustify.Center, Mark);

            // adjust base line upward by half height
            BaseLine += BoxHeight / 2;

            // draw the right half of PdfFileWriter shifted left by half width
            WaterMark.DrawText(ArialBold, FontSize, 0.0, BaseLine, TextJustify.Center, Mark);

            // draw the left half of PdfFileWriter shifted right by half width
            WaterMark.DrawText(ArialBold, FontSize, BoxWidth, BaseLine, TextJustify.Center, Mark);

            // restore graphics state
            WaterMark.RestoreGraphicsState();
            return;
        }
示例#2
0
        // Define Tiling Pattern Resource
        private void DefineTilingPatternResource()
        {
            // create empty tiling pattern
            WaterMark = new PdfTilingPattern(Document);
            WaterMarkToPDF = new PdfTilingPattern(DocumentToPDF);

            // the pattern will be PdfFileWriter layed out in brick pattern
            String Mark = "PdfFileWriter";

            // text width and height for Arial bold size 18 points
            Double FontSize = 18.0;
            Double TextWidth = ArialBold.TextWidth(FontSize, Mark);
            Double TextHeight = ArialBold.LineSpacing(FontSize);

            // text base line
            Double BaseLine = ArialBold.DescentPlusLeading(FontSize);

            // the overall pattern box (we add text height value as left and right text margin)
            Double BoxWidth = TextWidth + 2 * TextHeight;
            Double BoxHeight = 4 * TextHeight;

            WaterMark.SetTileBox(BoxWidth, BoxHeight);
            WaterMark.SaveGraphicsState();
            WaterMark.SetColorNonStroking(Color.FromArgb(230, 244, 255));
            WaterMark.DrawRectangle(0, 0, BoxWidth, BoxHeight, PaintOp.Fill);
            WaterMark.SetColorNonStroking(Color.White);
            WaterMark.DrawText(ArialBold, FontSize, BoxWidth / 2, BaseLine, TextJustify.Center, Mark);

            WaterMarkToPDF.SetTileBox(BoxWidth, BoxHeight);
            WaterMarkToPDF.SaveGraphicsState();
            WaterMarkToPDF.SetColorNonStroking(Color.FromArgb(230, 244, 255));
            WaterMarkToPDF.DrawRectangle(0, 0, BoxWidth, BoxHeight, PaintOp.Fill);
            WaterMarkToPDF.SetColorNonStroking(Color.White);
            WaterMarkToPDF.DrawText(ArialBold, FontSize, BoxWidth / 2, BaseLine, TextJustify.Center, Mark);

            BaseLine += BoxHeight / 2;

            WaterMark.DrawText(ArialBold, FontSize, 0.0, BaseLine, TextJustify.Center, Mark);
            WaterMark.DrawText(ArialBold, FontSize, BoxWidth, BaseLine, TextJustify.Center, Mark);
            WaterMark.RestoreGraphicsState();

            WaterMarkToPDF.DrawText(ArialBold, FontSize, 0.0, BaseLine, TextJustify.Center, Mark);
            WaterMarkToPDF.DrawText(ArialBold, FontSize, BoxWidth, BaseLine, TextJustify.Center, Mark);
            WaterMarkToPDF.RestoreGraphicsState();

            return;
        }
 private void DefineTilingPatternResource()
 {
     WaterMark = new PdfTilingPattern(Document);
     String Mark = "PdfFileWriter";
     Double FontSize = 18.0;
     Double TextWidth = ArialBold.TextWidth(FontSize, Mark);
     Double TextHeight = ArialBold.LineSpacing(FontSize);
     Double BaseLine = ArialBold.DescentPlusLeading(FontSize);
     Double BoxWidth = TextWidth + 2 * TextHeight;
     Double BoxHeight = 4 * TextHeight;
     WaterMark.SetTileBox(BoxWidth, BoxHeight);
     WaterMark.SaveGraphicsState();
     WaterMark.SetColorNonStroking(Color.FromArgb(230, 244, 255));
     WaterMark.DrawRectangle(0, 0, BoxWidth, BoxHeight, PaintOp.Fill);
     WaterMark.SetColorNonStroking(Color.White);
     WaterMark.DrawText(ArialBold, FontSize, BoxWidth / 2, BaseLine, TextJustify.Center, Mark);
     BaseLine += BoxHeight / 2;
     WaterMark.DrawText(ArialBold, FontSize, 0.0, BaseLine, TextJustify.Center, Mark);
     WaterMark.DrawText(ArialBold, FontSize, BoxWidth, BaseLine, TextJustify.Center, Mark);
     WaterMark.RestoreGraphicsState();
     return;
 }