コード例 #1
0
ファイル: PdfMaker.cs プロジェクト: BloomBooks/BloomDesktop
        ///  <summary>
        ///
        ///  </summary>
        /// <param name="pdfPath">this is the path where it already exists, and the path where we leave the transformed version</param>
        /// <param name="incomingPaperSize"></param>
        /// <param name="booketLayoutMethod"></param>
        /// <param name="layoutPagesForRightToLeft"></param>
        private void MakeBooklet(string pdfPath, string incomingPaperSize, PublishModel.BookletLayoutMethod booketLayoutMethod, bool layoutPagesForRightToLeft)
        {
            //TODO: we need to let the user chose the paper size, as they do in PdfDroplet.
            //For now, just assume a size double the original

            PageSize pageSize;
            switch (incomingPaperSize)
            {
                case "A3":
                    pageSize = PageSize.A2;
                    break;
                case "A4":
                    pageSize = PageSize.A3;
                    break;
                case "A5":
                    pageSize = PageSize.A4;
                    break;
                case "A6":
                    pageSize = PageSize.A5;
                    break;
                case "B5":
                    pageSize = PageSize.B4;
                    break;
                case "Letter":
                    pageSize = PageSize.Ledger;
                    break;
                case "HalfLetter":
                    pageSize = PageSize.Letter;
                    break;
                case "QuarterLetter":
                    pageSize = PageSize.Statement;	// ?? Wikipedia says HalfLetter is aka Statement
                    break;
                case "Legal":
                    pageSize = PageSize.Legal;//TODO... what's reasonable?
                    break;
                case "HalfLegal":
                    pageSize = PageSize.Legal;
                    break;
                default:
                    throw new ApplicationException("PdfMaker.MakeBooklet() does not contain a map from " + incomingPaperSize + " to a PdfSharp paper size.");
            }

            using (var incoming = new TempFile())
            {
                RobustFile.Delete(incoming.Path);
                RobustFile.Move(pdfPath, incoming.Path);

                LayoutMethod method;
                switch (booketLayoutMethod)
                {
                    case PublishModel.BookletLayoutMethod.NoBooklet:
                        method = new NullLayoutMethod();
                        break;
                    case PublishModel.BookletLayoutMethod.SideFold:
                        // To keep the GUI simple, we assume that A6 page size for booklets
                        // implies 4up printing on A4 paper.  This feature was requested by
                        // https://jira.sil.org/browse/BL-1059 "A6 booklets should print 4
                        // to an A4 sheet".  The same is done for QuarterLetter booklets
                        // printing on Letter size sheets.
                        if (incomingPaperSize == "A6")
                        {
                            method = new SideFold4UpBookletLayouter();
                            pageSize = PageSize.A4;
                        }
                        else if (incomingPaperSize == "QuarterLetter")
                        {
                            method = new SideFold4UpBookletLayouter();
                            pageSize = PageSize.Letter;
                        }
                        else
                        {
                            method = new SideFoldBookletLayouter();
                        }
                        break;
                    case PublishModel.BookletLayoutMethod.CutAndStack:
                        method = new CutLandscapeLayout();
                        break;
                    case PublishModel.BookletLayoutMethod.Calendar:
                        method = new CalendarLayouter();
                        break;
                    default:
                        throw new ArgumentOutOfRangeException("booketLayoutMethod");
                }
                var paperTarget = new PaperTarget("ZZ"/*we're not displaying this anyhwere, so we don't need to know the name*/, pageSize);
                var pdf = XPdfForm.FromFile(incoming.Path);//REVIEW: this whole giving them the pdf and the file too... I checked once and it wasn't wasting effort...the path was only used with a NullLayout option
                method.Layout(pdf, incoming.Path, pdfPath, paperTarget, layoutPagesForRightToLeft, ShowCropMarks);
            }
        }
コード例 #2
0
ファイル: PdfMaker.cs プロジェクト: JohnThomson/testBloom
        /// <summary>
        ///
        /// </summary>
        /// <param name="pdfPath">this is the path where it already exists, and the path where we leave the transformed version</param>
        /// <param name="incomingPaperSize"></param>
        /// <param name="booketLayoutMethod"></param>
        private void MakeBooklet(string pdfPath, string incomingPaperSize, PublishModel.BookletLayoutMethod booketLayoutMethod)
        {
            //TODO: we need to let the user chose the paper size, as they do in PdfDroplet.
            //For now, just assume a size double the original

            PageSize pageSize;
            switch (incomingPaperSize)
            {
                case "A3":
                    pageSize = PageSize.A2;
                    break;
                case "A4":
                    pageSize = PageSize.A3;
                    break;
                case "A5":
                    pageSize = PageSize.A4;
                    break;
                case "A6":
                    pageSize = PageSize.A5;
                    break;
                case "B5":
                    pageSize = PageSize.B4;
                    break;
                case "Letter":
                    pageSize = PageSize.Letter;//TODO... what's reasonable?
                    break;
                case "HalfLetter":
                    pageSize = PageSize.Letter;
                    break;
                case "Legal":
                    pageSize = PageSize.Legal;//TODO... what's reasonable?
                    break;
                default:
                    throw new ApplicationException("PdfMaker.MakeBooklet() does not contain a map from " + incomingPaperSize + " to a PdfSharp paper size.");
            }

            using (var incoming = new TempFile())
            {
                File.Delete(incoming.Path);
                File.Move(pdfPath, incoming.Path);

                LayoutMethod method;
                switch(booketLayoutMethod)
                {
                    case PublishModel.BookletLayoutMethod.NoBooklet:
                        method = new NullLayoutMethod();
                        break;
                    case PublishModel.BookletLayoutMethod.SideFold:
                        method = new SideFoldBookletLayouter();
                        break;
                    case PublishModel.BookletLayoutMethod.CutAndStack:
                        method = new CutLandscapeLayout();
                        break;
                    case PublishModel.BookletLayoutMethod.Calendar:
                        method = new CalendarLayouter();
                        break;
                    default:
                        throw new ArgumentOutOfRangeException("booketLayoutMethod");
                }
                var paperTarget = new PaperTarget("ZZ"/*we're not displaying this anyhwere, so we don't need to know the name*/, pageSize);
                var pdf = XPdfForm.FromFile(incoming.Path);//REVIEW: this whole giving them the pdf and the file too... I checked once and it wasn't wasting effort...the path was only used with a NullLayout option
                method.Layout(pdf, incoming.Path, pdfPath, paperTarget, /*TODO: rightToLeft*/ false, ShowCropMarks);
            }
        }
コード例 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pdfPath">this is the path where it already exists, and the path where we leave the transformed version</param>
        /// <param name="incomingPaperSize"></param>
        /// <param name="booketLayoutMethod"></param>
        private void MakeBooklet(string pdfPath, string incomingPaperSize, PublishModel.BookletLayoutMethod booketLayoutMethod)
        {
            //TODO: we need to let the user chose the paper size, as they do in PdfDroplet.
            //For now, just assume a size double the original

            PageSize pageSize;

            switch (incomingPaperSize)
            {
            case "A3":
                pageSize = PageSize.A2;
                break;

            case "A4":
                pageSize = PageSize.A3;
                break;

            case "A5":
                pageSize = PageSize.A4;
                break;

            case "A6":
                pageSize = PageSize.A5;
                break;

            case "B5":
                pageSize = PageSize.B4;
                break;

            case "Letter":
                pageSize = PageSize.Letter;                        //TODO... what's reasonable?
                break;

            case "HalfLetter":
                pageSize = PageSize.Letter;
                break;

            case "Legal":
                pageSize = PageSize.Legal;                        //TODO... what's reasonable?
                break;

            default:
                throw new ApplicationException("PdfMaker.MakeBooklet() does not contain a map from " + incomingPaperSize + " to a PdfSharp paper size.");
            }



            using (var incoming = new TempFile())
            {
                File.Delete(incoming.Path);
                File.Move(pdfPath, incoming.Path);

                LayoutMethod method;
                switch (booketLayoutMethod)
                {
                case PublishModel.BookletLayoutMethod.NoBooklet:
                    method = new NullLayoutMethod();
                    break;

                case PublishModel.BookletLayoutMethod.SideFold:
                    method = new SideFoldBookletLayouter();
                    break;

                case PublishModel.BookletLayoutMethod.CutAndStack:
                    method = new CutLandscapeLayout();
                    break;

                case PublishModel.BookletLayoutMethod.Calendar:
                    method = new CalendarLayouter();
                    break;

                default:
                    throw new ArgumentOutOfRangeException("booketLayoutMethod");
                }
                var paperTarget = new PaperTarget("ZZ" /*we're not displaying this anyhwere, so we don't need to know the name*/, pageSize);
                var pdf         = XPdfForm.FromFile(incoming.Path);        //REVIEW: this whole giving them the pdf and the file too... I checked once and it wasn't wasting effort...the path was only used with a NullLayout option
                method.Layout(pdf, incoming.Path, pdfPath, paperTarget, /*TODO: rightToLeft*/ false, ShowCropMarks);
            }
        }
コード例 #4
0
ファイル: PdfMaker.cs プロジェクト: JohnThomson/BloomDesktop
        ///  <summary>
        ///
        ///  </summary>
        /// <param name="pdfPath">this is the path where it already exists, and the path where we leave the transformed version</param>
        /// <param name="incomingPaperSize"></param>
        /// <param name="booketLayoutMethod"></param>
        /// <param name="layoutPagesForRightToLeft"></param>
        private void MakeBooklet(string pdfPath, string incomingPaperSize, PublishModel.BookletLayoutMethod booketLayoutMethod, bool layoutPagesForRightToLeft)
        {
            //TODO: we need to let the user chose the paper size, as they do in PdfDroplet.
            //For now, just assume a size double the original

            PageSize pageSize;

            switch (incomingPaperSize)
            {
            case "A3":
                pageSize = PageSize.A2;
                break;

            case "A4":
                pageSize = PageSize.A3;
                break;

            case "A5":
                pageSize = PageSize.A4;
                break;

            case "A6":
                pageSize = PageSize.A5;
                break;

            case "B5":
                pageSize = PageSize.B4;
                break;

            case "Letter":
                pageSize = PageSize.Ledger;
                break;

            case "HalfLetter":
                pageSize = PageSize.Letter;
                break;

            case "QuarterLetter":
                pageSize = PageSize.Statement;                          // ?? Wikipedia says HalfLetter is aka Statement
                break;

            case "Legal":
                pageSize = PageSize.Legal;                        //TODO... what's reasonable?
                break;

            case "HalfLegal":
                pageSize = PageSize.Legal;
                break;

            default:
                throw new ApplicationException("PdfMaker.MakeBooklet() does not contain a map from " + incomingPaperSize + " to a PdfSharp paper size.");
            }

            using (var incoming = new TempFile())
            {
                RobustFile.Delete(incoming.Path);
                RobustFile.Move(pdfPath, incoming.Path);

                LayoutMethod method;
                switch (booketLayoutMethod)
                {
                case PublishModel.BookletLayoutMethod.NoBooklet:
                    method = new NullLayoutMethod();
                    break;

                case PublishModel.BookletLayoutMethod.SideFold:
                    // To keep the GUI simple, we assume that A6 page size for booklets
                    // implies 4up printing on A4 paper.  This feature was requested by
                    // https://jira.sil.org/browse/BL-1059 "A6 booklets should print 4
                    // to an A4 sheet".  The same is done for QuarterLetter booklets
                    // printing on Letter size sheets.
                    if (incomingPaperSize == "A6")
                    {
                        method   = new SideFold4UpBookletLayouter();
                        pageSize = PageSize.A4;
                    }
                    else if (incomingPaperSize == "QuarterLetter")
                    {
                        method   = new SideFold4UpBookletLayouter();
                        pageSize = PageSize.Letter;
                    }
                    else
                    {
                        method = new SideFoldBookletLayouter();
                    }
                    break;

                case PublishModel.BookletLayoutMethod.CutAndStack:
                    method = new CutLandscapeLayout();
                    break;

                case PublishModel.BookletLayoutMethod.Calendar:
                    method = new CalendarLayouter();
                    break;

                default:
                    throw new ArgumentOutOfRangeException("booketLayoutMethod");
                }
                var paperTarget = new PaperTarget("ZZ" /*we're not displaying this anyhwere, so we don't need to know the name*/, pageSize);
                var pdf         = XPdfForm.FromFile(incoming.Path);        //REVIEW: this whole giving them the pdf and the file too... I checked once and it wasn't wasting effort...the path was only used with a NullLayout option
                method.Layout(pdf, incoming.Path, pdfPath, paperTarget, layoutPagesForRightToLeft, ShowCropMarks);
            }
        }