【发布时间】:2011-03-22 21:20:24
【问题描述】:
string imgfile = @"C:\users\me\desktop\test.jpg";
Bitmap bmp = new Bitmap(imgfile);
Bitmap bw = ConvertTo1Bpp(bmp); //make b+w
Document doc =
new Document(new iTextSharp.text.Rectangle(bmp.Width, bmp.Height));
PdfWriter.GetInstance(doc,
new System.IO.FileStream(
@"C:\users\me\desktop\test.pdf",
System.IO.FileMode.Create,
System.IO.FileAccess.ReadWrite));
iTextSharp.text.ImgJBIG2 i =
((iTextSharp.text.ImgJBIG2)iTextSharp.text.ImgJBIG2.GetInstance(
bmp, System.Drawing.Imaging.ImageFormat.Bmp));
doc.Open();
doc.Add(i);
doc.Close();
我无法使用 iTextSharp 找到任何好的文档。我想要做的是获取一个 Jpeg 文件并将其转换为嵌入为黑白 JBig2 图像的 pdf。我得到的错误是“iTextSharp.text.ImageRaw”和“iTextSharp.text.ImageJBig2”之间的 InvalidCastException ......有没有我上面的替代方法?
编辑
ImgJBig2 只是代表我现在相信已经用 JBig2 编码的图像。我正在寻找的是将位图编码为 BW JBig2 位图的东西,我可以将其放入 Pdf 中。
【问题讨论】:
标签: c# image-processing bitmap itextsharp