回复 6楼AvoCaDolol的帖子
1.旋转WebThumbnailViewer中的一页后,如何保存至原来文件,没有旋转的页保持不变?
2.往WebThumbnailViewer中追加页面,如何将追加的页面保存至原来文件?
以下是我所写的代码,但实现有问题:
if (sel_file.Substring(sel_file.LastIndexOf(".") + 1).ToLower() == "pdf")
{
using (RasterCodecs codecs = new RasterCodecs())
{
codecs.Options.Pdf.InitialPath = Server.MapPath("~/bin/");
Leadtools.Pdf.PDFFile pdf_file = new Leadtools.Pdf.PDFFile(WebThumbnailViewer1.Page.MapPath(sel_file));
for (int i = 0; i < WebThumbnailViewer1.Count; i++)
{
ThumbnailInfo info = WebThumbnailViewer1.GetThumbnailInfo(i);
if (info.CacheFileName.Length > 0)
{
Leadtools.Pdf.PDFFile pdf = new Leadtools.Pdf.PDFFile(WebThumbnailViewer1.Page.MapPath(info.CacheFileName));
if (i < pdf_file.GetPageCount())
pdf_file.ReplacePagesFrom(1, pdf, i + 1, i + 1);
else
pdf_file.InsertPagesFrom(1, pdf, i + 1, i + 1);
}
else
{
Leadtools.Pdf.PDFFile pdf = new Leadtools.Pdf.PDFFile(WebThumbnailViewer1.Page.MapPath(info.Url));
if (i < pdf_file.GetPageCount())
pdf_file.ReplacePagesFrom(1, pdf, i + 1, i + 1);
else
pdf_file.InsertPagesFrom(1, pdf, i + 1, i + 1);
}
}
}
}
else
{
using (RasterCodecs codecs = new RasterCodecs())
{
CodecsImageInfo img_info = codecs.GetInformation(WebThumbnailViewer1.Page.MapPath(sel_file), true);
for (int i = 0; i < WebThumbnailViewer1.Count; i++)
{
ThumbnailInfo info = WebThumbnailViewer1.GetThumbnailInfo(i);
if (info.CacheFileName.Length > 0)
{
using (Leadtools.RasterImage image = codecs.Load(WebThumbnailViewer1.Page.MapPath(info.CacheFileName)))
{
if (i < img_info.TotalPages)
codecs.Save(image, WebThumbnailViewer1.Page.MapPath(sel_file), image.OriginalFormat, image.BitsPerPixel, 1, 1, info.Page, CodecsSavePageMode.Replace);
else
codecs.Save(image, WebThumbnailViewer1.Page.MapPath(sel_file), image.OriginalFormat, image.BitsPerPixel, 1, 1, info.Page, CodecsSavePageMode.Append);
}
}
else
{
using (Leadtools.RasterImage image = codecs.Load(WebThumbnailViewer1.Page.MapPath(info.Url), 0, CodecsLoadByteOrder.BgrOrGray, info.Page, info.Page))
{
if (i < img_info.TotalPages)
codecs.Save(image, WebThumbnailViewer1.Page.MapPath(sel_file), image.OriginalFormat, image.BitsPerPixel, 1, 1, 0, CodecsSavePageMode.Replace);
else
codecs.Save(image, WebThumbnailViewer1.Page.MapPath(sel_file), image.OriginalFormat, image.BitsPerPixel, 1, 1, 0, CodecsSavePageMode.Append);
}
}
}
}
} |