Pdfshuffler .sfs - Edit pdfs :) fantastic!

Word processors, spreadsheets, presentations, translation, etc.
Message
Author
User avatar
tallboy
Posts: 1760
Joined: Tue 21 Sep 2010, 21:56
Location: Drøbak, Norway

#101 Post by tallboy »

disciple wrote:Does anybody by any chance know of a Linux program to change the default view settings in a pdf e.g. change from |continuous view" to "single page" view, or "fit width" to "100%" or "fit page"?
Xpdf does that. It can be set default in it's prefs, and be modified on the spot in a document dialog window.
I have only used Xpdf and pdftk (don't use the pdftk-1.41-static pet) for the last 10-15 years. In my view, Xpdf produces the the cleanest and best looking fonts in a .pdf.

I also use to drag a .pdf file that I want to edit, to Abiword, which sometimes opens it like any other text document for editing. It depends on the origin of the document, for example a .pdf printout of a browser page, can very often be modified in Abi later. I have always given it a try.
BTW: I just tested my own claim, and opened a 90-page Huawei .pdf user manual (downloaded from Huawei as a .pdf) in Abi, along with some .pdf email attachments and bills. All very editable. I'm afraid I am an Abi-lover. :oops:

Hmm, on second thoughts (the other cell awakened), I have only been using Xpdf and pdftk, as long as I have been using Linux, some 20 years now... :lol:
True freedom is a live Puppy on a multisession CD/DVD.
disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#102 Post by disciple »

Correct me if I'm wrong, but I think you misunderstand what I was asking.
Pdf viewers commonly allow you to configure defaults for the viewer, and it sounds like that is what you're describing i.e. it affects every pdf you open in that viewer. I am talking about the settings in the actual pdf i.e. if I change them using sejda or flexipdf and send the file to someone else, it affects how the file opens in their viewer, assuming their viewer is set up to respect the settings.
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER
disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#103 Post by disciple »

Another couple of tools along similar lines as something like pdfsam (although less mature) i.e. non-wysiwyg gui utilities:

https://github.com/muriloventuroso/pdftricks (vala/gtk3/ghostscript)
https://gitlab.com/scarpetta/pdfmixtool (c++/qt5/podofo, although looking at qpdf now)
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER
User avatar
tallboy
Posts: 1760
Joined: Tue 21 Sep 2010, 21:56
Location: Drøbak, Norway

#104 Post by tallboy »

disciple wrote:...I think you misunderstand what I was asking.
Yup! :lol:
True freedom is a live Puppy on a multisession CD/DVD.
disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

Re: attach files to a pdf

#105 Post by disciple »

disciple wrote:
disciple wrote:If you are interested in "pdf portfolios" i.e. pdfs with attached files, pdfdetach can extract them. But mutool can do that and also attach them in the first place.
Poppler now also has a pdfattach.
Which only attaches one file at a time, and you can't attach it in place i.e. you need to write out the pdf to a new file.
I tested it for sending Windows executables via email (both outlook
and gmail block executables and at least gmail blocks e.g. zip files these days. Success. Dealing with it seems nice and simple.
Sejda has an option to unpack attachments, and an option to create a "portfolio/collection of attachments". I'm not sure whether or not that is actually different from attaching a file with mutool or pdfattach.
If I create a pdf portfolio with sejda, when opening it in adobe reader it complains that it needs to install flash, although it seems to work without it. I'm not sure if pdf portfolios always use Flash, or if it is just the way they've chosen to implement it in sejda. I guess for pdfs to support Flash it must be written into the standard, which seems rather stupid as one day soon (if not already) most people won't have Flash...

The versions of mutool I have to hand don't actually seem to have the portfolio feature... perhaps it is a compile time option?
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER
disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#106 Post by disciple »

I haven't tried the linux version lately, but the Windows Foxit Reader has a good interface for attaching files. Even Adobe Reader can attach files on Windows, although the interface isn't good.
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER
disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#107 Post by disciple »

https://github.com/arrufat/pdftag
Gui to edit pdf metadata, written in vala and uses poppler
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER
disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#108 Post by disciple »

People might find these snippets from http://www.imagemagick.org/Usage/formats/#ps interesting:
Multi-paged PDF Documents...

You can use perl to combine multiple PDF files, without resorting to a IM, and its rasterization problem...

Code: Select all

#!/usr/bin/perl
#  Script   pdf-combiner.pl
use strict;
use warnings;
use PDF::Reuse;

prFile('combo.pdf'); # Output.
for (qw/a b c d/) # Inputs.
{
  prImage("result_$_.pdf");
  prPage();
}
prEnd();
You can also use a JAVA toolkit to merge IM generated images into a PDF producing a better PDF than a simpler one that IM will generate...

Code: Select all

#!/bin/bash

for x in ./*.jpeg
do
    echo $x to ${x}.pdf
    convert $x -quality 75 ${x}.pdf
done

echo Merging...
java tool.pdf.Merge *.pdf
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER
User avatar
rcrsn51
Posts: 13096
Joined: Tue 05 Sep 2006, 13:50
Location: Stratford, Ontario

#109 Post by rcrsn51 »

Can you please clarify this? Is the objective to merge some individual PDFs into one file? Or is it to encapsulate some JPEG images into a PDF?
disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#110 Post by disciple »

disciple wrote:Another program I don't think I've mentioned, particularly for doing ocr on scanned pdfs, is the Windows freeware "pdf-xchange viewer", which apparently runs well in Wine.
I know there are some other topics here about linux OCR engines and guis, but I thought I'd mention ocrmypdf, which is probably the easiest solution for adding a layer of ocred text to a raster pdf. It is from the same author as pikepdf, which is basically a python wrapper library for qpdf.

EDIT

FWIW I did some testing with ocrmypdf.
IIRC the ocr backend it uses is tesseract. Recognition was perfect except for white space; so more accurate than pdf-xchange, which I had handy for a comparison.
It shrinks test files from the scanner at my work a bit. If I install jbig2enc (which requires leptonica) it shrinks monochrome test files even more.

I wanted to know how to remove scanned text so I converted to a new pdf using pdftocairo, which removed the text and made the file a lot bigger, so presumably it reencoded without jbig2. Interestingly, if I rerun that output through ocrmypdf the result is even smaller. I was dealing with a very small single page file though, so metadata and stuff might show as a big difference in size which wouldn't be noticeable with a large file.
Last edited by disciple on Thu 24 Oct 2019, 20:04, edited 1 time in total.
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER
disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#111 Post by disciple »

rcrsn51 wrote:Can you please clarify this? Is the objective to merge some individual PDFs into one file? Or is it to encapsulate some JPEG images into a PDF?
I presume you are asking about the snippets in my previous. One appears to be for combining pdfs and the other for creating a pdf from some images.
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER
disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#112 Post by disciple »

This is the best solution I can come up with for converting vector pdf to raster pdf. You can probably tell it is pulled from a script I run from a magic button to automate all kinds of useful things:

Code: Select all

# read in the output resolution (DPI)
read RES <image_resolution.txt
# check that RES is a number
if ! [[ "$RES" =~ ^[0-9]+ ]]
then
 RES="300"
 echo $RES>image_resolution.txt
fi
for i in !(*-rasterised).pdf
 do (
  mkdir "/tmp/$i"
  pdftocairo -jpeg -r $RES "$i" "/tmp/$i/0"
  jpegoptim "/tmp/$i/0"
  img2pdf -o "${i%%.*}-rasterised.pdf" "/tmp/$i/"*
# this method results in ugly pdfs sometimes, regardless of the compression and quality specified
#  ( convert -density $RES "$i" -compress jpeg -quality 75 -flatten "${i%%.*}-rasterised.pdf" ) &
# this method doesn't cope with spaces in filename
#  ( convert -density $RES {"$i","$i"-rasterised}.pdf ) &
  rm -R "/tmp/$i" ) &
 done
unset RES
Change the compression and quality arguments depending on the nature of your pdfs.
I thought that a tool like pdftocairo would be able to convert directly to a raster pdf, but I couldn't find any that can. It wasn't even obvious how to do it with ghostscript.
Imagemagick will convert from vector to raster pdf (using ghostscript), and is a much simpler (but slower) solution for multi page documents, but sometimes it produces bad results (even though it always produces good results when converting to normal raster image formats.)

EDIT - added jpegoptim line, which saves 10% of file size in my test.
Last edited by disciple on Thu 10 Oct 2019, 21:19, edited 1 time in total.
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER
disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#113 Post by disciple »

Change the compression and quality arguments depending on the nature of your pdfs.
I mean choose the right raster format (-png, -jpeg, -tiff options) to convert to with pdftopoppler, referencing how img2pdf will handle it:
| JPEG | any | direct |
| JPEG2000 | any | direct |
| PNG (non-interlaced) | any | direct |
| TIFF (CCITT Group 4) | monochrome | direct |
| any | any except CMYK and monochrome | PNG Paeth |
| any | monochrome | CCITT Group 4 |
| any | CMYK | flate |
You might need to use the -mono or -gray options.
It seems poppler to cairo doesn't actually allow you to specify jpeg quality or similar. Maybe an alternative like mutool would.
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER
disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#114 Post by disciple »

disciple wrote:2. pdf-xchange is the best "free" option I've seen for editing pdf bookmarks (no, this isn't a premium feature).
It looks like I never mentioned jpdfbookmarks in this thread, which is generally pretty good, but can't format the bookmarks, and seems to have a bug in its logic with export/import of complex outlines.
Two .NET/Mono based alternatives that look very good although I haven't tested extensively:
http://handyoutlinerfo.sourceforge.net/
https://sourceforge.net/projects/djvubookmarker/
Both work with pdf and djvu, the second is a lot more powerful it seems (formatting in particular). The first also provides a command line tool.
There is also a Windows freeware called "PDF bookmarks" from Skysof, which I haven't looked at at all.
Last edited by disciple on Thu 24 Oct 2019, 23:43, edited 2 times in total.
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER
disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#115 Post by disciple »

https://willus.com/k2pdfopt optimizes pdf/DJVU files for small screens, including reflow even of scanned files!
Check out the example screenshots on the home page.
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER
disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#116 Post by disciple »

Another couple of options for cropping pdfs:
https://pypi.org/project/pdfCropMargins/ powerful python command-line tool, with gui.
http://pdfcrop.sourceforge.net/ script which uses ghostscript and pdfedit.
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER
disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

Re: Briss - gui for cropping pdfs (Java based)

#117 Post by disciple »

disciple wrote:
disciple wrote:Another interesting Java based tool - just for cropping:
http://sourceforge.net/projects/briss/
This is a small application to crop PDF files. It helps the user to decide what should be cropped by creating a overlay of similar pages (=>all pages within a pdf having the same size, orientation(even/odd)).
Very similar to Briss, and also Java, is Pdf scissors

EDIT 20191021
I just cropped on Windows a study Bible with almost 2000 pages successfully using Briss, and it was very fast. Pdfscissors failed for some reason - I don't know if it was to do with the file size or something, but it took quite a lot longer and appeared to succeed, but the pages were not actually cropped.
I get the same results with a couple of other New Testaments; I guess perhaps Briss is succeeding because it is shipped on Windows with a newer version of iText than pdfscissors is...?
FWIW I just noticed there's a "pre-release" of an updated version of Briss at https://github.com/mbaeuerle/Briss-2.0/releases
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER
disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#118 Post by disciple »

pdfScale - bash Script to scale and/or resize PDFs from the command line (uses gs).

A few other tools have similar ability (currently not qpdf unfortunately) - see e.g. https://superuser.com/questions/676013/ ... mmand-line, which makes me realise - I don't think I've ever mentioned cpdf in this thread, because it used to be only available under a commercial license.

Cpdf is a very capable cross-platform command line utility that is now available free for personal use. There is also a standalone pdf "squeezer" available under the LGPL: http://community.coherentpdf.com/
Last edited by disciple on Thu 30 Jan 2020, 05:17, edited 1 time in total.
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER
disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#119 Post by disciple »

https://sourceforge.net/projects/moonshiner/ - pygtk GUI for ps2pdf - "use Ghostscript's power in converting PostScript to PDF without worrying about the complicated command line. Change image resampling options, encryption and prepress settings and more with a few mouse clicks."
Intended to be something like adobe distiller. There are other similar projects but I'm not sure if any are maintained (moonshiner doesn't appear to be).
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER
Post Reply