I read that the XPS printer in Windows 8 produces OpenXPS (.oxps) files whereas its counterpart in earlier Windows versions produce XPS (.xps) files. So printing XPS files under Windows 8 implies a compatibility issue. Fair enough. But, what type of file does the CreateXpsDocumentWriter method create?
Does it use the XPS printer? If yes, how can you detect which XPS/OXPS setting the printer has? Or is it possible to choose XPS/OXPS via an API?
If the extension is oxps, chances are that you got an openxps. try renaming it to .zip. If it's openXPS, you will be able to view the contained parts.
According to the remarks in the XpsDocument class description, you will get XPS, not OpenXPS
("For more information about XPS see the XML Paper Specification (XPS) available for download at http://go.microsoft.com/fwlink/?LinkID=65761.")
Related
We use WKHTMLTOPDF to create PDF documents out of HTML in our C# Project.
But we have to be PDF/A compliant with our PDF-Files.
At the moment we use another external component to convert from PDF to PDF/A
Is there no direct way to generate PDF/A compliant documents with WKHTMLTOPDF?
Maybe a WKHTMLTOPDF "Fork" or something?
Not currently (has been an open issue since 2014)
PDF/* are SUPERsets (designed by committee) of good old functional PDF 1.0 ideals.
That is certain things MUST and must NOT be included.
WKHTMLTOPDF is built on QT WEBKIT viewer where those requirements are not needed in order to display PDF i.e. it can display some but not all conforming and non conforming PDFs, its a PDF viewer not creator.
You can as you know use GS to adjust and create the parts needed for some PDF conformances
Your best viable alternative is to use open source iText 7 specifically:-
https://github.com/itext/i7n-pdfhtml
an iText 7 add-on for C# (.NET) that allows you to easily convert HTML and CSS into standards compliant PDFs
I'm trying to generate a PDF that can be viewed interactively in Adobe Reader, but also, upon printing, selects different paper trays based on the page. (Some pages are supposed to use stationery, whereas other must not.)
PDF itself apparently doesn't support this form of metadata by design (as discussed e.g. here), but apparently, JDF is an appropriate format, and can be embedded as XML in the PDF.
What's less clear to me is if Adobe Reader does anything useful with that metadata: if a PDF with embedded JDF information is printed, does it parse the JDF and choose paper trays? Can I use PDF portfolios for this purpose instead?
My goal is to both let the user view the PDF in Adobe Reader interactively, and, upon printing, automatically selecting different paper trays.
(The far less convenient alternative would be to write a custom app to do the printing.)
You are right, PDF describes the artwork while the JDF describes the metadata about print. However, JDF is targeted to industrial printing systems rather than for desktop printers. As far as I know does Adobe Acrobat Reader not support this kind of feature based on a JDF.
In order to control the different paper trays of your printer, you may setup your printer several times - one for each tray and switch the flag "default printer" in the background programmatically.
Another idea could be to use the Acrobat Reader only for viewing purposes and using the command line for printing.
There are concepts of how to put metadata into the PDF directly (see: https://confluence.cip4.org/display/PUB/PDF+Intent), but it could take a while until this specification is gonna to be implemented.
I need to convert a Word document (docx) to a postscript file so that I can use this postscript file to generate PDF using the Ghostscript command line tool.
How do I generate the postscript file from the docx?
I need to code using .NET/C#. I found about LaTeX which generates postscript but how do I make my Word file be used with LaTeX or any other tool to get the postscript generated?
There are three main products I will mention that understand DOCX.
The obvious one is MS Word. It produces the definitive rendering of all DOCX files. Nothing is ever going to be exactly the same. By definition it is always correct. However it is not really designed for automated conversion and getting it to do this kind of thing is fraught with difficulty. On a legal level the EULA may confict with your chosen solution.
OpenOffice.org is a great product. The EULA is much more accomodating. The freeness is attractive. However, while it will produce a pretty good output for most DOCX documents it does not for all. While it is similar to MS Word it is not the same and this is something you may notice, particularly for more complex documents. Probably more importantly, again it's not designed for automated conversions and trying to get it to do this can be fraught and tiresome.
WordGlue .NET (on which I work) is a native .NET library that understands DOCX. It is designed specifically to produce output which is the same as MS Word. While I'm not going to say it is perfect (it's a big task) it is superior to OpenOffice.org in that it does actually attempt this as a specfic design decision. However probably the biggest advantage is that it is designed for high perfomance multi-threaded server side conversion. It's native .NET and thus low impact in terms of security.
Products like ABCpdf (on which I work) will integrate with these three applicatons to allow conversion direct to PDF. Why bother going via PostScript if you want PDF? However if you really want to save as PostScript you can do that too.
Or indeed you can write your own code to integrate with these products. Just be aware of the caveats above regarding fraughtness and tiresomeness relating to MS Office and OpenOffice.org. To get these things working unattended requires an awful lot of attention.
You need to print it to a PostScript file, from an application which can read .docx files. Or you could just export direct to PDf from the app, as far as I know anything which reads .docx and can print, can also write a PDF file.
If you have a windows computer you can use the commandline
"%ProgramFiles%\Windows NT\Accessories\wordpad.exe" /pt foobaar.docx "printerThatDumpsPS"
You can find file printers for postscript printing for free on the internet. Or if you have adobe pfdf, pdf exchange or any PS printer. You can use c# to temporarily set the printers settings so that it does this for you.
So for example using pdf exchange as follows,
"%ProgramFiles%\Windows NT\Accessories\wordpad.exe" /pt foobaar.docx "PDF-XChange Printer 2012"
Produces a pdf file without much of a trace anywhere what program was used, assuming pdf exchange was set to save file without asking.
This produces a passable document but yeah it looses quiet many features. But it might be enough.
The Goal
The company I work for currently uses a black box shipping system. Each morning our shipping manager prints out shipping tickets for his drivers. Using C#, I would like to save a copy of each ticket printed as a PDF. The action of saving to a PDF should be done behind the scenes.
Note: The PDF copy would be in addition to the hard copy, however, I would like to generate the PDF copy when the hard copy is printed (or directly after if I can use the saved print job).
End Result: The manager prints a hard copy and a PDF gets saved to an archive folder without any interaction from the manager.
What I've Tried
I've instructed the printer to "Keep printed documents" after printing. This leaves a .shd and a .spl file in the print spool folder. I've experimented with the PrintDocument class, but I can find no way to instruct a job to reprint (to a PDF driver) using a completed print job.
Question
Is what I'm trying to accomplish possible?
Further Clarification:
In case it wasn't clear, I do not want the manager to print the document a second time to a PDF print driver. On average he must print 60 tickets each morning before he can send his drivers out. I don't want to increase that number to 120 AND force him to type in the file names.
Additionally, the "black box" shipping system includes other modules that run other portions of our manufacturing plant - changing software is not an option.
I suggest you go with an existing solution to problems like this: Use a software that can install virtual printers that print the document on the printers you want. One such software is PrintDistributor. I don't have any experience with this software but the screenshot named "Virtual Printers" looks promising: The second printer is named "Print and save".
There is other software like this, see here.
According to your goal that you don't want to force him to enter file names, You should do this:
Use a PDF Printer software that provides automatic file naming, like these:
PDF Desk
Cute PDF
And tell the manager to print tickets just with that PDF Printer.
Then, write a c# or vb.net application. use FileSystemWatcher to detect if a new file is created in PDFs directory. and when a new PDF is created, print it.
Here are some tutorials that explains how to Print a PDF file in c#:
Print existing PDF (or other files) in C#
Printing PDF documents in C#
Trapping things being sent to the printer can be very tricky.
A simpler way would be to set up a 'pdf printer' using a piece of software such as:
http://www.bullzip.com/products/pdf/info.php
Configure this to output to a specific directory, and then write a windows service to monitor the directory and automatically send PDF files to the physical printer and archive the file off to a network folder.
[and remove the printer driver from his PC so he can't bypass your new system]
Issue two print commands... one to the paper printer, one to the PDF printer.
Does anyone know if the following is possible and if so what the best way of doing it is for free?
I am generating a PrintDocument in a project I am currently working on and displaying a print dialog box so a user can choose which printer they want to use etc. The is currently a windows form application and if a user wants to print to a PDF they can select to print to CutePDF or something similar.
However I am now putting a ASP.Net web frontend on the application and want to use the same code to generate the PrintDocument but want to print it to a PDF on the fly and serve it up via the Response stream in the format of a PDF download.
So my question is....How can I use the current PrintDocument and generate a PDF in memory from it??
Thanks
The System.Drawing code for a PrintDocument can be reused to generate a PDF document with ABCpdf .NET. See the System.Drawing example...
You would have to use a 3rd party component in order to generate the PDF. The following article has some links to some such components: Generating PDF Files from .Net
You're in a world of hurt if you think you're going to run the "same code" that deals with printers in both a forms app and an ASP.NET app.
You might be in luck, however, as it appears that PDFsharp + MigraDoc might be able to do this for you.
I think you will find there is not any tools that will take a PrintDocument as input and render a PDF as output. The only way to do what you want is to "print" the PrintDocument to a "PDF printer driver" that will generate PDF. Basically a virtual printer that will generate PDF instead of printing the actual output. There are a plethora of products on the market for that. A couple that are cheap and widely used are as follows:
Ghostscript with RedMon (open source/GPL or commercial licenses available)
Foxit Software's PDF Creator ($29)
You really should be looking at iTextSharp (it is mentioned on the iText.NET page recommended earlier)
http://itextsharp.sourceforge.net/
PrintDocument is meant for Windows Forms applications but is up and coming in SilverLight, see this video... http://silverlight.net/learn/videos/all/printing-api-basics/
If you wish to continue with the PrintDocument and a web application, I think SilverLight 4 (which is beta right now) is the only way to go, or your going to have to have a lite weight windows form application installed locally for the end user that maybe uses web services.
iTextSharp is a great tool for generating PDFs with .NET on the Internet. I highly recommend it; I've used iText with Java...and have been using iTextSharp for the past few years.
There are several ports of iText for .NET (A very popular open-source PDF library for Java).
http://www.ujihara.jp/iTextdotNET/en/