Coder Social home page Coder Social logo

huysentruitw / print-it Goto Github PK

View Code? Open in Web Editor NEW
83.0 8.0 41.0 4.22 MB

Windows service for printing PDF files to a local or network printer in the background

License: MIT License

C# 100.00%
windows-service printing background pdf api api-service pdfium

print-it's Introduction

print-it

Windows service for printing PDF files to a local or network printer in the background.

Usage instructions

  1. Download the latest release
  2. Extract the package to f.e. C:\print-it
  3. Create print-it as a Windows service from an elevated command line: sc create "PrintIt" binPath="C:\print-it\PrintIt.ServiceHost.exe" start=auto
  4. Start the service from the command line: sc start PrintIt
  5. Check if the service is listening on port 7000 by running: netstat -a | find ":7000"

API

By default, PrintIt.ServiceHost is listening on http://localhost:7000. The endpoint is configurable in appsettings.json.

[GET] /printers/list

List all available printers on the system.

[POST] /printers/install?printerPath=\\REMOTE_PC_NAME\PRINTER-NAME

Install the network printer with the UNC-path \\REMOTE_PC_NAME\PRINTER-NAME.

[POST] /print/from-pdf

To print a PDF on a given printer, post a multipart form to this end-point with the following fields:

Field Name Required Content
PdfFile ✔️ The PDF file to print (Content-type: application/pdf)
PrinterPath ✔️ The UNC-path of the printer to send the PDF to
PageRange An optional page range string (f.e. "1-5", "1, 3", "1, 4-8", "2-", "-5")
Copies An optional number of copies (defaults to 1)

PDFium

This project uses the PDFium library for rendering the PDF file which is licensed under Apache 2.0, see LICENSE.

The version included in this repository under the folder pdfium-binary was taken from https://github.com/bblanchon/pdfium-binaries/releases/tag/chromium/4194.

print-it's People

Contributors

huysentruitw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

print-it's Issues

Workflows are referencing vulnerable actions

Hello, there!

As part of the university research we are currently doing regarding the security of Github Actions, we noticed that one or many of the workflows that are part of this repository are referencing vulnerable versions of the third-party actions. As part of a disclosure process, we decided to open issues to notify GitHub Community.

Please note that there are could be some false positives in our methodology, thus not all of the open issues could be valid. If that is the case, please let us know, so that we can improve on our approach. You can contact me directly using an email: ikoishy [at] ncsu.edu

Thanks in advance

  1. The workflow build-test.yml is referencing action gittools/actions/gitversion/setup using references v0.9.9. However this reference is missing the commit 90150b4 which may contain fix to the vulnerability.
  2. The workflow build-test.yml is referencing action gittools/actions/gitversion/execute using references v0.9.9. However this reference is missing the commit 90150b4 which may contain fix to the vulnerability.
  3. The workflow release.yml is referencing action gittools/actions/gitversion/setup using references v0.9.2. However this reference is missing the commit 90150b4 which may contain fix to the vulnerability.
  4. The workflow release.yml is referencing action gittools/actions/gitversion/execute using references v0.9.2. However this reference is missing the commit 90150b4 which may contain fix to the vulnerability.

The vulnerability fix that is missing by actions' versions could be related to:
(1) CVE fix
(2) upgrade of vulnerable dependency
(3) fix to secret leak and others.
Please consider updating the reference to the action.

If you end up updating the reference, please let us know. We need the stats for the paper :-)

Not show digital signature

Thank you for sharing.
The solution works fine.
I have a pdf file with a digital signature, after printing it does not show this digital signature, do you have a solution?

Optional page range that needs to be printed

It should be made possible to pass an optional page range to the print command, so we can specify which pages from the PDF needs to be printed.

Suggestion 1: Add FromPage and ToPage parameters
The API model for the print/from-pdf endpoint (https://github.com/huysentruitw/print-it#post-apiprintfrom-pdf) could be extended with 2 optional values:

  • FromPage (Optional value, ranging from 1 to the number of pages)
  • ToPage (Optional value, ranging from 1 to the number of pages)

When ToPage is not specified, but FromPage is, start from FromPage (inclusive) and print to the end.
When FromPage is not specified, but ToPage is, start from the beginning of the document and print until ToPage (inclusive).
When ToPage < FromPage, throw an error.

This suggestion is rather limited to a single range and doesn't allow complex ranges like you could pass to other print dialogs.

Suggestion 2: Add Pages parameter
The API model for the print/from-pdf endpoint (https://github.com/huysentruitw/print-it#post-apiprintfrom-pdf) could be extended with an optional Pages parameter.

The Pages parameter takes a comma-separated string that supports single pages as well as page ranges, examples:

  • 2 -> Only prints the 2nd page.
  • 2-4 -> Prints the 2nd page, until the 4th page.
  • 1,3-5 -> Prints the 1st page followed by the 3rd until the 5th page.

PdfiumCore auto-generated bindings

Great project! The only one i on the web that makes it super easy to print pdfs on windows.

Question: Could we use the PdfiumCore auto generated bindings instead of using pinvoked functions inside the print-it project?
I believe it would provide easier updates to the library.
Im working on a fork that would use them, but im not sure why it was not used originally - maybe you could help a little

The library has no FPDF_RenderPage anymore, but FPDF_RenderPageBitmap
Im struggling to convert it because print-it uses System.Drawing.Graphics and the pdfium prints the pdf to PdfiumCore.fpdfview.FpdfBitmapT. I dont know easy way around it.
From what i understand if something about Device-Dependent Bitmaps (DDBs) vs Independant ones = bitmap vs HDC (?)

I dont expect full answer, but just a hint if you know how to approach it

Printer always chooses tray 1(not what is configured as default under printing preferences)

I have installed two printers on the host where Print-It is installed. One printer has tray 1 set to the default, the other has tray 2 set to the default. If I print a test page they print from the correct trays.
However when I use print-it they always print from tray 1.

If it would use the default that would be great, if not it would be great to be able to pass a tray selection as an optional parameter when printing the PDF.

Target framework of PrintIt.Core

Currently, the target framework of PrintIt.Core is netcoreapp3.1.
I tried to switch it to netstandard2.1, and the build also succeeded.
Do we have any reason to use netcoreapp3.1?

Command line tool

Any plans to make this into a command line tool too? My C# skills are unfortunately not the best otherwise I'd be happy to contribute with a PR

Add the spool name

Great software!
Do you plan to add arguments (spool name)?
All spools from this software are "document".
I would like to set the filename as the spool name.
thank you.

Scaling/Zooming Problem

The api doenst give a setting on scaling/zooming when printing. It seems it uses the default option which it could "adapt" the printing content to the page. And sometime is not intended result.

Can't get the web server to respond

Trying to get this setup, and I can't seem to get the server to respond. At first I thought it was an issue with the service registration or something, so deleted and registered it using NSSM. That also didn't work. Pulled the source and fired up the project and it says it's listening on the correct host:port combo, but no luck. I've tried a variety of ports, checked everything simple I can think of. Anyone else running into this?

Can't get a response from the running registered service with Postman

I think I did have the service registered and running correctly before, but I was trying to use postman and a web browser to check that I'd set things up correctly. Now I can see the port is listening with Netstat, but still get 404's when trying to add printers or list them using postman.

I've tried several things... Everything returns a 404
GET
http://127.0.0.1:7001/api/printers/list
http://localhost:7001/api/printers/list

POST
http://127.0.0.1:7001/api/printers/install?printerPath=\\printserver\DDG1

Any ideas on what could be going on here? A coworker is having the same issues...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.