From 3a49ec24220a0ab08e47de7a73b6fba6da66a862 Mon Sep 17 00:00:00 2001 From: chuckcharlie Date: Fri, 11 Apr 2025 08:59:15 -0600 Subject: [PATCH] Fix na-letter paper size --- Dockerfile | 36 ++++++++++++++++++++++++++-------- root/root/airprint-generate.py | 25 ++++++++++++++++++----- version.txt | 2 +- 3 files changed, 49 insertions(+), 14 deletions(-) diff --git a/Dockerfile b/Dockerfile index d572c1b..a2b1eb5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM alpine:3.19 +FROM alpine:3.20 # Install the packages we need. Avahi will be included RUN echo -e "https://dl-cdn.alpinelinux.org/alpine/edge/testing\nhttps://dl-cdn.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories &&\ @@ -8,12 +8,7 @@ RUN echo -e "https://dl-cdn.alpinelinux.org/alpine/edge/testing\nhttps://dl-cdn. cups-client \ cups-filters \ cups-dev \ - gutenprint \ - gutenprint-libs \ - gutenprint-doc \ - gutenprint-cups \ ghostscript \ - brlaser \ hplip \ avahi \ inotify-tools \ @@ -22,9 +17,31 @@ RUN echo -e "https://dl-cdn.alpinelinux.org/alpine/edge/testing\nhttps://dl-cdn. build-base \ wget \ rsync \ - py3-pycups \ + py3-pycups \ && rm -rf /var/cache/apk/* +# Build and install brlaser from source +RUN apk add --no-cache git cmake && \ + git clone https://github.com/pdewacht/brlaser.git && \ + cd brlaser && \ + cmake . && \ + make && \ + make install && \ + cd .. && \ + rm -rf brlaser + +# Build and install gutenprint from source +RUN wget -O gutenprint-5.3.5.tar.xz https://sourceforge.net/projects/gimp-print/files/gutenprint-5.3/5.3.5/gutenprint-5.3.5.tar.xz/download && \ + tar -xJf gutenprint-5.3.5.tar.xz && \ + cd gutenprint-5.3.5 && \ + # Patch to rename conflicting PAGESIZE identifiers to GPT_PAGESIZE in all files in src/testpattern + find src/testpattern -type f -exec sed -i 's/\bPAGESIZE\b/GPT_PAGESIZE/g' {} + && \ + ./configure && \ + make -j$(nproc) && \ + make install && \ + cd .. && \ + rm -rf gutenprint-5.3.5 gutenprint-5.3.5.tar.xz + # This will use port 631 EXPOSE 631 @@ -48,4 +65,7 @@ RUN sed -i 's/Listen localhost:631/Listen 0.0.0.0:631/' /etc/cups/cupsd.conf && sed -i 's//\n Allow All/' /etc/cups/cupsd.conf && \ sed -i 's/.*enable\-dbus=.*/enable\-dbus\=no/' /etc/avahi/avahi-daemon.conf && \ echo "ServerAlias *" >> /etc/cups/cupsd.conf && \ - echo "DefaultEncryption Never" >> /etc/cups/cupsd.conf + echo "DefaultEncryption Never" >> /etc/cups/cupsd.conf && \ + echo "ReadyPaperSizes A4,TA4,4X6FULL,T4X6FULL,2L,T2L,A6,A5,B5,L,TL,INDEX5,8x10,T8x10,4X7,T4X7,Postcard,TPostcard,ENV10,EnvDL,ENVC6,Letter,Legal" >> /etc/cups/cupsd.conf && \ + echo "DefaultPaperSize Letter" >> /etc/cups/cupsd.conf && \ + echo "pdftops-renderer ghostscript" >> /etc/cups/cupsd.conf diff --git a/root/root/airprint-generate.py b/root/root/airprint-generate.py index 146e3f2..da17055 100644 --- a/root/root/airprint-generate.py +++ b/root/root/airprint-generate.py @@ -186,10 +186,25 @@ class AirPrintGenerate(object): color.text = 'Color=T' service.append(color) - if attrs['media-default'] == 'iso_a4_210x297mm': - max_paper = Element('txt-record') - max_paper.text = 'PaperMax=legal-A4' - service.append(max_paper) + # Add paper size support with standard AirPrint format + paper_sizes = Element('txt-record') + paper_sizes.text = 'PaperMax=na-letter' + service.append(paper_sizes) + + # Add supported paper sizes with dimensions + supported_paper = Element('txt-record') + supported_paper.text = 'PaperSize=na-letter:8.5x11in,A4:210x297mm,A5:148x210mm,A6:105x148mm,EnvDL:110x220mm' + service.append(supported_paper) + + # Add paper size support flag + paper_support = Element('txt-record') + paper_support.text = 'PaperSize=T' + service.append(paper_support) + + # Add additional paper size attributes + paper_attrs = Element('txt-record') + paper_attrs.text = 'PaperSizeSupported=na-letter,A4,A5,A6,EnvDL' + service.append(paper_attrs) pdl = Element('txt-record') fmts = [] @@ -286,4 +301,4 @@ if __name__ == '__main__': adminurl=options.adminurl, ) - apg.generate() + apg.generate() \ No newline at end of file diff --git a/version.txt b/version.txt index e25d8d9..26aaba0 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.1.5 +1.2.0