-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How print a very long single page PDF #4736
Comments
but I only got one A4 width page. is how the default printer is defined. SumatraPDF does not alter the source page dimensions nor describe how to be printed. Those are all set by the system but there are constraints. SumatraPDF will simply honour the system settings at the time of print handover as pixels so if the system requires A4 pages or requires USA Letter then SumatraPDF uses those page defined pixels units. Printers have a limited length of paper sizes so a GhostScript printer may easily be limited to a nominal 2 m or 5 m but SumatraPDF can use those length no problem. If you are using PDF to be printed to a non default size then GhostScript PDL is probably the best command line method. For a heads up use it is more restricted. I have shown SumatraPDF can work with pages of up to 200" nominal length but dont recommend it be done that way. https://stackoverflow.com/a/78321355/10802527 |
I still don't quite understand, what do I need to do to print this file completely? I just tested using GhostScript to print this file directly, and it can only print the first page (A4 length) gswin32 -dNOPAUSE -dBATCH -sDEVICE=mswinpr2 -sOutputFile="%printer%EPSON LQ-82KF ESC/P2 (副本 1)" -dDEVICEWIDTHPOINTS 794 -dDEVICEHEIGHTPOINTS 6060 output1.pdf I tried many solutions, but it still doesn't work. Am I trying the wrong direction? |
Command line printers expect to be run in a system command console you seem to be trying to print from within some windows wrapper application ? Try your commands in the windows command console before move to any form of embedment. use gswin32C.exe PDF is unitless but has a maximum length so you need to debug what units you are attempting. If the file is long and the printer short you need to slice the page into parts (decimation) MuPDF has a poster command. Mutool poster -x 1 -y ## as may be required to be less than A4 high For finer control over where a page is split it will need a more complex approach such as via coherent cpdf read chapter 9.3 Chopping up pages |
Thank you very much for your patience. Yes, we are developing a program for printing HTML to a printer. At first we tried to print directly, but encountered paging problems. Then we tried to make the HTML into a long single-page PDF, but it seems that software like SumatraPDF or pdftopinter can not support direct printing. I used mutool to crop the file according to your method. From the PDF point of view, there is indeed no upper and lower margins, but when it is printed out through the printer, a blank line will still be generated after printing a page. I think this blank line is because of the natural behavior of the printer, which can't be avoided by the way we cut pdf. I feel powerless. |
PDF in effect is borderless i.e. does not have any "margins" as such cpdf has the ability to modify page shapes to suit 4 x A4 high before chop and had shown such example in other forums but was deleted ! If you simply need images of pages to send to a printer since ink can be pixels not vectors, it is perhaps simpler to use Magick and here I described a similar case. https://stackoverflow.com/a/78615507/10802527 the accepted answer (below mine) may or may not be better. dont worry about the maths concentrate on the reasons for each of my 3 methods and the accepted method (not mine) is discussed here ImageMagick/ImageMagick#7402 |
It depends. This problem has nothing to do with cropping. I have provided a cropped PDF here. You can see that there are no borders. However, after printing a page through the printer, the printer will still retain 2 lines of blank space. mutool -x 1 -y 5 out.pdf I'm trying other methods, maybe I don't need to convert HTML to PDF before printing |
Hmmm several problems with such tables. They are best created with a Spreadsheet application such as Excel where there each page can be controlled with new headers per page. Microsoft Edge says page size is "280 × 428 mm (portrait)" I know that is clearly wrong so the pages are physically 210 x 321 mm ? which is not European nor American printing paper. A bigger problem is that it is "tabular" so no easy places to cut unless you aim for a border between cells. The one tool I know can split with such precision (but needs some trial and error to get perfect) is cpdf -chop-h where you split and split again until all pages are done. Recently gave an example elsewhere of vertical slicing with 2 precision cuts but it worked https://stackoverflow.com/a/79314388/10802527 |
OK forget that suggestion it is exceptionally slow in chopping a very long page such as that, and would be hard to decide where to split. We call this an XY problem where trying to fix a bad input simply is not worth it when the problem lies with the generation of such un-paged format. Page Breaks should be done at the source, or for a roll printer use the printers own language e.g. HPGL for a plotter or ZPL for a Zebra.
|
Is your feature request related to a problem? Please describe.
I have a very long A4 width pdf. My printer is a dot matrix printer that can automatically feed paper. I tried to use this software to print it, but I only got one A4 width page.
Describe the solution you'd like
What I hope is to be able to achieve something like custom paper, so that the content of this page can be printed out completely (without scaling)
Is it possible to customize a paper size by read the width and height of the PDF when printing?
Describe alternatives you've considered
My current alternative is to render the PDF into A4 width and height, divided into many pages, which can be printed at present, but because each page has a little blank space at the end, the printed content will be interrupted (my PDF is a long table)
Additional context
print_1735184594331.pdf test pdf file
The text was updated successfully, but these errors were encountered: