我正在尝试在Monotouch中创建pdf的缩略图图像但是应用程序有时会崩溃并且会抛出错误。
堆栈跟踪:
at MonoTouch.CoreFoundation.CFString.Dispose () [0x00000] in /Developer/MonoTouch/Source/monotouch/src/shared/CoreFoundation/CFString.cs:131
at MonoTouch.CoreFoundation.CFUrl.FromFile (string) [0x00048] in /Developer/MonoTouch/Source/monotouch/src/shared/CoreFoundation/CFUrl.cs:79 at MonoTouch.CoreGraphics.CGPDFDocument.FromFile (string) [0x00000] in /Developer/MonoTouch/Source/monotouch/src/shared/CoreGraphics/CGPDFDocument.cs:98
下面是我生成缩略图图像的代码,它们位于BackgroundWorker线程中。奇怪的是,它并不总是发生。 有谁知道为什么会这样? 提前谢谢。
try
{
CGPDFDocument pdfDoc = CGPDFDocument.FromFile(url);
if (pdfDoc != null)
{
CGPDFPage pdfPage = pdfDoc.GetPage(1);
if (pdfPage != null)
{
UIImage image = PDFConverter.TransformToImage(pdfPage, this.Frame.Width);
}
}
}
catch (Exception ex)
{
Console.WriteLine("BookmarkView - BookmarkView: {0}", ex.ToString());
}