コード例 #1
0
ファイル: PDI.cs プロジェクト: keitaroemotion/mangatopdf
 public static int Add(PDFlib plib, string pdffile)
 {
     try
     {
         int indoc = plib.open_pdi_document(pdffile, "");
         if (indoc == -1)
         {
             throw new Exception(string.Format("AddPdi : picture -> {0} not found", pdffile));
         }
         return indoc;
     }catch(Exception ex){
         throw new Exception("PDI::Add: "+ex.Message);
     }
 }
コード例 #2
0
ファイル: MAIN.cs プロジェクト: keitaroemotion/mangatopdf
        public static void main(string resourcePath, AuthInfo auth)
        {
            PDFlib plib = new PDFlib();
            int image;

            try {
                plib.set_info("Creator", auth.Creator);
                plib.set_info("Title", auth.Title);
                plib.set_option("searchpath={" + resourcePath + "}");
                plib.set_option("errorpolicy=return");

                var outpath = resourcePath.TrimEnd('\\') + @"\Out\";

                if (!Directory.Exists(outpath))
                {
                    Directory.CreateDirectory(outpath);
                }

                plib.begin_document(outpath + "moomi.pdf", "");

                int i = 1;

                foreach (var eachpdf in GetPdfs(resourcePath)) {

                    image = plib.load_image("auto", eachpdf, "");

                    plib.begin_page(700, 1000);

                    int page = i;
                    plib.fit_image(image,0.0,0.0,"");
                    if (page == -1)
                    {
                        throw new Exception("OpenPDI: i: " + i);
                    }

                    plib.end_page();

                    i++;
                }

                plib.end_document("");

            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
コード例 #3
0
        private bool Annotate_NF(NPFE_Object nPanelObject, out string outPath)
        {
            outPath = string.Empty;
            bool   returnStatus     = true;
            string annotatedDocPath = string.Empty;
            string optionList       = string.Empty;
            int    inDoc            = -1;
            int    status           = -1;
            int    pageStatus       = -1;
            PDFlib annotate         = null;

            try
            {
                optionList       = " annotcolor =" + ColorCode.GENERIC + " opacity=0.9";
                annotate         = new PDFlib();
                annotatedDocPath = Path.Combine(Path.GetDirectoryName(filePath), (Path.GetFileNameWithoutExtension(filePath) + "_highlighted.pdf"));

                annotate.set_option("errorpolicy=return");
                annotate.set_option("license=W900202-010077-142367-MPGCD2-22DW62");

                status = annotate.begin_document(annotatedDocPath, "");

                if (status != 1)
                {
                    throw new Exception("Error while creating annotated PDF");
                }

                outPath = annotatedDocPath;

                inDoc = annotate.open_pdi_document(filePath, "");
                if (inDoc != 0)
                {
                    throw new Exception("Error while opening source PDF");
                }

                pageStatus = annotate.open_pdi_page(inDoc, 1, "");
                if (pageStatus != 0)
                {
                    throw new Exception("Error while opening source PDF page");
                }

                annotate.begin_page_ext(10, 10, "");

                annotate.create_bookmark(filePath, "");

                annotate.fit_pdi_page(pageStatus, 0, 0, "adjustpage");

                foreach (NPF_Annotate X in nPanelObject.textDetails)
                {
                    annotate.create_annotation(X.location.LLX, X.location.LLY, X.location.URX, X.location.URY, "highlight", optionList);
                }

                annotate.close_pdi_page(pageStatus);
                annotate.end_page_ext("");

                annotate.close_pdi_document(inDoc);
                annotate.end_document("");


                return(returnStatus);
            }
            catch (PDFlibException pdf_err)
            {
                Console.WriteLine(pdf_err.StackTrace);
                return(false);
            }
            catch (Exception err)
            {
                Console.WriteLine(err.StackTrace);
                return(false);
            }
        }