fail to open file when file name have special characters

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF Rasterizer for .NET (v2)  /  fail to open file when file name have special characters

DynamicPDF Rasterizer for .NET (v2) Forum

Dear All,

i'm facing exception "File not found or could not be opened." will converting or getting count of file having special character in file name like "Ÿ‰éZþß.txt" or "é.pdf".
please help for same

 StackTrace -->

ceTe.DynamicPDF.Rasterizer.DocumentLoadException was unhandled
  Message=File not found or could not be opened.
  Source=ceTe.DynamicPDF.Rasterizer.40.x86
  StackTrace:
       at ceTe.DynamicPDF.Rasterizer.InputPdf..ctor(String filePath)
       at ceTe.DynamicPDF.Rasterizer.PdfRasterizer..ctor(String filePath)
       at JpegImage_Example.Program.Main(String[] args) in C:\Program Files\ceTe Software\DynamicPDF Rasterizer v2.0.0 for .NET\Examples\VisualStudio2010\Console\CSharp\JpegImage_Example_CS\Program.cs:line 14
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException:


Posted by a ceTe Software moderator
Hello,

You can read the file contents in the form of byte array and use this byte array to load the PDF instead of using direct file path. Please read the PDF file contents into byte array and then build the InputPdf object using this byte array. You can then build PdfRasterizer object using InputPdf object. Below is the sample code for it.

            //Pdf file path
            string pdf = @"C:\input.pdf";
            //Read the file data into byte array.
            byte[] byteData = File.ReadAllBytes(pdf);
            //Build InputPdf object using byte array.
            InputPdf inputPdf = new InputPdf(byteData);
            //Build the PdfRastreizer object using InputPdf object
            PdfRasterizer pdfRasterizer = new PdfRasterizer(inputPdf);
            pdfRasterizer.Draw(@"C:\MyJPGImage.jpg", ImageFormat.Jpeg, ImageSize.Dpi72);

Thanks,
ceTe Software Support Team.

All times are US Eastern Standard time. The time now is 11:14 PM.