Esempio n. 1
0
        private void pictureBox1_MouseClick(object sender, MouseEventArgs e)
        {
            PDFLibrary qp = new PDFLibrary();

            qp.UnlockKey(LicenseKey);
            qp.LoadFromFile(OriginalFileName);
            // Calculate co-ordinates, width of PDF fitted to width of PictureBox
            double xpos = ((double)e.X / (double)pictureBox1.Width) * qp.PageWidth();
            double ypos = qp.PageHeight() - ((double)e.Y / (double)pictureBox1.Width) * qp.PageWidth();

            qp.SetTextSize(24);
            qp.SetTextColor(1, 0, 0);
            qp.DrawText(xpos, ypos, "A");
            qp.SaveToFile(NewFileName);
            ShowPDF(NewFileName);
        }
Esempio n. 2
0
        private void ShowPDF(string fileName)
        {
            PDFLibrary qp = new PDFLibrary();

            qp.UnlockKey(LicenseKey);
            qp.LoadFromFile(fileName);
            // Fit width of PDF to width of picture box
            int dpi = Convert.ToInt32((pictureBox1.Width * 72) / qp.PageWidth());

            byte[]       bmpData = (byte[])qp.RenderPageToVariant(dpi, 1, 0);
            MemoryStream ms      = new MemoryStream(bmpData);
            Bitmap       bmp     = new Bitmap(ms);

            pictureBox1.Image = bmp;
            ms.Dispose();
        }
        private bool LoadPDFLib()
        {
            bool result = true;

            try
            {
                if (isLibraryLoaded == false)
                {
                    if (pdfLib.LibraryLoaded())
                    {
                        // Create an instance of the class and give it the path to the DLL
                        string LicKey = (!string.IsNullOrEmpty(System.Configuration.ConfigurationSettings.AppSettings["DebenuLicenceKey"]) ? System.Configuration.ConfigurationSettings.AppSettings["DebenuLicenceKey"].ToString() : "jc8am89q6n57ue8q87xd7nt4y");
                        pdfLib.UnlockKey(LicKey);

                        if (pdfLib.Unlocked() == 0)
                        {
                            //LogManager.Trace("PWPPDFMgr::LoadPDFLib", TraceCategoryType.Error, "License unlock failed.  Please update your key in the form1.cs source code", "");
                            result = false;
                        }
                        else
                        {
                            isLibraryLoaded = true;
                        }
                    }
                    else
                    {
                        //LogManager.Trace("PWPPDFMgr::LoadPDFLib", TraceCategoryType.Error, "Could not locate the Debenu PDF Library DLL, please check the path");
                        result = false;
                    }
                }
            }
            catch (Exception Ex)
            {
                //LogManager.Trace("PWPPDFMgr::LoadPDFLib", Ex1, "Could not locate the Debenu PDF Library DLL, please check the path");
                result = false;
            }
            return(result);
        }
Esempio n. 4
0
        public static void Main()
        {
            // This example uses the DLL edition of Quick PDF Library
            // Create an instance of the class and give it the path to the DLL
            PDFLibrary QP = new PDFLibrary("QuickPDFDLL0718.dll");

            // Check if the DLL was loaded successfully
            if (QP.LibraryLoaded())
            {
                // Insert license key here / Check the license key
                if (QP.UnlockKey("...") == 1)
                {
                    QP.LoadFromFile(@"C:\Program Files\Quick PDF Library\DLL\GettingStarted.pdf");

                    int iPageCount   = QP.PageCount();
                    int PageNumber   = 1;
                    int MatchesFound = 0;

                    while (PageNumber <= iPageCount)
                    {
                        QP.SelectPage(PageNumber);
                        string PageText = QP.GetPageText(3);

                        using (StreamWriter TempFile = new StreamWriter(QP.GetTempPath() + "temp" + PageNumber + ".txt"))
                        {
                            TempFile.Write(PageText);
                        }

                        string[]   lines = File.ReadAllLines(QP.GetTempPath() + "temp" + PageNumber + ".txt");
                        string[][] grid  = new string[lines.Length][];

                        for (int i = 0; i < lines.Length; i++)
                        {
                            grid[i] = lines[i].Split(',');
                        }

                        foreach (string[] line in grid)
                        {
                            string FindMatch = line[11];

                            // Update this string to the word that you're searching for.
                            // It can be one or more words (i.e. "sunday" or "last sunday".

                            if (FindMatch.Contains("characters"))
                            {
                                Console.WriteLine("Success! Word match found on page: " + PageNumber);
                                MatchesFound++;
                            }
                        }
                        PageNumber++;
                    }

                    if (MatchesFound == 0)
                    {
                        Console.WriteLine("Sorry! No matches found.");
                    }
                    else
                    {
                        Console.WriteLine();
                        Console.WriteLine("Total: " + MatchesFound + " matches found!");
                    }
                    Console.ReadLine();
                }
            }
        }