Page 1 of 1

It is suggested to add an option named (Find Duplicate Page) to the menu 'More For Pages' for this popular software.

Posted: Thu Sep 05, 2024 3:45 pm
by MansourDalir
This feature is only for PDF whose content is a photo (bitmap). The method of detecting repetition should be like this. Looking horizontally linearly and vertically linearly When a duplicate page is found, the user deletes the pages.Or if this software has such a possibility, I would be grateful if you could help me
Image

Re: It is suggested to add an option named (Find Duplicate Page) to the menu 'More For Pages' for this popular software.

Posted: Thu Sep 05, 2024 9:59 pm
by Daniel - PDF-XChange
Hello, MansourDalir

Thank you for the suggestion, I believe this has come up in the past, but I will bring it by the Dev team again today and see what they think.

[Edit:] A ticket has been made for this request:
RT#7090: FR: Add "find duplicate page" feature

Kind regards,

Re: It is suggested to add an option named (Find Duplicate Page) to the menu 'More For Pages' for this popular software.

Posted: Fri Sep 06, 2024 2:22 am
by MansourDalir
I wrote a piece of code that can find duplicate pages. Maybe it can speed things up a bit. The code is in VB language. I don't know what is the base language of your application.

Code: Select all

Imports System.Runtime.InteropServices
Public Class frmDuplicateImageFinder

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim bmpFiles As New List(Of String)
        For Each foundFile As String In My.Computer.FileSystem.GetFiles(txtRootPath.Text, FileIO.SearchOption.SearchTopLevelOnly, "*bmp")
            bmpFiles.Add(foundFile)
        Next
        GetDulicateImage(bmpFiles.ToArray)
    End Sub
    Function GetDulicateImage(InFiles As String())
        Dim ResultUnique As New List(Of String)
        Dim ResultDuplicate As New List(Of String)
        Dim PixelsFile As New Dictionary(Of String, String)
        For Each CurrentFile In InFiles
            Dim EveryFilePixel As String = GetPixelsFile(CurrentFile)
            If Not PixelsFile.Keys.Contains(EveryFilePixel) Then
                PixelsFile.Add(EveryFilePixel, "Uniqe(" & My.Computer.FileSystem.GetName(CurrentFile) & ")")
                ResultUnique.Add(CurrentFile)
            Else
                PixelsFile(EveryFilePixel) += "_" & My.Computer.FileSystem.GetName(CurrentFile)
                ResultDuplicate.Add(CurrentFile)
            End If
        Next
        My.Computer.FileSystem.CreateDirectory(txtDuplicate.Text)
        My.Computer.FileSystem.CreateDirectory(txtUnique.Text)
        For Each file In ResultDuplicate.ToArray
            My.Computer.FileSystem.MoveFile(file, txtDuplicate.Text & "\" & My.Computer.FileSystem.GetName(file))
        Next
        For Each file In ResultUnique.ToArray
            My.Computer.FileSystem.MoveFile(file, txtUnique.Text & "\" & My.Computer.FileSystem.GetName(file))
        Next
        txtResultDup.Text = Join(PixelsFile.Values.ToArray, vbNewLine)
        MsgBox("Duplicate File " & ResultDuplicate.Count)
    End Function
    Function GetPixelsFile(Path As String) As String
        Dim RecCheck As New List(Of Rectangle)
        Dim Pixels As New List(Of String)
        Dim RecPixel As String = ""
        Dim bm As Bitmap = New Bitmap(Path)
        'Here, a user's choice needs to be set, such as the number of vertical or horizontal lines
        Dim Len As Integer = 10 'Set By User
        Dim per As Integer = 6 'Set By User
        For Vertical = bm.Width / per To bm.Width Step (bm.Width / per) - 1
            RecCheck.Add(New Rectangle With {.X = Vertical, .Y = bm.Height / 2 - Len / 2, .Width = 1, .Height = Len})
        Next
        For Horizontal = bm.Height / per To bm.Height Step (bm.Height / per) - 1
            RecCheck.Add(New Rectangle With {.X = bm.Width / 2 - Len / 2, .Y = Horizontal, .Width = Len, .Height = 1})
        Next

        For Each Check As Rectangle In RecCheck
            Dim rec As New Rectangle(Check.X, Check.Y, Check.Width, Check.Height)
            Dim bmpData As System.Drawing.Imaging.BitmapData = bm.LockBits(rec, Drawing.Imaging.ImageLockMode.ReadOnly, Imaging.PixelFormat.Format32bppArgb)
            Pixels.Add(GetStringOfPixel(bmpData))
            bm.UnlockBits(bmpData)
        Next
        bm.Dispose()
        RecPixel = Join(Pixels.ToArray, "")
        Return RecPixel
    End Function
End Class

It is suggested to add an option named (Find Duplicate Page) to the menu 'More For Pages' for this popular software.

Posted: Fri Sep 06, 2024 10:47 am
by Stefan - PDF-XChange
:)

Re: It is suggested to add an option named (Find Duplicate Page) to the menu 'More For Pages' for this popular software.

Posted: Tue Jan 14, 2025 11:49 am
by joxeme
Dont understand, the new 10.5 has a New feature of "Duplicate pages" (great tool btw), not "Find duplicate pages", no?

Re: It is suggested to add an option named (Find Duplicate Page) to the menu 'More For Pages' for this popular software.

Posted: Tue Jan 14, 2025 7:39 pm
by Daniel - PDF-XChange
Hello, joxeme

Find duplicate pages does indeed exist in the new release:
image.png
Please give it a try, the implementation is quite robust.

Kind regards,

Re: It is suggested to add an option named (Find Duplicate Page) to the menu 'More For Pages' for this popular software.

Posted: Wed Jan 15, 2025 8:35 am
by joxeme
Oooh i see, thank you (i didn't know there was a Duplicate pages feature too!!), 2 good tools discovered, keep the good job!!

Best regards,

It is suggested to add an option named (Find Duplicate Page) to the menu 'More For Pages' for this popular software.

Posted: Wed Jan 15, 2025 10:38 am
by Stefan - PDF-XChange
:)