Can anyone recommend a pdf compressor and DT workflow?

Humm. My hunch is that there are too many diverse comments involved. I put comments, tags, only in DEVONthink and pay no attention to what Finder and the macOS is doing.

I suspect a combination of Keyboard Maestro controlling PDFPen (or equivalent) and a DEVONthink rule that copies meta data can be made. Or DEVONthink rule that calls Ghostscript to compress the PDF (discussed here in the past–seqrch). Perhaps you can experiment or hire someone.

DT stores comments made in the sorter as Finder comments (you’ll see that label in the DT sidebar). So when I say Finder comment, it’s synonymous with DT comments.

This thread is about sharing solutions to the problem of making smaller PDFs, so hopefully someone can chime in with some useful pieces of their process.

2 Likes

Hi Bluefrog,

I used your example workflow for something little bit different. I want to use the workflow to compress an existing PDF in Devonthink and I do not want to make a copy of the PDF. Instead I want to shrink the existing PDF and save it. So I adopted the workflow a little bit and use PDF Squeezer for the shrinking job. PDF Squeezer has a Automator action and has the option to save the shrinking in the same file.
Everything works fine so far except one problem. After using the workflow on PDF file. The size is smaller, but I can only see this in the Finder. Devonthink mentioned now an error, that the checksum is wrong for one file. And also I see the old file size in Devonthink.

Can you help me to adopt the script, that this is working?

See below some screenshot as explanation.

dvt3


dvt2

Please post code as code, not as screenshot. This one is illegible, too.
```
code goes here and can be read, copied and pasted
```

I do not understand why you think the leading AppleScript is relevant for this issue. But, anyway, here it is:

on run {}
tell application id “DNtp”
set fileList to {}
if selection ≠ {} then
repeat with thisRecord in (selection as list)
copy (path of thisRecord) to end of fileList
end repeat
end if
return fileList
end tell
end run

I did not find a way how to export the PDF Squeezer Action as code snipset. If you can give a hint, I will post this as well.

I don’t know if it’s relevant, since I couldn’t read it. You posted it, so I assumed it might be relevant. And you were asking for assistance on the script. And please do not post code as blockquote, but as I described included in three back quotes.

No idea. But legible screenshots of the complete workflow might help (I’m wearing my glasses :wink:

You should make it as easy as possible to help you. For example, post the DT error message and the file it refers to. And what’s the black square meant to show?

Also: perhaps using the commandline tool in a shell script is easier? Something along the lines of (JavaScript, not tested!)

(() => {
  const app = Application("DEVONthink 3");
  const curApp = Application.currentApplication();
  curApp.includeStandardAdditions = true;
  app.selectedRecords().forEach(r => {
     curApp.doShellScript(`pdfs --output /tmp/compressed.pdf "${r.path()}"`);
     const group = r.locationGroup();
     const newRecord = app.import('/tmp/compressed.pdf', {to: group});
     newRecord.name = r.name();
     curApp.doShellScript('rm /tmp/compressed.pdf');
// The next command is dangerous! Uncomment only after thorough testing          
//   app.delete({record: r}); 
  })
})()

So for someone else, how it searching for a solution. I added the following block after squeezing the pdf. This updates the file.

tell application id "DNtp"
	set theSelection to selection
	repeat with theRecord in theSelection
		deconsolidate record theRecord
		synchronize record theRecord
	end repeat
end tell

And also attached the full workflow. I often save PDFs in the “Inbox” e. g. during a download from a kind of service portal. This PDF a sometimes very big.
So when the PDF is already in my Devonthink I can shrink the size with this workflow. Attention, it did not makes a backup or copy of the file. So if the file shrinking destroys the file. You need a different way to get a clean file.
The workflow uses PDF Squeezer already mentioned in this thread. You need to install this software in advanced.

TD_PDF Squeez.workflow.zip (157.4 KB)

I assume you are writing about PDF SQUEEZER 4 and PDF SHRINK. The first one costs 18 CHF (about 18 USD), the later one 3 CHF (about 3 USD) in the MacOS Store. As far as I have understood, Shrink is better scriptable? Would you still recommend squeezer over shrink? Is the higher price for Squeezer worth it? For me it’s not really clear how to use the scripts that you have posted here (should I copy it into the applescript section of a smartrule) and then run the script by drag and drop pdfs on these smartrule? Has anyone here already a working script that allows to automate PDF Squeezer or PDF shrink to compress multiple pdfs by predefined criteria?

I only use PDF Squeezer, primarily because it’s included in Setapp and so doesn’t cost anything if you’re a subscriber anyway, but it looks to me as if PDF Squeezer offers finer-grained control over compression settings. If you haven’t already done so, I’d suggest downloading the trial version from the developer’s website to take it for a spin. (There doesn’t seem to be a trial version of PDF Shrink.)

I have and like “PDF Squeezer”. But I’ve been unable to get the command line interface “pdfs” working as when I click on the “grant access” button, PDF Squeezer throws the error “The Open file operation failed to connect to the open and save panel service”. Have no real clue what that means. Have contacted their support a couple of times last month with no reply whatsoever. Nice.

Otherwise, dragging and dropping individual or even groups of files does a good job of “squeezing” PDFs down to more reasonable size for my purposes.

I have now bought squeezer, great software. However, you are right, it’s currently a bit difficult to get a response from the Squeezer support, but I have seen that @daniel_witt is also active here in the DT forum.

Thank you for this !!