示例#1
0
        private void PDFCombineAll(string basedName, Data.ONNotebook notebook)
        {
            if (notebook == null)
            {
                throw new ArgumentNullException("notebook");
            }

            if (!InitDocument(Path.Combine(basedName, notebook.Name) + ".pdf"))
            {
                return;
            }

            TOCHandler.Init(pdfDocument, pdfWriter);

            PdfOutline root = pdfWriter.DirectContent.RootOutline;

            TOCHandler.BeginTocEntry();
            foreach (Data.ONSection section in notebook.Sections)
            {
                if (!section.Exclude)
                {
                    TOCHandler.AddTocEntry(section.Name, pdfWriter.CurrentPageNumber);
                    TOCHandler.BeginTocEntry();
                    PDFCombineSection(root, section);
                    TOCHandler.EndTocEntry();
                }
            }
            TOCHandler.EndTocEntry();

            TOCHandler.WriteTocEntries();
            TOCHandler.Close();
            CloseDocument();
        }
示例#2
0
        private void PDFMergeAll(string basedName, ONSection sec)
        {
            if (sec == null)
            {
                throw new ArgumentNullException("sec");
            }
            if (sec.Exclude)
            {
                Log.Warning("Trying to export the excluding section. Abort!");
                return;
            }

            if (!InitDocument(Path.Combine(basedName, sec.Name) + ".pdf"))
            {
                return;
            }
            TOCHandler.Init(pdfDocument, pdfWriter);

            TOCHandler.BeginTocEntry();
            PDFCombineSection(pdfWriter.DirectContent.RootOutline, sec);
            TOCHandler.EndTocEntry();

            TOCHandler.WriteTocEntries();
            TOCHandler.Close();
            CloseDocument();
        }
示例#3
0
        private void PDFCombineSection(PdfOutline parent,
                                       Data.ONSection section)
        {
            if (section == null)
            {
                throw new ArgumentNullException("section");
            }
            if (section.Exclude)
            {
                return;
            }

            PdfOutline gotoPage = null;

            int       currentPage = (pdfWriter.CurrentPageNumber == 1) ? pdfWriter.CurrentPageNumber : (pdfWriter.CurrentPageNumber + 1);
            PdfAction action      = PdfAction.GotoLocalPage(currentPage, new PdfDestination(PdfDestination.FITH, 806), pdfWriter);

            gotoPage = new PdfOutline(parent, action, section.Name);
            pdfWriter.DirectContent.AddOutline(gotoPage);

            foreach (Data.ONSection subSection in section.SubSections)
            {
                if (!subSection.Exclude)
                {
                    TOCHandler.AddTocEntry(subSection.Name, pdfWriter.CurrentPageNumber);

                    TOCHandler.BeginTocEntry();
                    PDFCombineSection(gotoPage, subSection);
                    TOCHandler.EndTocEntry();
                }
            }
            foreach (Data.ONPage page in section.Pages)
            {
                if (pdfWriter.CurrentPageNumber == 1)
                {
                    TOCHandler.AddTocEntry(page.Name, pdfWriter.CurrentPageNumber);
                }
                else
                {
                    TOCHandler.AddTocEntry(page.Name, pdfWriter.CurrentPageNumber + 1);
                }
                PDFCombinePage(gotoPage, page);
            }
        }