Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Fri Aug 27, 2021 9:42 am

Hi,

I am making a C# application to automate some processes. I have 2 questions, regarding Spire.PDF:

Is it possible to search trough a PDF document and check if a specific word exists in the document? And how?

The second question is maybe some more complex:
Is it possible to retrieve a rectangled part of a PDF from (pre-defined) coordinates. And then print that part (or create a picture of it)?

Thanks for any replies :)

marvinarets
 
Posts: 1
Joined: Tue Dec 23, 2014 2:07 pm

Fri Aug 27, 2021 11:32 am

Hello,

Thanks for you inqiry.

Regarding your first issue, please refer to the following tutorial.
https://www.e-iceblue.com/Tutorials/Spi ... B.NET.html

As for your second issue, I am sorry that our Spire.PDF does not support converting a specific area of the PDF file into an image directly, but you can convert the PDF to an image and then crop the image according to your needs (as shown below).
Code: Select all
            PdfDocument doc = new PdfDocument("test.pdf");
            using (Image image = doc.SaveAsImage(0, 300, 300))
            {
                Bitmap resultBitmap = new Bitmap(image.Width, image.Height);
                using (Graphics g = Graphics.FromImage(resultBitmap))
                {
                    Rectangle sourceRectangle = new Rectangle(0-500, 0-500, image.Width/2, image.Height/2);
                    Rectangle resultRectangle = new Rectangle(0, 0, image.Width, image.Height);
                   
                    g.DrawImage(image, resultRectangle, sourceRectangle, GraphicsUnit.Pixel);
                }
                resultBitmap.Save("result.png",ImageFormat.Png);
            }
        }


Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Wed Sep 01, 2021 10:38 am

Hello,

Greetings from E-iceblue!
Did the code we provided work for you? Any feedback will be greatly appreciated.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Return to Spire.PDF