Need to print a PDF from .net and select different trays for output - vb.net

My company is moving to a new system which has a very poor printing system in place but it does create PDF's on the file system.
My Boss has asked me to create an application to print all the PDF's based on a JOB number.
I've gotten the filesystem search working, I have used the acrobat sdk to open each file and find certain strings to determine which pages go where.
The problem I'm dealing with is that the Acrobat SDK doesn't seem to support choosing printer settings.
My first thought was no big deal I just change the default windows printer and just change the tray so the invoice part and equipment listing go to white paper from tray 1, and the remittance goes to tray 2 on blue paper.
It seems like the printdocument in .net can handle alot of printer settings but I'm not sure if a PDF can be used with a print document.
Looking for any advice or assistance.
Thanks,
Joshua

I found the answer was to use Win32.
Here was the website that helped me get through some of the hurdles:
http://edinkapic.blogspot.com/2011/01/how-to-set-printer-default-paper-bin-in.html

The underlying problem is that PDFs are combination of vector graphics for the text and bitmapped images. It all needs to be rendered into a format the printer understands before being printable.
Ghostscript does this very nicely and if you need to do it from .Net, GhostScript.Net provides an excellent vb.Net interface.
The problem I'm dealing with is that the Acrobat SDK doesn't seem to support choosing printer settings.
You can't use the desktop version of Acrobat for this, since it's not designed for unattended operation and requires a user interface. Also, I believe it violates Adobe's license.

Related

Creating Thumbnail from PDF without Adobe SDK

I've been looking for ways by which I can generate Thumbnails from pdf, as shown in the explorer. But the problem is that without Adobe Pro, the free version does not expose all ihe COM interfaces. Is there any other way? please help.
Ghostscript (which is what ImageMagick uses) will generate images in a wide variety of different image formats... if you need something really obscure then use the imagemagick wrapper, otherwise, I prefer the straight dope.
If you can afford a commercial option, you could use Amyuni PDF Creator ActiveX for this task, (or .Net version if that suits your needs better). Using this product you can create jpg/png/bmp images from the first page of your PDF files with the specified resolution, and then use them as thumbnails.
Disclaimer: I am part of the development team of this product.
Here are other SO questions proposing other approaches (not involving COM):
Using ImageMagic in command line
Thumbnail of a PDF page (Java)

Add watermark to various documents investigation

I've been asked to investigate the feasibility of adding watermarks to documents when printed through our application. The documents will consist of word, pdf and cad.
The interface of the application is vb6 with a plethora of vc6 dll's.
I can see a couple of possible solutions:
Convert all documents to PDF, add a watermark and then print.
Find a print driver that will add a watermark to all documents prior to printing and install it and reenable it at runtime if it gets disabled for any reason.
3rd Party suites are possibility (we use Volo View Express for viewing CAD files) but since this application is nearing end-of-life we wouldn't want to spend too much on it.
Has anyone had any experience of the above? Any gotcha's that will bog me down?
Tracker Software has a good set of PDF api's that that will allow you to implement the solution you already have in mind. I've used their Image and PDF libraries quite a bit with a lot of success in both VB6 and .NET. Single user licenses are not expensive (depending on how you look at it I guess), and I've found support to be excellent as well.

Is there a good ActiveX/COM component to "print" to PDF?

Clutching at straws here, I think I remember seeing a solution to this somewhere but can't find it now.
The issue is that I need a Windows application (not .Net) to be able to generate PDFs. The "standard" solution is to use something like PDF995 or CutePDF which create a dummy printer that your application can then print to and it is redirected to a PDF file. The problem is that to control those printers requires updating INI files or registry keys and that is error prone and often runs into concurrency problems.
Building the PDF file programmatically isn't an option, it needs to be able to take the output that would normally be sent to a printer, or possibly convert directly from an Excel file.
Ideally, I'd just pass the Excel file to a COM/ActiveX object and it would write to a file I specify. Next best option would be for it to create a separate printer per print job or have some reasonable way of guaranteeing the filename I give will have the document I print.
This Excel to PDF Batch converter might do the trick as at least it has a command line mode, has anyone tried that? It would only solve the problem for Excel files though.
So, is there a better solution?
(As a side note, for Visual FoxPro reports XFRX works really well, it converts the report directly to a PDF without needing a printer driver.)
You might want to look at BullZip (google it because I cannot add hyperlinks yet). We recently had Jody Meyer present this tool at the Detroit Area Fox User Group (previously shown at the Grand Rapids Area Fox User Group too). It was a great session.
She showed how to use the COM object to automate a ton of the BullZip features including the name of the file and properties like author and keywords. Watermarks are a snap too. It is simple and straightforward and her example was rock solid. Tons of features already done for you so you can simply re-engineer the demo form.
You can download it on the DAFUG Web site, in the downloads folder. File name is BullZipDemo.zip (google Detroit Area Fox User Group) and add the folder and filename.
Rick
VFP MVP
For this scenario I would recommend Amyuni PDF Converter. It provides a Microsoft Certified PDF Printer and ActiveX/.Net controls to communicate with it. Concurrency issues can be avoided by using these controls.
Disclaimer: I am part of the development team of this product.

Commenting on LaTeX PDF documents with PDF reader

Im currently writing my bachelor thesis with latex and using TexnicCenter. I want to be able to send my generated pdf file to people and they should be able to write comments.
It seems like commenting is not allowed by default, how do I change this?
I am using straight to PDF with pdflatex and acrobat reader 9 to read and comment on the files
I think your problem is that acrobat reader doesn't allow commenting on documents not produced by abode approved products, which I don't think pdflatex would be.
You should look at the free PDF-XChange Viewer which allows you to comment and annotate the text. Its a portable windows app (download), so doesn't need to be installed on your (or the reviewers) machines.
In order to comment using the free Adobe Reader application, the document needs to be signed with a cryptographic key only available from Adobe's commercial (non-free, for-pay) software suites. Likewise, if one is using Adobe Acrobat (not the free Reader) to view a PDF document, commenting may be activated -- or so I hear. The idea here is that it takes some piece of commercial Adobe software in the scenario -- be it producer or consumer -- to make commenting possible.
There are other free PDF producer and consumer applications that allow some form of annotation, but none of them are equivalent to the "native" form offered by Adobe's products.
Strange... I just finished my master thesis, using TexnicCenter and the MikTeX distribution, and comments worked just fine. What build profile do you use? Straight to PDF with pdflatex, or via the PS->PDF route? You might want to try the pdflatex method.
(EDIT): ah, we used Acrobat Pro for commenting, so that's why it did work in our case... Thanks rsg!
You can download the 30 day trial of Acrobat Professional 9, and enable the user rights required on the pdf so that they can comment using Acrobat Reader.
I would definitely have a look at the LaTeX Web Companion. There is a whole section about generating PDF from LaTeX, including esoterica such as forms.

How to convert Word and Excel documents to PDF programmatically?

We are developing a little application that given a directory with PDF files creates a unique PDF file containing all the PDF files in the directory. This is a simple task using iTextSharp. The problem appears if in the directory exist some files like Word documents, or Excel documents.
My question is, is there a way to convert word, excel documents into PDF programmatically? And even better, is this possible without having the office suite installed on the computer running the application?
Office 2007 allows for this. I have found PDFCreator to be good, the VBA is included in sample files, and have heard that CutePDF is also good. PDFCreator and CutePDF are free.
To work without Office, you would need viewers, as far as I know:
http://www.microsoft.com/downloads/details.aspx?FamilyID=c8378bf4-996c-4569-b547-75edbd03aaf0&displaylang=EN
http://www.microsoft.com/downloads/details.aspx?familyid=95E24C87-8732-48D5-8689-AB826E7B8FDF&displaylang=en
I needed to do this myself, but managed to get it done with .Net and without 3rd party tools:
MSDN: Saving Word 2007 Documents to PDF and XPS Formats
Pretty simple, about 50 lines of code. However I think you will need Word 2007 installed on the machine as well as the ability to Save As PDF
To convert Word documents to PDF, take a look at jWordConvert, a java library that can do exactly that. This will not work with the Excel files though, only with the Word files. The language is not Sharp, it's Java but you could switch to use IText (which is java) instead of ITextSharp.
You can also use a component like activePDF's DocConverter to convert a lot formats to PDF.
Use PDF maker that comes with adobe 7- 9
I just used this code Covert Doc to PDF
I'm surprised Aspose wasn't mentioned here, it's easy, simple, and reliable. Downside is that it is not free.
I've used iTextSharp in the past, it's really good, easy to install (one DLL I believe), the merge takes a bit of tindering so it's not as easy to use as Aspose, but hey, it's free so that is the best part.
TallPDF.NET (comes with a hefty price tag) allows you to serve dynamic PDF from any .NET application including ASP.NET pages and web services.
PDFEdit (free and open source) is an editor for manipulating PDF documents. It has a GUI version and a command-line interface. Scripting is used to a great extent in the editor and almost anything can be scripted. It is possible to create your own scripts or plugins.
The most common way to convert files to a pdf is to print them to a pdf printer driver. There are a number of such drivers, one that i know of that will do the job is Black Ice.
Another is to use Adobe Acrobat's SDK. from memory its very expensive.
Its been a while since i have actually done any work with converting pdf's and the landscape may have changed.