Convert djvu to pdf using PDFNet / pdftron_1

My Requirement is Converting => Convert djvu to pdf using PDFNet / pdftron

Please describe your issue and provide steps to reproduce it:

My Requirement is convert djvu file to PDF .
i use below code for the same

  1. Check if virtual printer installed or not

lse if (!pdftron.PDF.Convert.Printer.IsInstalled())
{
try
{
Console.WriteLine(“Installing printer (requires Windows platform and administrator)”);
pdftron.PDF.Convert.Printer.Install();
Console.WriteLine("Installed printer " + pdftron.PDF.Convert.Printer.GetPrinterName());
// the function ConvertToXpsFromFile may require the printer so leave it installed
// uninstallPrinterWhenDone = true;
}
catch (PDFNetException e)
{
Console.WriteLine(“ERROR: Unable to install printer.”);
Console.WriteLine(e.Message);
err = true;
}
2) Convert DJVU file to PDF

using (pdftron.PDF.PDFDoc pdfdoc = new PDFDoc())
{
//Orginal Code Start

                                if (pdftron.PDF.Convert.RequiresPrinter(inputPath + file.inputFile))
                                {
                                      Console.WriteLine("Using PDFNet printer to convert file " + file.inputFile);
                                }                                   
                                pdftron.PDF.Convert.ToPdf(pdfdoc, inputPath + file.inputFile);
                                pdfdoc.Save(outputPath + file.outputFile, SDFDoc.SaveOptions.e_linearized);
                                Console.WriteLine("Converted file: " + file.inputFile);
                                Console.WriteLine("to: " + file.outputFile);                                  

                          }

Although it gives me below error
PDFNet is running in demo mode.
Installing printer (requires Windows platform and administrator)
Installed printer PDFTron PDFNet
Package: base
Using PDFNet printer to convert file Example.djvu
ERROR: on input file Example.djvu
Exception:
Message: An error occurred while converting the file.
Detailed error:
Exception:
Message: Unable to convert file, too many attempts.
Conditional expression: attemptCount < MaxAttempts
Version : 10.8.0-842bd75fad
Platform : .Net Framework
Architecture : AMD64
Filename : Convert.cpp
Function : trn::PDF::Convert::printToPrinter
Linenumber : 3217

      printing to printer D:\WORK\IV Question\ Questions QP_New\C#_D_JAN_2024_1_1\pdftron\PDFNetDotNet4\PDFNetDotNet4\Samples\TestFiles\Example.djvu
      AssocQueryString printto:
      AssocQueryString print  :
      Created new PDFNet Mutex
      WaitForSingleObject start
      WaitForSingleObject End
      printo: C:/Users/Shashank/AppData/Local/Temp/pdftron/Trn-13484-1714058778-b04f16f5-c98d-40dd-bd0d-3c077ff47ee7.xps
      Using HKCU
      PrinterManager initialized
      ShellExecuteExW using verb 'printto', printer '"PDFTron PDFNet"' on file 'D:\WORK\IV Question\ Questions QP_New\C#_D_JAN_2024_1_1\pdftron\PDFNetDotNet4\PDFNetDotNet4\Samples\TestFiles\Example.djvu'
      Skipping 'printto' since no verb association detected
      ToPdf using verb 'print', on file 'D:\WORK\IV Question\ Questions QP_New\C#_D_JAN_2024_1_1\pdftron\PDFNetDotNet4\PDFNetDotNet4\Samples\TestFiles\Example.djvu'
      ToPdf ShellExecuteEx 'print' returned error 1155: No application is associated with the specified file for this operation.

      ToPdf did not create a new process -- application already running? 0
      waiting for print job: state 3, attempts 0
      waiting for print job: state 3, attempts 1
      waiting for print job: state 3, attempts 2
      waiting for print job: state 3, attempts 3
      waiting for print job: state 3, attempts 4
      waiting for print job: state 3, attempts 5
      waiting for print job: state 3, attempts 6
      waiting for print job: state 3, attempts 7
      waiting for print job: state 3, attempts 8
      waiting for print job: state 3, attempts 9
      waiting for print job: state 3, attempts 10
      waiting for print job: state 3, attempts 11
      waiting for print job: state 3, attempts 12
      waiting for print job: state 3, attempts 13
      waiting for print job: state 3, attempts 14
      waiting for print job: state 3, attempts 15
      waiting for print job: state 3, attempts 16
      waiting for print job: state 3, attempts 17
      waiting for print job: state 3, attempts 18
      waiting for print job: state 3, attempts 19
      waiting for print job: state 3, attempts 20
      waiting for print job: state 3, attempts 21
      waiting for print job: state 3, attempts 22
      waiting for print job: state 3, attempts 23

.

waiting for print job: state 3, attempts 999
Error destructing ToPdfPrinterManager

     Conditional expression: false
     Version      : 10.8.0-842bd75fad
     Platform     : .Net Framework
     Architecture : AMD64
     Filename     : Convert.cpp
     Function     : trn::PDF::Convert::ToPdf
     Linenumber   : 2353

ConvertFile failed
ConvertSpecificFormats failed

Please provide a link to a minimal sample where the issue is reproducible:

May i know if djvu to PDF file conversion is supported by PDFNet ?

Thanks in advance

Many Thanks
Shashank Kulkarni

May i know if djvu to PDF file conversion is supported by PDFNet ?

Not directly/internally, but only through our virtual printer and a 3rd party application that can print DJVU files and which you would install on your server.

See here for file formats supported without a 3rd party installation.

AssocQueryString printto:
AssocQueryString print  :

You can see from above that nothing is installed on your Windows PC to print to DJVU files. You need to install such an application that can print DJVU files. The Apryse will utilize that application, through Windows print verb, to convert DJVU files (or any other printable file formats) to PDF.

Hi Ryan ,

Thanks for your reply.
File Formats supported with out third party installation do not include .djvu file.
(Link provided by you)
Which third party installation, may suggest for this .djvu - pdf conversion please suggest.

I used be PDFNet/PDFNetLoader/PresentationCore dll

blow is code i use to convert djvu to pdf
Also May i ask if can we convert .djvu file to bitmap/png file ? If yes then is PDFnet support for this ?

using pdftron;
using pdftron.Common;
using pdftron.Filters;
using pdftron.SDF;
using pdftron.PDF;

1) Install PDFTron PDF printer virtual Printer using code


2)Print djvu file using PdfTron-pdfnet printer

         try				{
				using (pdftron.PDF.PDFDoc pdfdoc = new PDFDoc())
				{
					//Orginal Code Start

					if (pdftron.PDF.Convert.RequiresPrinter(inputPath + file.inputFile))
					{
						Console.WriteLine("Using PDFNet printer to convert file " + file.inputFile);
					}						
					pdftron.PDF.Convert.ToPdf(pdfdoc, inputPath + file.inputFile);
					pdfdoc.Save(outputPath + file.outputFile, SDFDoc.SaveOptions.e_linearized);
					Console.WriteLine("Converted file: " + file.inputFile);
					Console.WriteLine("to: " + file.outputFile);		
					
					//Orignal code ends here

				}
			}
			catch (PDFNetException e)
			{
				Console.WriteLine("ERROR: on input file " + file.inputFile);
				Console.WriteLine(e.Message);
				err = true;

			}

As you mentioned in your reply ---->
You can see from above that nothing is installed on your Windows PC to print to DJVU files. You need to install such an application that can print DJVU files.
My Answer ----->
PDFTron to pdf printer is installed

PDFTron PDF printer was installed successfully with Step 1
image

Example.djvu file i used to convert is attached
Example.djvu (207.1 KB)

With above code and File attached i got error which is attached with this thread error.txt
Error.txt (49.7 KB)

Kindly Suggest if any alternative know, to convert this djvu file to pdf.

Many Thanks
Shashank Kulkarni

Which third party installation, may suggest for this .djvu - pdf conversion please suggest.

I do not have any experience/knowledge in this area. It would be your responsibility to find an appropriate application that can accurately print DJVU files.

Also May i ask if can we convert .djvu file to bitmap/png file ? If yes then is PDFnet support for this ?

Once you have the PDF version of the DJVU file, then yes, you can use Apryse PDFNet SDK to generate a JPG/PNG from the PDF.

Thanks Ryan for your reply. :slight_smile:
I already found DjVuLibre third party /open source to convert .djvu to PDF , this help to print djvu to pdf.

Although i was exploring for more options including PDFNet .

Thanks for your kind Help.
Have a good day