Tutorials > Convert DjVu to Image File |
The following code is to save the first page to an image file using Page.SaveImageAs Method
djvu2img.cs |
Copy Code |
---|---|
using System; using DjVu; namespace DjVu2Jpeg { class DjVu2Jpeg { // Usage: djvu2img INPUT_DJVU_FILENAME OUTPUT_JPEG_FILENAME static void Main(string[] args) { // TODO: ADD app's license script here or REMOVE the following line LicenseManager.LicenseScript = "......"; using (Document doc = new Document(args[0])) { doc.Pages[0].SaveImageAs(args[1], ImageFormat.Jpeg, 70); } } } } |
Because TIFF is very unique that it can bundle multiple pages, DjVu# provides a specialized method for TIFF export; Document.SaveTiffAs Method is used to save all of the document pages to a file.
The following code is a minimum sample to convert DjVu file to a TIFF file.
djvu2tiff.cs |
Copy Code |
---|---|
using System; using DjVu; namespace DjVu2Tiff { class DjVu2Tiff { // Usage: djvu2tiff INPUT_DJVU_FILENAME OUTPUT_TIFF_FILENAME static void Main(string[] args) { // TODO: ADD app's license script here or REMOVE the following line LicenseManager.LicenseScript = "......"; using (Document doc = new Document(args[0])) { doc.SaveTiffAs(args[1], TiffBitonalEncodingMethod.CcittFax4, // G4 encoding for bitonal pages TiffPictureEncodingMethod.Jpeg, // JPEG for color pages 75); // JPEG quality=75 } } } } |
If your code should also support Secure DjVu Files, you should implement authentication logic. For more information, see Handling Secure DjVu.