• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Script to move files based on pages

New Here ,
Dec 17, 2018 Dec 17, 2018

Copy link to clipboard

Copied

Hi,

We have created a script that move PDF files to different folders based on if it's one page, or multiple page. This works with Adobe Acrobat installed locally. Problem is that this script will run on a server, and then we need license for ALL users accessing the server, which can be a variable amount of people for different environments. We have thought about the SDK, but not sure if same license regulations apply, or if the SDK itself is sufficient.

Any sugestions to solve this problem would be appriciated.

Kind Regards,

Vidar

TOPICS
Acrobat SDK and JavaScript

Views

669

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Dec 17, 2018 Dec 17, 2018

Copy link to clipboard

Copied

The SDK is just a way to automate Acrobat – so all the same licensing restrictions apply.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 17, 2018 Dec 17, 2018

Copy link to clipboard

Copied

What kind of script do you use? Acrobat Javascript scripts can't move files.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 17, 2018 Dec 17, 2018

Copy link to clipboard

Copied

I suggest you rethink your solution.

While Acrobat can be licensed and run on a server. If you want this sorting process to be automated, I strongly recommend against using Acrobat be the engine behind the process; it just wasn't built for that kind of thing. However, even the most brain-dead PDF library tool can detect the number of pages in a file and since you only want to get information from the PDF and then move the file and you are not changing the PDF, any of these tools will work.

In general, if you want to work with PDF on a server, don't use a desktop application. Subscribe to, buy or write a real server app.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 17, 2018 Dec 17, 2018

Copy link to clipboard

Copied

As mentioned, your solution (an Acrobat script or plugin) is not a good one, due to technical and legal reasons.

If you're interested I could develop for you a stand-alone tool (for a small fee) that will do it, without relying on Acrobat at all, and you could use it on a server if you wanted to. Feel free to contact me privately (try6767 at gmail.com) to discuss it further.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 17, 2018 Dec 17, 2018

Copy link to clipboard

Copied

Hi,

Thanks a lot for the sugestions, but I managed to solve it using a .vsb script. I'll share it:

'
' eg:   cscript.exe  TAX_AnnualReport_Distribute.vbs  "C:\SCRIPTS\"
'-----------------------------------------------------------------------------------------------------------------------------

'-----------------------------------------------------------------------------------------------------------------------------
'Define variables
'-----------------------------------------------------------------------------------------------------------------------------
Dim objFSO
Dim objFolder
Dim objFil
Dim xlAp
Dim objStream, strData

' Hent path til root for
if WScript.Arguments.Count>0 THEN
FilePathRoot = WScript.Arguments(0)
Else
FilePathRoot = "D:\Filepath here"
END IF

' SET RELATIVE PATHS
FolderFrom="\"
FolderToOne="\OnePage\"
FolderToMany="\MultiplePages\"

' Relativ path & root
FilePathFrom  = FilePathRoot & FolderFrom
FilePathToOne  = FilePathRoot & FolderToOne
FilePathToMany  = FilePathRoot & FolderToMany


'-----------------------------------------------------------------------------------------------------------------------------
'Instances and creation of files
'-----------------------------------------------------------------------------------------------------------------------------
'Folder og filer
Set objFSO = CreateObject("scripting.filesystemobject")
Set objFolder = objFSO.getfolder(FilePathFrom)

Set objStream = CreateObject("Adodb.Stream")
objStream.Charset = "x-ansi"
objStream.open

Const ForReading = 1, ForWriting = 2
Set re = New RegExp
re.Pattern = "Type\s*/Page[^s]"
re.Global = True
re.IgnoreCase = True

'-----------------------------------------------------------------------------------------------------------------------------
' Control file format and move file to another destination
'-----------------------------------------------------------------------------------------------------------------------------
'a = 1
'DO WHILE A < 5
'a = a + 1
For Each objFil In objFolder.Files
  NbPages = 0
  If InStr(objFil.Type, "Acrobat")  > 0 Then  
  
   a = 0
   do while a < 5000
   a = a+1
   Loop
  
   'Set objFilex = objFSO.OpenTextFile(FilePathFrom&objfil.name, ForReading)
   objStream.LoadFromFile(FilePathFrom&objfil.name)
   strSearchString = objStream.ReadText(-1)
   objStream.flush
  
  
   'Search file for defined pattern
   Set colMatches = re.Execute(strSearchString)
   If colMatches.Count = 0 Then       
    NbPages = 0
   else
    NbPages = colMatches.Count
   End If
  
   ' If one page is identified
   if (NbPages = 1) then
    oldpath = objFSO.BuildPath(FilePathFrom, objfil.name)
    newpath = objFSO.BuildPath(FilePathToOne, objfil.name)
    if objFSO.FileExists(newpath) then
     objFSO.DeleteFile newpath
    end if
    objFil.Move(FilePathToOne)
   else
   ' More than one page or unidentified
    oldpath = objFSO.BuildPath(FilePathFrom, objfil.name)
    newpath = objFSO.BuildPath(FilePathToMany, objfil.name)
    if objFSO.FileExists(newpath) then
     objFSO.DeleteFile newpath
    end if
    objFil.Move(FilePathToMany)
   
   end if

  End If

Next

'loop

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 18, 2018 Dec 18, 2018

Copy link to clipboard

Copied

Ingenious! Two comments

1. It may not happen to you but its easy to make a single page file with /Type /Page more than once. It’s also possible (by default) to make a PDF with none. You then get into needing a complete PDF parser.

2. Your file type string from scripting won’t contain “Acrobat” unless Acrobat or Reader is installed, which invites the same licensing issues you are trying to avoid. Simple solution is to just use the file name, check the last 4 chars.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Dec 18, 2018 Dec 18, 2018

Copy link to clipboard

Copied

LATEST

Yes, but it won’t work on any modern PDF (something created in the last decade) do the use of object stream compression.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines