PDF AutoCropPage Method

Discussions about PDF management.
Post Reply
andrew
Posts: 22
Joined: Tue Jul 24, 2007 9:30 pm

PDF AutoCropPage Method

Post by andrew » Fri May 13, 2022 3:36 pm

Hi, I am looking for some help on the AutoCropPage Method, as I cannot seem to get it to crop at all.
I have tried many inputs for the margin Parameters without any luck.

The files I am processing have clear black borders on 3-4 sides, and crop quite easily using the CropBlackBorders.

I need to crop the pages as PDF pages as they are already OCR'd, and bring them out to GDPictureImaging would require re-OCRing.

Sample

Code: Select all

Dim GDpdf As New GdPicturePDF
            GDpdf.NewPDF()
            Dim message As String = ""
            Dim status As GdPictureStatus = GDpdf.LoadFromFile(Filename, True)
            If status = GdPictureStatus.OK Then
                Dim pageCount As Integer = GDpdf.GetPageCount()
                status = GDpdf.GetStat()
                Dim pageNo As Integer = 1
                While (pageNo <= pageCount) AndAlso (status = GdPictureStatus.OK)
                    GDpdf.SelectPage(pageNo)
                    If status = GdPictureStatus.OK Then
                        GDpdf.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitInch)
                        status = GDpdf.AutoCropPage(0.25, 0.25, 0.25, 0.25)
                        status = GDpdf.GetStat()
                        'End If
                    End If
                    pageNo += 1
                End While

Hugo
Posts: 227
Joined: Tue Dec 18, 2018 10:09 am

Re: PDF AutoCropPage Method

Post by Hugo » Mon May 16, 2022 3:30 pm

Hi Andrew,

Thank you for your question.

Could you provide a sample file please so we may visualize this issue on our end?
How are you determining the values you are using as parameters for the AutoCropPage method. This could perhaps be determined by creating a clone of your page in GdPictureImaging and then cropblackborders and then get new page width and height which you can then use in PDF. Please make sure you are compensating for DPI values between both though.

Regards,
Hugo Cudd
Technical Support

andrew
Posts: 22
Joined: Tue Jul 24, 2007 9:30 pm

Re: PDF AutoCropPage Method

Post by andrew » Mon May 16, 2022 5:37 pm

Thanks for the reply.
perhaps I am confused about the function of AutoCropPage, does it not automatically crop the page similar to cropblackborders?
I have tried a number of values for the parameters; however, there is no change to the PDF page.

I don't think that breaking out to GDPictureImaging and using cropblackborders would be helpful as it would only work on the off chance the margins being cropped are the same on the top and bottom, or the left and right.
Attachments
SampleB_nonOCR.pdf
(24.92 KiB) Downloaded 367 times
SampleB.pdf
(26.94 KiB) Downloaded 381 times

Hugo
Posts: 227
Joined: Tue Dec 18, 2018 10:09 am

Re: PDF AutoCropPage Method

Post by Hugo » Tue May 17, 2022 4:57 pm

Andrew,

Thank you for these files.

You are indeed correct about your previous assumptions. The parameters are irrelevant as they are simply allowing you to set a margin.
The crop should indeed automatically delete pages borders depending on the content of the page. In your case it is clear there is a black border.

I have sent this to our developpers to investigate and I'll get back to you when I have more news.

Regards,
Hugo Cudd
Technical Support

andrew
Posts: 22
Joined: Tue Jul 24, 2007 9:30 pm

Re: PDF AutoCropPage Method

Post by andrew » Tue May 17, 2022 7:25 pm

Thanks!

Hugo
Posts: 227
Joined: Tue Dec 18, 2018 10:09 am

Re: PDF AutoCropPage Method

Post by Hugo » Wed May 18, 2022 1:39 pm

Hi Andrew,

I have further news for you clarifying things.

AutoCropPage in GdPIcturePDF does not detect black borders on the image of any other objects in the PDF. The method only crops the page to minimal rectangle that is needed to accommodate all objects present on the page (+optional margins).

You are therefore currently recommended to do the way you previously described by converting to GdPictureImage and then using our CropBlackBorders method, following up with a conversion back to PDF format and then running our OCR engine on your document if you need it to be searchable.
This is the currently available solution.

I have further discussed options for implementing different solutions. Having a CropBlackBorders in GdPicturePDF is definitely possible to implement however it would take some time on our end and it wouldn't be our developpers top priority task either.
Despite this, let me know if you still wish for us to consider implementing this or if you are satisfied with the current solutions.

Regards,
Hugo Cudd
Technical Support

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest