I ran into the same problem. In the end, I found out that I was mistaken due to a misunderstanding of the PDF format. We view PDFs as WYSIWYG for printers. This is not the case. In any kind of print stream, the PDF file is converted to some intermediate format, PostScript , TIFF or PCL usually.
This can happen on your local machine, so you need a driver or on the printer itself. If this happens on the printer, you simply transfer the PDF file to another computer with the conversion system installed.
This is all fine and dandy, except that PDF does not define the order of the pages, which is very inconsistent with the print format. This means that there is no front page of your document, and you cannot define it in any way in a form or form.
You have two solutions:
Choose your printer architecture and use your unique method of setting up a media type that is sick and intolerable.
Converting to a format that allows you to set the type of media and includes the idea of ​​organizing pages, such as PostScript. Then add your media commands and send this file along with your printer. If your printer has a driver for reading the selected intermediate format, it must convert the commands to its version of multimedia switching. It is more portable, but still not perfect.
This is similar to the idea of ​​converting your C program into an assembly to port it to the new architecture. It basically works, but you have to inspire every system.
Hypothetical conveyor:
Create your PDF file> run it through a PDF-to-PostScript conversion utility or library> run through a custom lexer to add media type commands on each new page> send to a PostScript file to the printer
This is a lot of work, but it is the only thing you will find to solve this problem.
Example
%{ char paper[] = 'yourPaper'; %} %option 8bit outfile="scanner.c" %option nounput nomain noyywrap %option warn %% showpage { printf("showpage\nsetpagedevice MediaType '%s'", paper); } %% int main(int argc, char **argv); int main (argc,argv) int argc; char **argv; { yylex(); return 0; }
The above is a very simple lexer to find every showpage command received from stdin and output the showpage setpagedevice command set. The setpagedevice MediaType command is an agnostic way to print the type of paper used for the page.
Compile code with flex and GCC :
flex -Cf scanner.l gcc -O -o lineCount.exe scanner.c
It takes input through stdin and outputs to standard output.
Below is a more complete lexer. It uses GNU getopts for command line options and has two rules, so it will also set the page device for the first page. This may not ideally capture pages, and it has only one variable for the paper type, so functionality is limited. On the other hand, it is very open, but you want it to determine the page device used.
Either the new rules for recognizing which page he is looking at, or the additional input file with one line on the page are those that immediately come to mind.
%{