<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="de-CH">
	<id>https://wiki.primat.ch/index.php?action=history&amp;feed=atom&amp;title=PDF_Barcode_Document_Management_CUPS_Printer</id>
	<title>PDF Barcode Document Management CUPS Printer - Versionsgeschichte</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.primat.ch/index.php?action=history&amp;feed=atom&amp;title=PDF_Barcode_Document_Management_CUPS_Printer"/>
	<link rel="alternate" type="text/html" href="https://wiki.primat.ch/index.php?title=PDF_Barcode_Document_Management_CUPS_Printer&amp;action=history"/>
	<updated>2026-05-09T13:38:56Z</updated>
	<subtitle>Versionsgeschichte dieser Seite in Primatenwiki</subtitle>
	<generator>MediaWiki 1.43.0</generator>
	<entry>
		<id>https://wiki.primat.ch/index.php?title=PDF_Barcode_Document_Management_CUPS_Printer&amp;diff=54&amp;oldid=prev</id>
		<title>Rbritt: Die Seite wurde neu angelegt: «Add a postprocessing script for tagging the printed pdf documents with a barcode for using with a document management software  == Install cups-pdf ==  &amp;nbsp;$ sudo apt install cups-pdf  == Configure cups-pdf ==  Configure the output path in the cups-pdf configuration file /etc/cups/cups-pdf.conf  &amp;nbsp;$ sudo vi /etc/cups/cups-pdf.conf  Change   &quot;Out ${HOME}/PDF&quot; to &quot;Out ${HOME}/Desktop&quot; for saving the pdf file on the desktop.&lt;br&gt;Add the to be created post…»</title>
		<link rel="alternate" type="text/html" href="https://wiki.primat.ch/index.php?title=PDF_Barcode_Document_Management_CUPS_Printer&amp;diff=54&amp;oldid=prev"/>
		<updated>2025-01-08T18:10:32Z</updated>

		<summary type="html">&lt;p&gt;Die Seite wurde neu angelegt: «Add a postprocessing script for tagging the printed pdf documents with a barcode for using with a document management software  == Install cups-pdf ==   $ sudo apt install cups-pdf  == Configure cups-pdf ==  Configure the output path in the cups-pdf configuration file /etc/cups/cups-pdf.conf   $ sudo vi /etc/cups/cups-pdf.conf  Change   &amp;quot;Out ${HOME}/PDF&amp;quot; to &amp;quot;Out ${HOME}/Desktop&amp;quot; for saving the pdf file on the desktop.&amp;lt;br&amp;gt;Add the to be created post…»&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Neue Seite&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Add a postprocessing script for tagging the printed pdf documents with a barcode for using with a document management software&lt;br /&gt;
&lt;br /&gt;
== Install cups-pdf ==&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;$ sudo apt install cups-pdf&lt;br /&gt;
&lt;br /&gt;
== Configure cups-pdf ==&lt;br /&gt;
&lt;br /&gt;
Configure the output path in the cups-pdf configuration file /etc/cups/cups-pdf.conf&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;$ sudo vi /etc/cups/cups-pdf.conf&lt;br /&gt;
&lt;br /&gt;
Change &lt;br /&gt;
&lt;br /&gt;
&amp;quot;Out ${HOME}/PDF&amp;quot; to &amp;quot;Out ${HOME}/Desktop&amp;quot; for saving the pdf file on the desktop.&amp;lt;br&amp;gt;Add the to be created post processing script in the postprocessing section:&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
PostProcessing /usr/local/bin/cups-pdf-barcode-tag&lt;br /&gt;
&lt;br /&gt;
== Create the PostProcessing script ==&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;$ sudo vi /usr/local/bin/cups-pdf-barcode-tag&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;FILENAME=$(basename $1) &amp;lt;br&amp;gt;&amp;amp;nbsp;DIRNAME=$(dirname $1)&amp;lt;br&amp;gt;&amp;amp;nbsp;firstpagefilepdf=/tmp/first.pdf&amp;lt;br&amp;gt;&amp;amp;nbsp;firstpagefilepdfstamped=/tmp/firststamped.pdf&amp;lt;br&amp;gt;&amp;amp;nbsp;restpagefilepdf=/tmp/first.pdf&amp;lt;br&amp;gt;&amp;amp;nbsp;barcodefileps=/tmp/barcode.ps&amp;lt;br&amp;gt;&amp;amp;nbsp;barcodefilepdf=/tmp/barcode.pdf&amp;lt;br&amp;gt;&amp;amp;nbsp;barcodefilepdfrot=/tmp/barcoderot.pdf&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;numberofpages=$(pdfinfo &amp;quot;$1&amp;quot; | grep Pages | awk &amp;#039;{print $2}&amp;#039;)&amp;lt;br&amp;gt;&amp;amp;nbsp;barcodetext=&amp;quot;DMSD&amp;quot;$(date +&amp;#039;%Y%m%d%H%M%S&amp;#039;)&amp;lt;br&amp;gt;&amp;amp;nbsp;newfilename=$DIRNAME&amp;quot;/&amp;quot;${barcodetext}&amp;quot; &amp;quot;${FILENAME}&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;#delete old tmp files&amp;lt;br&amp;gt;&amp;amp;nbsp;rm ${firstpagefilepdf} ${restpagefilepdf} ${barcodefileps} ${barcodefilepdf} ${barcodefilepdfrot} ${firstpagefilepdfstamped} 2&amp;amp;gt;/dev/null&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;&amp;lt;br&amp;gt;&amp;amp;nbsp;#generate barcode ps&amp;lt;br&amp;gt;&amp;amp;nbsp;barcode -b &amp;quot;${barcodetext}&amp;quot; -o ${barcodefileps} -e 128 -g 180x20+300+795 -n&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;#convert ps to pdf&amp;lt;br&amp;gt;&amp;amp;nbsp;ps2pdf ${barcodefileps} ${barcodefilepdf}&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;#rotate barcode pdf -90 degrese&amp;lt;br&amp;gt;&amp;amp;nbsp;pdftk ${barcodefilepdf} cat 1-endwest output ${barcodefilepdfrot}&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;#extract first page&amp;lt;br&amp;gt;&amp;amp;nbsp;pdftk $1 cat 1 output ${firstpagefilepdf}&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;#stamp first page with barcode&amp;lt;br&amp;gt;&amp;amp;nbsp;pdftk ${firstpagefilepdf} stamp ${barcodefilepdfrot} output ${firstpagefilepdfstamped}&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;#only if pdf contains more than 1 pages&amp;lt;br&amp;gt;&amp;amp;nbsp;if [[ $numberofpages -gt 1 ]]&amp;lt;br&amp;gt;&amp;amp;nbsp;then&amp;lt;br&amp;gt;&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; #extract rest pages (2-x)&amp;lt;br&amp;gt;&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; pdftk $1 cat 2-end output ${restpagefilepdf}&amp;lt;br&amp;gt;&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; #merge first and rest pages to new output file&amp;lt;br&amp;gt;&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; pdftk ${firstpagefilepdfstamped} ${restpagefilepdf} cat output &amp;quot;${newfilename}&amp;quot;&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;else&amp;lt;br&amp;gt;&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; pdftk ${firstpagefilepdfstamped} cat output &amp;quot;${newfilename}&amp;quot;&amp;lt;br&amp;gt;&amp;amp;nbsp;fi&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;#delete old tmp files&amp;lt;br&amp;gt;&amp;amp;nbsp;rm ${firstpagefilepdf} ${restpagefilepdf} ${barcodefileps} ${barcodefilepdf} ${barcodefilepdfrot} ${firstpagefilepdfstamped} 2&amp;amp;gt;/dev/null&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;#delete original file&amp;lt;br&amp;gt;&amp;amp;nbsp;rm $1 2&amp;amp;gt;/dev/null&amp;lt;br&amp;gt;&lt;br /&gt;
== Configure apparmor for allowing the postproccessing script to execute ==&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;$ sudo vi /etc/apparmor.d/usr.sbin.cupsd&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add before the last closing curly bracket } the following line:&lt;br /&gt;
&lt;br /&gt;
/usr/local/bin/cups-pdf-barcode-tag uxr,&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Restart apparmor and cups ==&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;$ sudo service apparmor restart&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;$ sudo service cups restart&lt;/div&gt;</summary>
		<author><name>Rbritt</name></author>
	</entry>
</feed>