Tuesday, August 12, 2008

Using Watched Folders to Convert PDF files to PDF/A with Solid PDF Tools

Our last blog post showed how to write a command line application that watches a folder for PDF files and converts them to DOC. Due to the flexibility of scripting Solid PDF Tools Scan to PDF we can adapt this to other needs very easily.

For example, say you want your watched folder to convert PDF files to PDF/A-1b. Why would you want to convert PDF files to PDF/A? Because converting to and validating PDF/A files will help to ensure that they are archivable and will display the same now as they will in 40 years.

With a few minor changes to the script you now have a program that watches for PDF files and converts them to PDF/A:



The rest of the changes in the PDFAWatcher project [zip file] are just in implementation (e.g. checking to see if the folders that the original and converted files will be placed in exist and creating them if they do not).

If you want to adapt this project for your own needs you may wish to look at our scripting reference and our first post on scripting using Solid Documents software.

Monday, August 11, 2008

Using Watched Folders to Convert PDF files to DOC with Solid PDF Tools

Using the scripting functionality of Solid PDF Tools Scan to PDF to watch a folder for PDF files and automatically convert them to DOC is fairly easy.

Microsoft provides a .NET class in System.IO called FileSystemWatcher which takes care of watching a folder. Any time a PDF file is moved or copied into the watched folder an event will be raised. Add an event handler to run a script with Solid PDF Tools and you're done (this is a simplification, but most of the other work is just implementation).

We have created a C# project [solidwatcher.zip] which provides a good example of how to do this in a command line program. A basic outline of the project is below:



There are two main sections. The first is the Main() method that is run when you run the program (solidwatcher.exe). The second is the event handler that handles events that are raised when files are copied into the watched folder.

There are about fives lines of code in the Main() method that you need to understand. The highlighted code below shows creating the FileSystemWatcher object and getting the path for the watched folder from the first argument on the command line.



The highlighted code below allows us to filter based on file name (anything ending in .pdf in this case). The next highlighted section lets the end user running the program know that it is running and loops until they press the 'q' key and enter.



Although the event handler in the project is over twenty lines of code, you really only need to understand three of them (highlighted below) to understand what is going on.

First, we make the script. After that we create a new SolidScript object and run it's RunScript method with the script you just created.



If you're new to scripting Solid PDF Tools you may wish to look at our scripting reference and our first post on scripting using Solid Documents software.

Tuesday, July 29, 2008

Better PDF to DOC Conversion with Solid PDF Tools using Wildcards

The C# project that we wrote about last week is very informative, but it isn't perfect.

One commonly used feature in command line applications are wildcards. For example, one might want to use the command below to convert all of the PDF files in the temp folder to DOC using Solid PDF Tools Scan to PDF:

TestApp.exe /i "c:\temp\*.pdf"
Supporting this requires a few changes in our application (a foreach loop among other changes):



This provides us with all the values we need to run through the script below:



We've made a few other improvements to the project as well (download here). After you build it with Visual Studio or Visual C# Express 2008 you can run the resulting TestApp.exe with -h as an argument to see all the new options.

If you need to change the sample script we recommend that you read our first post on scripting using Solid Document software and our scripting reference [pdf file].

Any thoughts or ideas? How do you use this in your work and how would you like to use it? Contact us with any or all of your feedback.

Wednesday, July 23, 2008

Command Line PDF to DOC Conversion Using Solid PDF Tools

Earlier we talked about using a C# class library to allow you to use the scripting functionality of Solid PDF Tools Scan to PDF from the command line:



We've written a C# project [zip file] using some of the above code that demonstrates this. The compiled program from this project allows you to convert a PDF file to DOC and provides a few additional options (whether to log, provide a verbose output, etc.). Running it from the command line with -h as an argument will display all of the options you can use with it.

If you're not using Visual Studio and wish to compile it yourself we'd recommend using Visual C# Express 2008.

If you need to change the sample script we recommend that you read our first post on scripting using Solid Document software to get a better idea of how to modify this to suite your needs. Our scripting reference [pdf file] is another great source for information on how to do this.

Have any thoughts that you'd like to share? Please contact us with your feedback.

Wednesday, June 25, 2008

C# Class for Parsing Command Line Arguments

The ability to automate Solid PDF Tools Scan to PDF via scripts is very powerful, but there may be times that running it directly from the command line is needed (We're sure a couple system administrators are nodding their heads right now).

Users who need to automate repetitive tasks may want to take a look at this C# class library posted at the Code Project (thanks to Richard Lopes for writing the library).

The post shows how to use the class library with C# to parse, store and retrieve the arguments from a command line .NET application. This, when combined with the various ways you can automate PDF conversions using Solid PDF Tools allows you to create custom tools to suit your needs.

Have any great ideas or code that you'd like to share? Please contact us with your feedback.

Friday, June 20, 2008

Exporting PDF Files to Excel via Scripts using Solid PDF Tools

Solid PDF Tools Scan to PDF has the ability to export PDF files to Excel. In doing so tables in the PDF file are extracted and placed in a new Excel file.

This can be performed manually using our WYSIWYG PDF conversion interface.

However, what about when you need to automate this process? We suggest using scripts to control Solid PDF Tools when this is the case.

Below is an example script exporting a PDF file to Excel:

<</FileName (c:\\temp\\input.pdf) >> FileOpen
<< /Pages (1,3-4,6)
/OutputFolder (c:\\temp\\)
/LaunchViewer false >> ConvertToExcel
FileClose Exit
Not all of these options are required, but it does give you an idea of the flexibility that the tool offers.

If you haven't done so already we recommend that you read our first post on scripting using Solid Document software to get a better idea of how to use this in practice. You can also check out our scripting reference [pdf file] for additional information.

As always, we welcome you to contact us with any questions or ideas you have.

Wednesday, June 18, 2008

Scripting PDF/A Validation Using Solid PDF Tools

Solid PDF Tools Scan to PDF is a very powerful product. Besides being able to validate PDF/A-1b compliance by converting PDF files to PDF/A using a GUI, you can also script this behavior.

Unlike most scripts that control our software, this one will be more complex:

<</FileName (c:\\temp\\document.pdf)>> FileOpen
<</FileName (c:\\archive\\document.pdf) /PdfA true>> FileSaveAs
FileClose Exit
Were you expecting things to be more complex than this? Don’t worry, you can tell your boss how complex this one was to do. We won’t tell them otherwise. ;)

Need more details? Please read more on scripting with Solid Documents software.

Have questions or suggestions on how to automate tasks with our software? Tell us how you use the scripting features of Solid Documents products to increase your productivity.