I’m using LeadTools 14.5. I have PDF file that I want to load to codec so I can save to PNG. PDF file size is about 55 KB.
I already call RasterSupport.Unlock() to unlock RasterSupportType(Pdf, PdfAdvance, PdfRead & PdfSave). I have two PDF files and this very same code work when I try to save PDF to PNG for 1st PDF file only but it throw exception when I have try 2nd PDF file.
// Resulting image pixel depth.
codecs.Options.Pdf.Load.DisplayDepth = 24;
codecs.Options.Pdf.Load.GraphicsAlpha = 4;
codecs.Options.Pdf.Load.Password = @"";
// Type of font anti-aliasing to use.
codecs.Options.Pdf.Load.TextAlpha = 4;
codecs.Options.Pdf.Load.UseLibFonts = true;
// Horizontal,vertical display resolution in dots per inch.
codecs.Options.Pdf.Load.XResolution = 150;
codecs.Options.Pdf.Load.YResolution = 150;
IRasterImage tempImage;
tempImage = codecs.Load(orgPDFFileFullPath, 0, CodecsLoadByteOrder.BgrOrGray, 1, 1); //throw ex from here
// Set access rights for the user when he\she opens the file we create
codecs.Options.Pdf.Save.AssembleDocument = true;
codecs.Options.Pdf.Save.ExtractText = true;
codecs.Options.Pdf.Save.ExtractTextGraphics = true;
codecs.Options.Pdf.Save.PrintDocument = false;
codecs.Options.Pdf.Save.FillForm = true;
codecs.Options.Pdf.Save.ModifyAnnotation = true;
codecs.Options.Pdf.Save.ModifyDocument = true;
codecs.Options.Pdf.Save.OwnerPassword = "Lead Technologies";
codecs.Options.Pdf.Save.PrintFaithful = false;
codecs.Options.Pdf.Save.TextEncoding = CodecsPdfTextEncoding.Hex;
codecs.Options.Pdf.Save.Use128BitEncryption = true;
codecs.Options.Pdf.Save.UserPassword = "Lead";
PDF file created by print RTF via free open source. The problem is not a PDF file because I can open it directly but when I load to codecs then it's throw exception below:
ex=System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at delete(Void* )
at L_FreeThreadData()
at Leadtools.Kernel.Codecs.Codec.fltInfo(Object pDispatch)
at Leadtools.Kernel.Codecs.KernelCodecs.L_IntFileInfo(String pFilename, FILEINFO pInfo, UInt32 uStructSize, INFOLOADSTATE pState, Object pVector, Object pDocument, LOADFILEOPTION pLoadOptions, LOADDISPATCH pLoadDispatch)
at Leadtools.Kernel.Codecs.KernelCodecs.L_FileInfo(String pFilename, FILEINFO pInfo, UInt32 uStructSize, UInt32 uFlags, LOADFILEOPTION pLoadOptions)
at Leadtools.Codecs.RasterCodecs.GetInformation(String fileName, Stream stream, Boolean totalPages, Int32 pageNumber)
at Leadtools.Codecs.RasterCodecs.Load(LoadParams loadParams)
at Leadtools.Codecs.RasterCodecs.Load(String fileName, Int32 bitsPerPixel, CodecsLoadByteOrder order, Int32 firstPage, Int32 lastPage)
Is there something wrong with my code?
I also tried with existing PDF that I've printed out earlier but it throws same exception for all of them. Please help,