コード例 #1
0
ファイル: PDFTable.cs プロジェクト: henrim/DoddleReport
        /// <summary>
        /// Add image
        /// </summary>
        /// <param name="inImage">XImage to put into the cell</param>
        /// <param name="bStretch">If bStretch is true inserted image will have the same width with the cell</param>
        /// <returns></returns>
        public int AddImage(XImage inImage, bool inStretch)
        {
            if (inImage != null)
            {
                int    id      = 0;
                string theRect = mDoc.Rect.String;
                mDoc.Rect.Inset(CellPadding, CellPadding);

                double scale = 1;
                if (inStretch)
                {
                    scale = mDoc.Rect.Width / inImage.Width;
                }

                mDoc.Rect.Width = inImage.Width * scale;
                PageNumber      = RowTop.PageNr;

                if (mDoc.Rect.Top - inImage.Height * scale >= mBounds.Bottom)
                {
                    mDoc.Rect.Bottom = mDoc.Rect.Top - inImage.Height * scale;

                    PagePos thePos = new PagePos(this);
                    id      = mDoc.AddImage(inImage);
                    thePos -= inImage.Height * scale;
                    if (thePos < RowBottom)
                    {
                        RowBottom = thePos;
                    }
                    SaveRowObject(id, inImage);
                }
                else
                {
                    MoveRowToNextPage();
                    mDoc.Rect.String = theRect;
                    mDoc.Rect.Top    = RowTop.PosY;
                    id = AddImage(inImage, inStretch);
                }

                mDoc.Rect.String = theRect;
                return(id);
            }
            return(0);
        }
コード例 #2
0
 private Doc AddHeaderFooter(Doc theDoc)
 {
     int theCount = theDoc.PageCount;
     int i = 0;
     //This block add Header
     BindPDFInfoData();
     string theFont = "Helvetica-Bold";
     theDoc.Font = theDoc.AddFont(theFont);
     theDoc.FontSize = 10;
     string imgPath = Server.MapPath(CredentialLogoURL);
     for (i = 1; i <= theCount; i++)
     {
         theDoc.PageNumber = i;
         theDoc.Rect.String = "10 750 490 777";
         theDoc.HPos = 0.5;
         theDoc.VPos = 0.4;
         theDoc.AddText(CredentialHeaderText);
         if (i == 1)
         {
             theDoc.Rect.String = "500 730 600 775";
             if (File.Exists(imgPath))
             {
                 theDoc.AddImage(imgPath);
             }
             else
             {
                 imgPath = Server.MapPath("~/Images" + "/CredentialLogo.jpg");
                 if (File.Exists(imgPath))
                     theDoc.AddImage(imgPath);
             }
             //SetImageWidthAndHeight(theDoc);//Do not remove 
         }
         theDoc.Rect.String = "5 10 605 783";
         theDoc.FrameRect();
     }
     //This block add Footer
     for (i = 1; i <= theCount; i++)
     {
         theDoc.PageNumber = i;
         theDoc.Rect.String = "10 10 500 60";
         theDoc.HPos = 0.5;
         theDoc.VPos = 0.5;
         theDoc.FontSize = 10;
         theDoc.AddText(CredentialFooterText);
         theDoc.Rect.String = "500 10 590 60";
         theDoc.HPos = 0.5;
         theDoc.VPos = 0.5;
         theDoc.FontSize = 8;
         theDoc.AddText("Page " + i + " of " + theCount); //Setting page number  
     }
     return theDoc;
 }