Saturday, December 5, 2009

Solid Framework updated with new Installer and ProgressTicker classes.

We've released a new version of Solid Framework SDK 6.0.255.0. This build addresses a couple issues:

  1. PdfPage.DrawBitmap always adds a watermark regardless of the license. It now properly disables the watermark if the license is a non free version.
  2. When converting Pdf pages to image files, the first page is blank. The GDI+ module is now loaded before the page drawing starts.
  3. Extraction of the support files is now faster because we are using memory streams instead of file streams.

This version also includes the new Configuration.Installer class, that we will talk about today in this blog post. With this class Solid Framework can be installed in one of three ways:

  1. Self extraction to the current users local application data folder.
  2. Self extraction to a folder handed to the Installer class.
  3. Pre extraction.

The first method is the default method that the previous versions of Solid Framework has been using. When the application calls one of the Solid Framework methods, it will check to see if the support files have been extracted to the current users application data folder, and if it has not, it will extract it at this point.


The second method allows these support files to be extracted to any folder the developer wishes. Before any Solid Framework method is called, the developer can set the Configuration.Installer.NativePlatformDirectory string property to a full path, and that path will be used as the root folder for the support files. This is useful if you want to share the support folder between many users and don't want each user to have their own copy of the support files, or you wish to remove this known folder location during an uninstall.


The third method is to use the ExtractFramework tool to extract the support files from Solid Framework beforehand and install them to a folder you want in your application installer. You have to let the Framework know where these files are by setting the Configuration.Installer.NativePlatformDirectory string property in the application. This gives the developer total control during the install and uninstall.


Another feature of this release is the ProgressTicker event class. You can register for this event to show progress UI while Solid Framework is extracting the support files (if needed).


The default for ProgressTicker is 50 ticks for the extraction. This tick value can be set to any value you wish by setting the TicksPerEpisode property off the ProgressTicker to any integer value. This also enables feedback in console applications, which didn't work in previous versions of Solid Framework, that needed a Windows message pump to work.


The extraction tool link above uses this feature to show feedback of the extraction. Source code for the ExtractFramework tool is included, it shows you how ProgressTicker works. Both Visual Studio 2005 and Visual Studio 2008 projects are included in the package.

Thursday, November 19, 2009

New Solid Framework released

We have released a new version (6.0.251) of Solid Framework SDK that now includes full support for image processing and optical text recognition to allow conversion of scanned PDF files to editable Word documents. Solid Framework takes advantage of the MODI API (part of Microsoft Office) to provide OCR capability.

When converting PDF to Office documents, you can specify when OCR is used by setting the TextRecoveryType:







To one of the following settings:











Always - All pages are rendered to images and processed as scanned pages.

Automatic - Pages that contain scanned text-like images are recognized automatically.

Default - Same as Automatic.

Never - No scanned page processing. Scanned pages converted as images.

Friday, September 4, 2009

Convert PDF pages to Image files

Another comment question we get in email is if Solid Framework can convert PDF pages into image files. Solid Framework can be used to convert PDF pages into image files, and we use this feature to create page thumbnail images and the main page view for PDF Navigator. Here is a diagram of how this works:


You can download the sample project [zip file] to see this in action yourself. The project contains both Visual Studio 2005 and Visual Studio 2008 solutions. Those without Microsoft Visual Studio can use Visual C# 2008 Express Edition for free to work with the sample project.

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 use this class again to parse out the command line arguments we need to convert the pages into image files:


  Arguments CommandLine = new Arguments(args);‍
  if (CommandLine["f"] == null)‍
  {
    ShowUsage();‍
    return -1;
  }‍
  else
    pdfFile = CommandLine["f"];‍

  if (CommandLine["p"] != null)‍
    password = CommandLine["p"];

‍  if (CommandLine["o"] == null)
  {‍
    ShowUsage();
    return -2;‍
  }
  else
    outputfolder = CommandLine["o"];

‍  // Note: We default to 96 dpi if the parameter was not provided.
  if (CommandLine["d"] != null)‍
    dpi = Convert.ToInt32(CommandLine["d"]);

  if (CommandLine["t"] != null)
  {‍
    switch (CommandLine["t"].ToUpper())
    {‍
      case "TIF":
      case "TIFF":‍
        imagetype = ImageType.TIFF;
        break;‍
      case "BMP":
        imagetype = ImageType.BMP;‍
        break;
      case "JPEG":‍
      case "JPG":
        imagetype = ImageType.JPG; ‍
      break;
      case "PNG":‍
      default:
        imagetype = ImageType.PNG;‍
        break;
    }‍
  }

  if (CommandLine["r"] != null)
  {‍
    pagerange = CommandLine["r"];
  }‍

  DoConversion(pdfFile, password, outputfolder, dpi, pagerange, imagetype);‍

The code above takes care of setting up the arguments to hand off to DoConversion. So lets say we have a pdf file at c:\mypdfs\pdftest.pdf that is encrypted with a user password of "mypassword" and we want to make JPEG images of pages 1-5, 7, 8 with a dpi of 127 and put these images in c:\myimages. The commandline would look like this:

PDFtoImage.exe -f:c:\mypdfs\pdftest.pdf -p:mypassword -o:c:\myimages -d:127
-t:JPG -r:1-5,7,8


Note: -p -d -t and -r are optional. No password is used if -p is missing. DPI will default to 96, and image type will default to PNG. If -r is missing, all pages will be used to make images.

The DoConversion function is the meat of the project. First we set the trial license:

  // Setup the license
  SolidFramework.License.ActivateDeveloperLicense();

It then loads the PDF file with password if supplied:

  // Load up the document
  SolidFramework.Pdf.PdfDocument doc =
    new SolidFramework.Pdf.PdfDocument(file, password);

  doc.Open();

After the document is open, we check to see if the output folder exists, and if it doesn't, we create it:

  // Setup the outputfolder
  if (!Directory.Exists(folder))
  {
    Directory.CreateDirectory(folder);
  }
  // Setup the file string.
  string filename = folder + Path.DirectorySeparatorChar +
    Path.GetFileNameWithoutExtension(file);

Now walk the Pages dictionary and finds the page items by following the references.

  // Get our pages.
  List<SolidFramework.Pdf.Plumbing.PdfPage> Pages =
    new List<SolidFramework.Pdf.Plumbing.PdfPage>(doc.Catalog.Pages.PageCount);

  SolidFramework.Pdf.Catalog catalog =
    (SolidFramework.Pdf.Catalog)SolidFramework.Pdf.Catalog.Create(doc);

  SolidFramework.Pdf.Plumbing.PdfPages pages =
    (SolidFramework.Pdf.Plumbing.PdfPages)catalog.Pages;

  ProcessPages(ref pages, ref Pages)

Then if a page range is specified, parse the argument into page number integers. For each page that is specified, or all if not specified.

  // Check for page ranges
  PageRange ranges = null;
  bool bHaveRanges = false;
  if (!string.IsNullOrEmpty(pagerange))
  {
    bHaveRanges = PageRange.TryParse(pagerange, out ranges);
  }

  if (bHaveRanges)
  {
    int[] pageArray = ranges.ToArray();
    foreach (int number in pageArray)
    {
      CreateImageFromPage(Pages[number], dpi, filename, number, extension, format);
      Console.WriteLine(string.Format("Processed page {0} of {1}", number,
      Pages.Count));
    }
  }
  else
  {
    // For each page, save off a file.
    int pageIndex = 0;
    foreach (SolidFramework.Pdf.Plumbing.PdfPage page in Pages)
    {
      // Update the page number.
      pageIndex++;

      CreateImageFromPage(page, dpi, filename, pageIndex, extension, format);
      Console.WriteLine(string.Format("Processed page {0} of {1}", pageIndex,
      Pages.Count));
    }
  }

We load each requested Page object and request a bitmap from that object. We then request that the bitmap object save itself to a file in the output directory with the requested ImageFormat type.

  private static void   CreateImageFromPage(SolidFramework.Pdf.Plumbing.PdfPage page,
    int dpi, string filename, int pageIndex, string extension,
    System.Drawing.Imaging.ImageFormat format)
  {
    // Create a bitmap from the page with set dpi.
    Bitmap bm = page.DrawBitmap(dpi);

    // Setup the filename.
    string filepath = string.Format(filename + "-{0}.{1}", pageIndex, extension);
    // If the file exits already, delete it. I.E. Overwrite it.
    if (File.Exists(filepath))
      File.Delete(filepath);

    // Save the file.
    bm.Save(filepath, format);

    // Cleanup.
    bm.Dispose();
  }

And there you have it. The requested images should have been created in the specified output directory. Since we are using the free developer trial license, each page image will have a watermark at the bottom if the page. To remove this watermark, read more about an annual license for the Solid Framework Tools Edition here ($250 or $500 per year depending on distribution, no royalties).

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

Friday, August 28, 2009

App Domain Switches and Solid Framework

It has come to our attention that there is an issue with Solid Framework finding its support files when 3rd party assemblies are being used. The problem manifests itself as "Cannot find framework.dll" exception.

To work around this issue your license call, or instance of the LicenseCollection Object should be placed at the very beginning of your application. This license call should happen before any other 3rd party assembly is called.

The 3rd party assemblies can change the App Domain and then the call to Solid Framework fails. It looks within the App Domain searching for its support resources and when it doesn’t find them it assumes they have already been extracted and tries to load them.

We have tracked this down with Oracle and other assemblies and fixed the bug. We should be releasing a new version of Solid Framework sometime in the next week.

Monday, August 24, 2009

Extracting Solid Framework support files.

Developers may need to extract the support files in Solid Framework for a couple of reasons.

  • To use the native C++ interface
  • Running scripts with SolidScript.exe
To facilitate this issue, we have uploaded a small console app that works with Solid Framework version 225 or greater here. Place the exe anywhere you like and run it with 2 parameters. The first parameter is the full path to Solid Framework.dll, and the second parameter is the path to where you want the extracted files to be placed.

Example:

ExtractFramework.exe "c:\development\Solid Framework\SoldFramework.dll" "d:\My Files\Framework"

This will extract the support files from SolidFramework.dll sitting in c:\development\Solid Framework to the location d:\My Files\Framework.

Note: We wrapped both paths with quotes on the command line because of spaces in the folder names. If your path has spaces, you should also use quotes.

Wednesday, July 1, 2009

Solid Framework now does PDF/A

Solid Documents provides a free online PDF/A Validation service that uses our recently released Solid Framework v6 SDK behind the scenes. Solid Framework is now available through an enterprise licensing model. The Tools and Professional levels include PDF/A Validation and PDF to PDF/A conversion functionality.

The PDF/A Competence Center has a test suite for validating PDF/A Validators called the Isartor Test Suite.

Evaluate for Yourself

An easy way to test drive our PDF/A Validation technology is to download the Isartor Test Suite (4MB ZIP) and then simply submit this ZIP file to our online PDF/A (ISO 19005 -1) validation service.

The online service will validate all 205 files in the ZIP and e-mail you an XML report, in Open Compliance Report format, containing the PDF/A violations found in these file. All of the 205 files should exhibit errors, including the Isartor Test Suite Manual.

1. Download isartor-pdfa-2008-08-13.zip from http://www.pdfa.org/
2. Go to http://www.validatepdfa.com/ and step through the wizard.
3. Attach isartor-pdfa-2008-08-13.zip to the e-mail.
4. Sit back and wait for the response from our free validation service.
5. Examine the report to confirm that our PDF/A Validator is 100% compliant.