ToString() public method

public ToString ( ) : string
return string
コード例 #1
0
ファイル: Converter.cs プロジェクト: abenori/TeX2img
        List<BoundingBoxPair> readPDFBox(string inputPDFFileName, List<int> pages, string boxname) {
            try {
                using (var mupdf = new MuPDF(Path.Combine(GetToolsPath(), "mudraw.exe"))) {
                    if (controller_ != null) controller_.appendOutput("Getting the size of PDFBox...\n");
                    var rv = new List<BoundingBoxPair>();
                    var doc = mupdf.Execute<int>("open_document", Path.Combine(workingDir, inputPDFFileName));
                    if (doc == 0) return null;
                    foreach (var p in pages) {
                        if (abort) {
                            if (controller_ != null) controller_.appendOutput(Properties.Resources.STOPCONVERTMSG + "\n");
                            return null;
                        }
                        int rotate = 0;
                        BoundingBox box = new BoundingBox(), media = new BoundingBox();
                        const int repeatTimes = 10;
                        for (int i = 1; i <= repeatTimes; ++i) {
                            try {
                                var page = mupdf.Execute<int>("load_page", doc, p - 1);
                                media = mupdf.Execute< BoundingBox>("pdfbox_page", page, "media");
                                box = mupdf.Execute<BoundingBox>("pdfbox_page", page, boxname);
                                rotate = mupdf.Execute<int>("rotate_page", page);
                                break;
                            }
                            catch (Exception) {
                                mupdf.ClearError();
                                if (i == repeatTimes) throw;
                            }
                        }
                        BoundingBox bb;
                        switch (rotate) {
                        default:
                        case 0:
                            bb = new BoundingBox(box.Left - media.Left, box.Bottom - media.Bottom, box.Right - media.Left, box.Top - media.Bottom);
                            break;
                        case 90:
                            bb = new BoundingBox(box.Bottom - media.Bottom, media.Right - box.Right, box.Top - media.Bottom, media.Right - box.Left);
                            break;
                        case 180:
                            bb = new BoundingBox(media.Right - box.Right, media.Top - box.Top, media.Right - box.Left, media.Top - box.Bottom);
                            break;
                        case 270:
                            bb = new BoundingBox(media.Top - box.Top, box.Left - media.Left, media.Top - box.Bottom, box.Right - media.Left);
                            break;
                        }
                        if (controller_ != null) controller_.appendOutput(bb.ToString() + " (Page " + p + ")\n");
                        rv.Add(new BoundingBoxPair(bb.HiresBBToBB(), bb));
                    }
                    if (controller_ != null) controller_.appendOutput("\n");
                    return rv;
                }
            }
            catch (Exception e) {
                if (controller_ != null) controller_.appendOutput(e.Message + "\n");
#if DEBUG
                System.Diagnostics.Debug.WriteLine(e.StackTrace);
#endif
                return null;
            }
        }