Print PDF in server side to default printer - c#

I created web application using ASP.NET CORE 2 and used DinkToPdf to create and download the PDF to target directory. It is working really well to create and save PDFs. Now I want to use server side and print the PDF to target printer in the office. I couldn't find any solution to do this. Please help me.

Are you looking to integrate this functionality into your software? If so, there are several PDF libraries on the market with printing capabilities, some more reliable and full-featured than others.
If you're looking for a Windows command line utility to print PDFs to a target printer, you may be interested in PDF2PRINT, which allows you to do exactly that, as well as set optional parameters like duplex, collation, custom page ranges, number of copies, etc.
For future reference, questions like these should be posted in the Software Recommendations forum.

Related

Dynamic content replacement using Adobe Illustrator and C#

We are currently looking for a way to automate part of our design/development process. Our product is an asp.net mvc multi-tenant website and we have a need to create marketing materials (such as banners and leaflets) and letters for each of our clients, dynamically replacing content like client names, urls, logos, etc. where necessary.
We have a third party designer working in illustrator, and then porting the designs over to a work document. This is so we can do our content replacement using word automation from our Windows service. We then export these files to PDF, PNG or JPEG and allow users to download them.
As we are growing, we've realised that it's no longer viable to using the word automation on the server to produce these documents and we are looking for alternatives.
I've currently investigated a few different avenues, such as replacing the need for word with just using illustrator on the server and making our content replacements there but this appears to have the same issue, as well as not running headless. Another route that we've considered is looking at indesign server, however I think this is overly complicated for our scenario and definitely over priced.
A lot of places seem to suggest doing ai files to html and then performing our content replacement there. However, one of our needs is the ability to be "print ready" from these PDFs, so I'm not sure if that's possible.
I think I might have reached the end of my research path, so I'm looking to see if anyone else has created a similar system for custom content replacement?

Return a PrintDocument() as a PDF in web project

I have an existing, and very complex, library that generates a System.Drawing.Printing.PrintDocument() that is used to send print jobs directly to a printer.
I now need to take this existing library and generate PDF documents for a web application.
I tried looking into 3rd party libraries such as ABCpdf, Spire.PDF, PDFSharp, etc, and none of them seem to be able to take a PrintDocument as input. At least none of their documentation indicated they could.
There are a couple of other questions here regarding this, but none of them point to an actual solution or library that works.
Installing a print driver such as Bullzip doesn't seem to be an option either as I need to return the rendered PDF through the web application.
What options are there for taking a PrintDocument(), rendering it as a PDF, and then serving it through a web application?

.NET graphic libraries to display images (pdf, .docx and any other format of image) in the browser

I am developing a ASP .NET MVC application where users are able to upload files to a repository. Those files could be pdf, doc, any type of image and so on.
When the user select a file to be imported I would like to display this file in the browser so they can review its contents before the upload.
I know I could use some sort of IFrame to display pdf but I am looking for some specific class or .net libraries to implement this feature.
I just need a north.
This is an extremely difficult problem. There are some libraries that can help. For instance PDF files might be rendered to images with ghostscript. Word and Excel files might be converted to PDF or image with a number of libraries. None of them, AFAIK, are very good at it so I can not recommend one.
You could automate MSO to perform the conversion to PDF, but that is decidedly not safe for server code. Another possibility is convert source documents to SWF files (like flexpaper) and display in flash. There are some great libraries out there, but it will limit your supported clients. Sharepoint has support for providing some of this capability as well. Others have used OpenOffice to convert MSO documents but also at a loss of quality.
I can't really advise any specific direction as it is highly dependent on what you/your company is willing to spend and the desired results. Good luck.
You could try to rely on Windows and the explorer thumbnails for it, like here, but then you'd have to make sure that:
You can abuse the server in the most elaborate way (install stuff, talk to the shell from ASP.NET)
You have a thumbnail provider installed on the server for every type that you want to preview. I guess from the moment you can see the thumbnail in explorer, you're set. So for pdf, you might need to install PDF Reader from Adobe.
Docx files should be saved with thumbnail checked (see link). There seems to be no other easy, free way to convert a docx to a thumbnail. The "best" solution I came across, was saving it automatically again somehow, and making sure the thumbnail option is checked.
I don't want to say that's impossible, but it can't be done with finite effort.
What you are asking for is a browser-based solution, because you want the user to be able to "review" the document before uploading.
Therefore you cannot use a server side solution, which is essentially what is being asked by referring to a ".Net library".
.Net libraries are dependent on an installed version of .Net, which does not exist in all versions for all operating systems for which graphical browsers exist.
Next, recent changes in browser security do not allow to read the full client-side file name of the selected file in the input field.
You'd have to rely on HTML5 and its FileReader to access the file's byte stream, but even then you can only retrieve image from image files. (see sample)
Excluding browser-based solutions in Flash, ActiveX, Java, due to browser and platform support, this leaves JavaScript as the only "reasonable" solution: you'd need a library for each supported format to either convert a file into an image in an image format supported by browsers, or extract the text(+image) representation of a file.
Great awnsers... Just want to share the result of my research and I found a nice client-based solution supported by Mozilla Labs. This is a framework based on HTML5 and Javascript with no native code needed.
Here the project website:
https://github.com/mozilla/pdf.js
This is what you are capable of:
http://mozilla.github.com/pdf.js/web/viewer.html
And for the last a great video explaning how everthing works
http://www.youtube.com/watch?v=Iv15UY-4Fg8&noredirect=1
Reguarding my question we are going to converter every possible file to PDF on the server and then render this PDF using this framework.

How to print formatted labels from c#

I'm writing a program that will (among other things) print out labels with variable information. I want to be able to format these labels (preferably in a GUI) at design-time, then have them print out at runtime. What tools/languages/projects can I use to accomplish this?
The label needs to include text and also Code39 or Code128 barcodes.
Printing will be done on a normal default printer, or possibly a label printer, unknown at this time.
Preference is for open-source, free projects, but any suggestions are appreciated. I'd also like to be able to distribute the program through xcopy, meaning no separate installations needed on the client.
EDIT: I'm now trying to do this using Microsoft Reporting services in local mode, but I'm still having problems getting the barcode to be readable.
There is a simple walkthrough of using our programmable ActiveReports product to do this here. Once you design the labels you can get them in PDF or print them directly (among other things). Another example of using ActiveReports to create a label maker program is here. That one uses the ActiveX/COM edition of ActiveReports but the concepts are still the same in the C#/.NET version.
We also provide a product named Data Dynamics Reports that uses a page-based metaphore for designing reports rather than the banded metephore like ActiveReports. It includes a label wizard which you can find out more about at this link.
Scott Willeke
GrapeCity inc.
Using Microsoft Reporting Services I can use a local report. Its not xcopy, but it is free and relatively easy. I just have to install report viewer on the client (and the barcode font), then I can even run the .exe from a network share.

Best way to print Invoices, Pick Tickets etc

Well, heres my scenario.
Client/Server winforms application with SQL Express as the DB. I need to be able to print invoice, packing slips etc..
i would like the customer to be able to modify the invoices. ie. be able to put their logo or change font sizes etc...basically format the display.
Things i have considered so far are.
1) Use a template engine (similar to codesmith or mygeneration) and use templates that output HTML. Then print the html page.
2) Use ReportViewer in local mode. I've heard that users can download a plugin for web dev express and edit the local report files. can anyone confirm this?
3) Use Reportviewer in remote mode.
I don't have much experience with ReportViewer so I'm not sure if i should use local or remote mode as well.
Those of you that have done this kind of thing before whats your recommendation?
After just completing a project with it, I would heartily recommend iTextSharp to create your invoices and other forms as PDFs. In addition to creating PDFs from scratch, you can also use it to fill in PDF forms and/or templates created with Acrobat (or even MS Office/OpenOffice). And it's free.
It's pretty easy to use in Windows apps or in ASP.Net applications. Most of the documentation and the books on it (iText in Action, for example) are about the original Java version, iText. However, there are tutorials and example code on the conversion process and, for the most part, all of the functions and libraries work the same in the .Net version, so adapting the book and reference code has been no problem.
I definitely learned the hard way that HTML and CSS are great for browsers (well, great except for the "every browser interprets it different" problem), but horrible for trying to generate consistent, attractive, and precise printed output and forms.
I'm personally using Aspose Words: they use word documents as templates, and I'm using Words bookmarks function to mark and retrieve the fields I need to fill.
Aspose works nicely with Tables (ie: you can add lines to a table, etc...) and sees Word documents as XML documents. You can then save the document as MSWord or PDF.
I wouldn't say it's the greatest library in the world, but it's definitely worth having a look :)
you can use Crystal Report for this. But first you need to scan the INVOICE and save it as an image,
Next is, on your crystal report, export the image on to it, and DRAG the fields to where they must print on the invoice (IMAGE SERVES AS YOUR GUIDE). Then after everything has been set-up, DELETE THE IMAGE and try it.
hope this helps.

Categories