.jpg 到 .pdf 的转换 - iTextSharp.text.PageSize' 在 Windows Phone 8.1 中抛出异常
.jpg to .pdf Conversion - iTextSharp.text.PageSize' threw an exception in Windows Phone 8.1
我正在尝试使用 iTextSharp 库将 .jpg 文件转换为 PDF。
查看下面我的代码:
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());
我收到这样的错误:
Message = "The type initializer for 'iTextSharp.text.PageSize' threw
an exception." InnerException = {System.IO.FileNotFoundException:
Could not load file or assembly 'System.Drawing, Version=1.0.5000.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its
dependencies. The system cannot find the file specified.
如何处理,请指教。
谢谢!!
iTextsharp(还)不支持 windows phone。您遇到的问题之一是 System.Drawaing 在 windows phone 中不存在,但它会在其他地方失败。有 windows phone 支持的程序集列表 here。
终于找到方法了。我在 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);
}
我正在尝试使用 iTextSharp 库将 .jpg 文件转换为 PDF。
查看下面我的代码:
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());
我收到这样的错误:
Message = "The type initializer for 'iTextSharp.text.PageSize' threw an exception." InnerException = {System.IO.FileNotFoundException: Could not load file or assembly 'System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
如何处理,请指教。 谢谢!!
iTextsharp(还)不支持 windows phone。您遇到的问题之一是 System.Drawaing 在 windows phone 中不存在,但它会在其他地方失败。有 windows phone 支持的程序集列表 here。
终于找到方法了。我在 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);
}