PDF24 quality window

ag_122

New Member
Joined
Mar 15, 2020
Messages
31
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Dear All

i coded the command line to merge pdfs in a file

"C:\Program Files\PDF24\pdf24-DocTool.exe" -join -outputFile "C:\Dest\TEST.pdf" -File1 "C:\Dest\1_PDFsam_CV.pdf" -File2 "C:\Dest\2_PDFsam_CV.pdf" -File3 "C:\Dest\3_PDFsam_CV.pdf"

it works fine but when excecated, pdf24 window pop to choose the document quality, is there a way were i can keep a default quality or skip this part in the command line ?
 

Attachments

  • Capture.JPG
    Capture.JPG
    24.2 KB · Views: 23

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
You do not need the -File# switches.

Depends on what you mean by default quality. This example hides the progress bar and uses the Good quality default profile. The progress bar is neat but slows things down.

I did not add any checks for errors...
VBA Code:
Sub Main()
  Dim p As String, a(3)
 
  p = "C:\Users\ken\Dropbox\_Excel\pdf\"
  a(0) = p & "A10_1.pdf"
  a(1) = p & "A10_2.pdf"
  a(2) = p & "A10_B&W.pdf"
  a(3) = p & "A10_Color.pdf"
 
  PDF24Merge ThisWorkbook.Path & "\PDF24Merge.pdf", a
  MsgBox "Done!"
End Sub

Sub PDF24Merge(outPDF As String, a)
  Dim i As Long, s As String, exe As String, q As String
 
  '************** Change exe path to yours *************************
  exe = "D:\MyFiles\pdf24\Pdf24-DocTool.exe"
 
  q = """"
  outPDF = q & outPDF & q
 
  's = exe & " -join -profile ""default/good"" -outPutFile " & outPDF & " "
  s = exe & " -join -profile ""default/good"" -noProgress -outPutFile " & outPDF & " "

 
  For i = LBound(a) To UBound(a)
    a(i) = q & a(i) & q
  Next i
 
  s = s & Join(a, " ")
  'Debug.Print s
 
  Shell s, vbHide
End Sub
 
Upvote 0
You do not need the -File# switches.

Depends on what you mean by default quality. This example hides the progress bar and uses the Good quality default profile. The progress bar is neat but slows things down.

I did not add any checks for errors...
VBA Code:
Sub Main()
  Dim p As String, a(3)
 
  p = "C:\Users\ken\Dropbox\_Excel\pdf\"
  a(0) = p & "A10_1.pdf"
  a(1) = p & "A10_2.pdf"
  a(2) = p & "A10_B&W.pdf"
  a(3) = p & "A10_Color.pdf"
 
  PDF24Merge ThisWorkbook.Path & "\PDF24Merge.pdf", a
  MsgBox "Done!"
End Sub

Sub PDF24Merge(outPDF As String, a)
  Dim i As Long, s As String, exe As String, q As String
 
  '************** Change exe path to yours *************************
  exe = "D:\MyFiles\pdf24\Pdf24-DocTool.exe"
 
  q = """"
  outPDF = q & outPDF & q
 
  's = exe & " -join -profile ""default/good"" -outPutFile " & outPDF & " "
  s = exe & " -join -profile ""default/good"" -noProgress -outPutFile " & outPDF & " "

 
  For i = LBound(a) To UBound(a)
    a(i) = q & a(i) & q
  Next i
 
  s = s & Join(a, " ")
  'Debug.Print s
 
  Shell s, vbHide
End Sub

I want to use vba combined with pdf24 to set a password for the pdf file. For example, the pdf file is located at the path C:/1.pdf, what should I do? thanks
 
Upvote 0
The VBA code for merge multiple PDF files work perfectly from VBA.
What about to Compress the merge PDF file - does any know an VBA exampel ?
 
Upvote 0
Manual link to the command line options:

View the manual for command line parameters. In this case, search for -compress. There are some other options for that too. The code example uses another method.

I did not notice the previous thread #4. In that case, one uses -encrypt.

VBA Code:
'unchecked chatgpt code:
Sub CompressPDF()
    Dim pdfPath As String
    Dim compressedPdfPath As String
    Dim pdf24Path As String
    Dim shellCommand As String
    Dim shellObject As Object
    
    ' Define the path to the PDF, the output path, and the PDF24 executable
    pdfPath = "C:\t\test.pdf"
    compressedPdfPath = "C:\t\test_compressed.pdf"
    pdf24Path = "C:\Program Files\PDF24\pdf24-Compress.exe" ' Update this path based on your installation
    
    ' Create the shell command
    shellCommand = Chr(34) & pdf24Path & Chr(34) & " --output=" & Chr(34) & compressedPdfPath & Chr(34) & " " & Chr(34) & pdfPath & Chr(34)
    
    ' Create a new shell object
    Set shellObject = CreateObject("WScript.Shell")
    
    ' Run the shell command
    shellObject.Run shellCommand, 0, True
    
    ' Clean up
    Set shellObject = Nothing
    
    MsgBox "PDF compression completed!"
End Sub
 
Upvote 0
Its prompt with an Dialogwindow from pdf24-Compress.exe - no automatic progess ?
 
Upvote 0
Dim I As Long, s As String, exe As String, q As String

'************** Change exe path to yours *************************

exe = Environ("ProgramW6432") & "\PDF24\Pdf24-DocTool.exe"

If Trim(Environ("ProgramW6432")) = "" Then exe = "C:\Program Files" & "\PDF24\Pdf24-DocTool.exe"


q = """"
outPDF = q & outPDF & q

's = exe & " -join -profile ""default/good"" -outPutFile " & outPDF & " "
s = exe & " -join -profile -compress ""default/good"" -noProgress -outPutFile " & outPDF & " "

For I = LBound(a) To UBound(a)
a(I) = q & a(I) & q
Next I

s = s & Join(a, " ")
'Debug.Print s


Shell s, vbHide

How to set no popup calling this ?
 
Upvote 0
While I can hide the dialog, pdf24-doctool.exe does not output the pdf as set. If you run it manually from the CMD prompt, you will see that it stalls out and requires an Enter key to complete. It will show that it output the compressed pdf to an unlocked or compress prefixed unique named pdf. e.g. compress_qpdf_2_72600390_141483112.pdf. For all that effort, it would be easier just to use Window dialog method.

pdf24-Compress.exe has a few command line options but none to hide the Window or set other parameters.


You can use another 3rd party CLI to possibly do what you want. Of course if you had Acrobat (not reader), then that would work. If I were doing this, I would try using Python directly. One could use a Shell() method to run an EXE self-contained Python that has CLI options for custom inputs. Those EXEs tend to be large file size because it has to include the libraries used in the code along with the standard Python libraries. One nice thing about that method is that if many use the EXE, they would not need Python installed.

There is a Python addon that you can get to run Python code but it still needs work. For simple Python function returns, some Python can be done within a cell.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,331
Members
452,636
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top