Пример #1
0
        protected override void InternalGenerate()
        {
            try
            {
                {
                    string title = "Trees Album";//LangMan.LS(LSID.LSID_TreesAlbum)

                    fDocument.AddTitle(title);
                    fDocument.AddSubject("");
                    fDocument.AddAuthor("");
                    fDocument.AddCreator(GKData.APP_TITLE);
                    fDocument.Open();

                    BaseFont baseFont = BaseFont.CreateFont(Environment.ExpandEnvironmentVariables(@"%systemroot%\fonts\Times.ttf"), BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
                    fTitleFont   = new itFont(baseFont, 30f, itFont.BOLD);
                    fChapFont    = new itFont(baseFont, 16f, itFont.BOLD, BaseColor.BLACK);
                    fSubchapFont = new itFont(baseFont, 14f, itFont.BOLD, BaseColor.BLACK);
                    fLinkFont    = new itFont(baseFont, 8f, itFont.UNDERLINE, BaseColor.BLUE);
                    fTextFont    = new itFont(baseFont, 8f, itFont.NORMAL, BaseColor.BLACK);
                    fBoldFont    = new itFont(baseFont, 8f, itFont.BOLD, BaseColor.BLACK);
                    fSymFont     = new itFont(baseFont, 12f, itFont.BOLD, BaseColor.BLACK);

                    float halfpage = (fDocument.Top - fDocument.Bottom - (fTitleFont.Size) * 4) / 2f;
                    fDocument.Add(new Paragraph(Chunk.NEWLINE)
                    {
                        SpacingAfter = halfpage
                    });
                    fDocument.Add(new Paragraph(title, fTitleFont)
                    {
                        Alignment = Element.ALIGN_CENTER
                    });
                    fDocument.NewPage();

                    PreparePatriarchs();

                    var   itPS       = fDocument.PageSize;
                    float pageHeight = itPS.Height;
                    float pageWidth  = itPS.Width;

                    var renderer = new TreeChartPDFRenderer(pageWidth, pageHeight);
                    renderer.SetTarget(fPdfWriter.DirectContent, false);

                    // TODO: replace by local options in TreeChartBox
                    bool prevKinship = GlobalOptions.Instance.ChartOptions.Kinship;
                    GlobalOptions.Instance.ChartOptions.Kinship = false;

                    var treeBox = AppHost.Container.Resolve <ITreeChartBox>();
                    treeBox.SetRenderer(renderer);
                    treeBox.Base       = fBase;
                    treeBox.Options    = GlobalOptions.Instance.ChartOptions;
                    treeBox.DepthLimit = 3;
                    treeBox.Height     = (int)pageHeight;
                    treeBox.Width      = (int)pageWidth;

                    int num = fPatList.Count;
                    for (int i = 0; i < num; i++)
                    {
                        string iName = fPatList[i];
                        GEDCOMIndividualRecord iRec = fPatList.GetObject(i) as GEDCOMIndividualRecord;

                        treeBox.SetScale(1.0f);
                        treeBox.GenChart(iRec, TreeChartKind.ckDescendants, false);

                        ExtSize imageSize   = treeBox.GetImageSize();
                        float   scaleFactor = SysUtils.ZoomToFit(imageSize.Width,
                                                                 imageSize.Height,
                                                                 pageWidth, pageHeight);
                        scaleFactor = (scaleFactor > 1.0f) ? 1.0f : scaleFactor;

                        treeBox.SetScale(scaleFactor);
                        treeBox.RenderStatic(BackgroundMode.bmNone, true);

                        fDocument.NewPage();
                    }

                    GlobalOptions.Instance.ChartOptions.Kinship = prevKinship;
                }
            }
            catch (Exception ex)
            {
                Logger.LogWrite("TreesAlbumExporter.InternalGenerate(): " + ex.Message);
                throw;
            }
        }