2015-01-13 25 views
0

我试图使用iTextSharp库将.jpg文件转换为PDF。.jpg to .pdf Conversion - iTextSharp.text.PageSize'在Windows Phone 8.1中抛出了一个异常

见下面我的代码:

using (MemoryStream newStream = new MemoryStream()) 
{ 
    Document doc = new iTextSharp.text.Document(iTextSharp.text.PageSize.A4.Rotate());      
    PdfWriter writer = PdfWriter.GetInstance(doc, newStream); 
    writer.CloseStream = false; 

    byte[] all = newStream.ToArray(); 
} 

但是,我在这一行收到错误:

Document doc = new iTextSharp.text.Document(iTextSharp.text.PageSize.A4.Rotate()); 

我得到的错误是这样的:

消息=“的'iTextSharp.text.PageSize'的类型初始值设定项会抛出 例外。“ InnerException = {System.IO.FileNotFoundException: 无法加载文件或程序集'System.Drawing,Version = 1.0.5000.0, Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'或其某个 依赖项。该系统找不到指定的文件。

如何处理此问题,请给我建议。 谢谢!

+0

这篇文章可以帮助你 - http://stackoverflow.com/questions/21827669/jpg-to-pdf-conversion-in-windows-phone-8-app –

回答

0

最后我找到了方法。我在Windows Phone 8.1项目中添加了ComponentOne库。

using C1.Phone.Pdf; 
using C1.Phone.PdfViewer; 

C1PdfDocument pdf = new C1PdfDocument(PaperKind.PrcEnvelopeNumber3Rotated); 
pdf.Landscape = true; 

var rc = new System.Windows.Rect(20,30,300,200); 
pdf.DrawImage(wbitmp, rc); 

var fillingName = "Test.pdf"; 
var gettingFile = IsolatedStorageFile.GetUserStoreForApplication(); 

using (var loadingFinalStream = gettingFile.CreateFile(fillingName)) 
{ 
    pdf.Save(loadingFinalStream); 
} 
+0

这是如何工作?它不适合我吗?是silverlight还是rt? – Amin

+0

@Amin是的,它是silverlight哥们! –

1

iTextsharp不支持windows phone。您遇到的问题之一是System.Drawaing在Windows Phone中不存在,但它会在其他地方失败。有一个Windows Phone支持的程序集列表here

+0

能否版本iTextSharp的没有'系统.Drawing'被使用? –

+0

所以,没有用它!该死的windows手机! Thanx @Paulo –

+0

@ChrisHaas:这不仅是System.Drawing,所有的文件管理都必须改变,还有许多其他部分。 –

相关问题