惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

爱范儿
爱范儿
T
Troy Hunt's Blog
B
Blog
N
Netflix TechBlog - Medium
H
Help Net Security
PCI Perspectives
PCI Perspectives
罗磊的独立博客
SecWiki News
SecWiki News
S
Security Affairs
Webroot Blog
Webroot Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Hacker News: Ask HN
Hacker News: Ask HN
Google Online Security Blog
Google Online Security Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
V
Visual Studio Blog
V2EX - 技术
V2EX - 技术
Recorded Future
Recorded Future
Schneier on Security
Schneier on Security
The Last Watchdog
The Last Watchdog
博客园 - 【当耐特】
Attack and Defense Labs
Attack and Defense Labs
S
Secure Thoughts
Hugging Face - Blog
Hugging Face - Blog
Forbes - Security
Forbes - Security
Application and Cybersecurity Blog
Application and Cybersecurity Blog
TaoSecurity Blog
TaoSecurity Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
M
MIT News - Artificial intelligence
博客园_首页
A
About on SuperTechFans
Microsoft Azure Blog
Microsoft Azure Blog
T
Tailwind CSS Blog
The Cloudflare Blog
P
Proofpoint News Feed
D
DataBreaches.Net
N
News and Events Feed by Topic
G
Google Developers Blog
B
Blog RSS Feed
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
MyScale Blog
MyScale Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
AI
AI
O
OpenAI News
雷峰网
雷峰网
C
Check Point Blog
大猫的无限游戏
大猫的无限游戏
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Blog — PlanetScale
Blog — PlanetScale
有赞技术团队
有赞技术团队

博客园 - 蒜头

Mailbox unavailable. The server response was: 5.7.1 Unable to relay for (email address). 再谈Images到xps,pdf的转换 SQL Server 2005中xml类型和函数的简单应用 部分Office 2007文件格式转换为xps和pdf代码整理 Image.FromFile gives "Out of Memory" Exception for icon - 蒜头 SQL 2005 全文检索(续) 简单实现C#生成Excel 2007文件并下载 简单应用ReportViewer控件 配置SQL Server Session方法 采用负载均衡,部署了两个ASP.NET 2.0的站点服务器碰到的问题 初试VSTS 2008(TFS安装) Windows Server 2003分区修改方法[转载] 制作VSTO 2005 SE开发的Office 2007 AddIn的安装包 一个简单的document library event handler VS 2005 SP1 安装错误 [续] 一个简单的Checkbox Custom Field Type ASP.NET 2.0 SQL Cache 配置方法 解读Document Library关于权限的对象模型 SharePoint应用AJAX.NET和AJAX Control Toolkit
简单介绍PDF,XPS,Images,Office 2007之间的转换方法 - 蒜头 - 博客园
蒜头 · 2008-03-12 · via 博客园 - 蒜头

在实现这些文件格式转换时,使用了第三方的一个组件:Amyuni PDF Creator .NET,Licence好像需要399美刀。这里使用的是30天试用Licence。主要需要是三个dll,在项目中添加对他们的引用就可以了.在B/S应用中部署时可能碰到问题在此blog第二条描述解决办法。

        private string licensee
            
= "PDF Creator Evaluation license";
        
private string activationCode
            
= "07EFCDAB0100010048A7F99BCA4506BAE4D4F8695A701B085D550F57C0436768AD20DB28763CE97934AFB3DC8D2228B55AB06E9466AA8A772032BF46FBFAB5";

组件提供了部分转换方法,可以将PDF文件通过下面的方法转换成相应的格式:

PDF->XPS:

            acPDFCreatorLib.Initialize();
            acPDFCreatorLib.SetLicenseKey(licensee, activationCode);

            System.IO.FileStream pdfFile 
= new System.IO.FileStream("license.pdf", FileMode.Open);
            IacDocument document 
= new IacDocument(null);

            
//Open the pdf document
            document.Open(pdfFile, "");

            
bool flag = document.ExportToXPS("license.xps", IacXPSExportOptions.acXPSExportOptionsNone);

            pdfFile.Close();


XPS->PDF:

            acPDFCreatorLib.Initialize();
            acPDFCreatorLib.SetLicenseKey(licensee, activationCode);

            System.IO.FileStream pdfFile 
= new System.IO.FileStream("license.xps", FileMode.Open, FileAccess.Read, FileShare.Read);
            IacDocument document 
= new IacDocument(null);

            
//Open the pdf document
            document.Open(pdfFile, "");

            System.IO.FileStream file1 
= new System.IO.FileStream("new.pdf", System.IO.FileMode.Create,
System.IO.FileAccess.Write, System.IO.FileShare.Read);

            
bool flag = document.Save(file1, IacFileSaveOption.acFileSaveView);

            pdfFile.Close();
            file1.Close();

Image -> PDF:

      private void ConverToPDF(string sourcePath, string targetPath)
        
{
            
// initialize library and set the license key
            acPDFCreatorLib.Initialize();
            acPDFCreatorLib.SetLicenseKey(licensee, activationCode);

            
//creating a new document
            IacDocument document = new IacDocument(null);
            System.IO.FileStream file1 
= new System.IO.FileStream(targetPath, System.IO.FileMode.Create,
            System.IO.FileAccess.Write, System.IO.FileShare.Read);
            document.StartSave(file1, Amyuni.PDFCreator.IacFileSaveOption.acFileSaveView);

            
int pageIndex = 1;

            
//create a picture object on each page
            IacPage page = document.GetPage(pageIndex);
            String objectName 
= "image";
            Amyuni.PDFCreator.IacObject picture 
= page.CreateObject(IacObjectType.acObjectTypePicture, objectName);

            
//position the picture
            int WidthInPixels = page.GetPageFormat().Width;
            
int HeightInPixels = page.GetPageFormat().Length;
            
            Image IMG 
= Image.FromFile(sourcePath);
            GraphicsUnit GU 
= GraphicsUnit.Millimeter;
            RectangleF Bounds 
= IMG.GetBounds(ref GU);
            
if (WidthInPixels > Bounds.Width * 10)
            
{
                WidthInPixels 
= (int)Bounds.Width;
            }

            HeightInPixels 
= (int)((WidthInPixels / Bounds.Width * 10* Bounds.Height * 10);

            picture.Attribute(
"Right").Value = WidthInPixels;
            picture.Attribute(
"Bottom").Value = HeightInPixels;
            picture.Attribute(
"FileName").Value = sourcePath;

            
//insert a bookmark that points to this page
            document.RootBookmark.InsertChild(pageIndex, objectName, "image");
            
//save the current page
            document.SavePageNumber(pageIndex);
            
//clear the page contents to save memory
            page.Clear();
            
// add a new page after the current one
            document.AddPage(pageIndex);

            
//close the pdf document
            document.EndSave();
        }

Office 2007文件格式转换为PDF和XPS格式的方法也比较简单,微软提供了一个转换为XPS和PDF的AddIn,安装后调用Office类库可以实现转换,MSDN上有相应的代码