Hot answers tagged

13

I'm surprised to find the premier free office software for Linux mentioned nowhere on this page. LibreOffice Draw will open a PDF and allow you to insert an image. If your signature file already exists in the file system as a PNG with a transparent background, it's a snap to get it onto a page, change the size and move it into place in Draw. Draw will save ...


8

There is no way to remove a page in Okular. However, it can refresh modified PDF document automatically so there is no need to re-open the document manually after modifying it in external tool such as pdftk. To remove a given page use cat option and specify a range of pages you'd like to keep in the target PDF file. For example, if you want to remove 5th ...


8

Solved it. The pages were being rendered on the computer because I had chosen a LaserJet driver from the Hewlett-Packard section of the CUPS printer management interface, implemented using Gutenprint. This worked fine for B&W text but poorly for color areas. After still not seeing a "PostScript" option in the configurator, I chose "Raw", and this works: ...


8

This is just a question of permissions. If a file has execute permissions, that just means users are allowed to execute it. Whether they will be successful is another matter. In order for a file to be executed, the user executing it must have the right to do so and the file needs to be a valid executable. The permissions shown by ls only affect the first ...


8

Yes. The file command covers this $ file x1.pdf x1.pdf: PDF document, version 1.7 $ To get greater detail, you could try pdfinfo, part of popper-utils. $ pdfinfo x1.pdf Title: Full page photo Author: steve Producer: Microsoft: Print To PDF CreationDate: Fri Apr 5 10:14:34 2019 ModDate: Fri Apr 5 10:14:34 2019 Tagged: ...


7

Definitely start with leaving the partition with the data alone, if at all possible (you would be surprised what you can recover even a month later if it is not your main system partition). Then proceed with foremost (I originally mentioned magicrescue but foremost performs just as well, yet it has a ready receipe for pdf sudo apt update && sudo apt ...


7

The green in your ls display means that the files have execute permissions, which doesn't necessarily mean that they can be executed in any way. If you accidentally set the execute permission, or if it was set due to an import from a file system without support for the basic linux permission model, you can remove the execute bit with chmod a-x -- "$...


5

On Debian (Bullseye) I've found the simplest (?) free way is to use Scribus 1.5.5 which can easily import a PDF (this may be possible in earlier releases, too): Import the PDF, then make an image box where you want your signature, choose your signature file, resize as necessary and then export as a new PDF (of course, you can use a text box to place ...


5

convert doesn't work for me. This (pdftoppm) works perfectly, however. Each of the below commands will ensure an "images" directory exists, creating it if it doesn't, and store the generated images into that directory. 1200 DPI mkdir -p images && pdftoppm -jpeg -r 1200 mypdf.pdf images/pg 600 DPI mkdir -p images && pdftoppm -jpeg -r 600 ...


3

You have only a basic groff installation. You can see this by finding the full pathname to the groff command: command -v groff It says /usr/bin/groff. Use this to find which package it came from: dpkg -S /usr/bin/groff It says groff-base. Look for other packages: apt search groff You just have to install the listed full groff package, which is just ...


3

I had this same problem so I wrote this over the weekend. Give it a shot; it works great! It is a simple wrapper around tesseract. It uses pdftoppm to convert a PDF into a bunch of TIFF files, then it uses tesseract to perform OCR (Optical Character Recognition) on them and produce a searchable PDF as output. All intermediate temporary files are ...


3

I know about headless Firefox and Chrome but I need to run it on a Debian server and call from PHP. If it works without problems then sure, NodeJS is fine Since you want to convert complex HTML to PDF, then you really need a HTML rendering engine, such as Chrome Headless. The following AGPL-3.0 project from the company I work for can accomplish what you ...


2

Thanks to OccamsRazor for his script, which does a great job of converting both color and grayscale PDFs into a compact and legible monochrome version. This is really a comment on OccamsRazor's post, but I don't have enough points to comment. The script will fail on img2pdf -o ./$output_pdf_name --dpi $dpi_res $input_files as --dpi is no longer an ...


2

Since it's included by default in many distributions, a shorter way to call libreoffice from the cli: soffice --convert-to pdf input.txt Supported extensions by soffice, we can convert from/to: ODF Spreadsheet .ods ODF Spreadsheet Template .ots Flat XML ODF Spreadsheet .fods Unified Office Format Spreadsheet .uos ...


2

Perhaps an updated version of @Gilles accepted answer with PyPDF2. Using Python 3 on MacOS. #!/usr/bin/env python # usage pdf_split_double_page.py 2-up-file.pdf output-file.pdf import copy, sys from PyPDF2 import PdfFileReader, PdfFileWriter input = PdfFileReader(sys.argv[1]) output = PdfFileWriter() for p in [input.getPage(i) for i in range(0,input....


2

moraes solution did not work for me. The main problem was the x5 and x6 calculation. Here an offset has to be considered, i.e. if lowerLeft is not at (0,0) So here is another variation, with additional adaptions to use PyPDF2 and python 3: import copy import math import PyPDF2 import sys import io def split_pages(src, dst): src_f = io.open(src, 'r+b'...


2

Inspired by the answer from bodo I created a simplified version in hope others can reuse/modify this easily for their purpose to sign a single page pdf. I'm not sure if this might also work for multipage pdf's. Save the following script as sign.sh. Given some pdf called origin.pdf you want to add an image, e.g. a png of your signature, somewhere in the pdf, ...


2

I have had a better experience with u2ps written by Alex Suykov which produces much smaller PDF files using system Unicode fonts. This program is not in Ubuntu or Fedora; you have to compile it yourself. The usage is the same: $ u2ps text.txt | ps2pdf - text.pdf (Compared to u2ps, paps output is huge).


2

Punchline: most likely what you actually want to do is to use the empty string for the user password and a non-empty string for the owner password, not the other way around. If you do this, people will be able to open the file without supplying a password, but compliant viewers will still enforce the document's security. Opening with the owner password will ...


2

Poppler provides a pdfinfo tool which can be used to determine the protections active in any given PDF. Restricted PDFs have encryption enabled, and pdfinfo will output (among other things) a line indicating this: Encrypted: yes (print:no copy:no change:no addNotes:no algorithm:RC4) So something like pdfinfo yourpdf.pdf | grep -q 'Encrypted:.*yes \(.*...


2

A function I use all the time to do exactly this. Just make sure the pdfs sort properly in sequence in the expansion. tp="/tmp/tmp.pdf" td="/tmp/data" for i in *.pdf; do echo "Bookmarking $i" printf "BookmarkBegin\nBookmarkTitle: %s\nBookmarkLevel: 1\nBookmarkPageNumber: 1\n" "${i%.*}"> "$td" pdftk "$i" update_info "$td" output "$tp" mv "$...


2

weasyprint is an alternative, packaged on debian bullseye/sid , it can be installed on a prior debian release through pip. python 3.5+ is required: pip install weasyprint weasyprint on github. Features.


2

Seems you might need to install HPLIP proprietary driver plugin: https://developers.hp.com/hp-linux-imaging-and-printing/models/laserjet/hp_laserjet_400_mfp_m425dn


2

Basic text selection According to the Zathura Wikipedia page: Zathura can search for text and copy text to the primary X selection This implies the ability to select text as you read is built in, though it likely requires your mouse (you'll be hard-pressed to find a solution for keyboard-controlled selection). How minimalist do you need? I use Atril, a ...


2

I'm not sure what you mean by programmatically, so here are some ideas. These days, all output targets PostScript, which is itself a language, so you could write your requests in that, but it is a little difficult. (PDF is mostly convertable to PostScript). However, to overcome some limitation of a conversion tool, you can often tweak the PostScript output ...


2

The accepted answer perpetuates myths and a poor understanding of how "executing" a file happens in Unix. ./cmd in the shell does more than just trying to execute ./cmd: if executing ./cmd fails with ENOEXEC (as it does for any executable file which is not a valid binary or doesn't start with a shebang, including a valid shell script) then the shell will ...


2

The manpage to pdfimages says pdfimages [options] PDF-file image-root So, your command pdfimages archive.pdf . instructs pdfimages to create the output files with filenames starting with a . - and this is exactly what happened, only that such filenames happen to have a special meaning in Unix/Linux. You can either re-run the command with a more ...


1

There are actually two clipboards. The primary clipboard is used by terminal and some applications and the other clipboard is used by most GUI applications like MS style copy/paste. Zathura, by default, copies the selected contents to the Primary clipboard that can be accessed by middle mouse button. This behaviour can be changed by adding set selection-...


1

LibreOffice Draw can read in a PDF, and then overlay it with graphical objects. Documentation is found at https://wiki.documentfoundation.org/Documentation/Publications#LibreOffice_Draw_Guide and a quick review is at https://www.techrepublic.com/blog/tr-dojo/edit-pdf-documents-with-libreoffice-draw/ Since you are working with layers, if you want,, you can ...


Only top voted, non community-wiki answers of a minimum length are eligible