Page 1 of 1

PDF AutoCropPage Method

Posted: Fri May 13, 2022 3:36 pm
by andrew
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

Re: PDF AutoCropPage Method

Posted: Mon May 16, 2022 3:30 pm
by Hugo
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

Re: PDF AutoCropPage Method

Posted: Mon May 16, 2022 5:37 pm
by andrew
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.

Re: PDF AutoCropPage Method

Posted: Tue May 17, 2022 4:57 pm
by Hugo
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

Re: PDF AutoCropPage Method

Posted: Tue May 17, 2022 7:25 pm
by andrew
Thanks!

Re: PDF AutoCropPage Method

Posted: Wed May 18, 2022 1:39 pm
by Hugo
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