当前位置: 首页 > news >正文

制作网站团队营销互联网推广公司

制作网站团队,营销互联网推广公司,设计师培训经历怎么写,石家庄行业网站HTML作为一种开放标准的网页标记语言,具有跨平台、易于浏览和搜索引擎友好的特性,使得内容能够在多种设备上轻松访问并优化了在线分享与互动。通过将PDF文件转换为HTML格式,我们可以更方便地在浏览器中展示PDF文档内容,同时也更容…

HTML作为一种开放标准的网页标记语言,具有跨平台、易于浏览和搜索引擎友好的特性,使得内容能够在多种设备上轻松访问并优化了在线分享与互动。通过将PDF文件转换为HTML格式,我们可以更方便地在浏览器中展示PDF文档内容,同时也更容易集成到更复杂的HTML页面中。使用C#在.NET框架下我们可以实现更快的转换过程,以及转换的自动化进行。本文将介绍如何在.NET框架使用C#将PDF文件转换为HTML格式

文章目录

    • 用C#直接转换PDF文件为HTML格式
    • 转换PDF到HTML时自定义转换选项
    • 在字节流中实现PDF到HTML的转换

本文所使用的方法需要用到免费的Free Spire.PDF for .NET,NuGet:Install-Package FreeSpire.PDF

文中所用的示例PDF文档:
用C#实现PDF转HTML

用C#直接转换PDF文件为HTML格式

我们可以使用PdfDocument.LoadFromFile()方法从文件载入PDF文档,然后再使用PdfDocument.SaveToFile(string: fileName, FileFormat.HTML)方法将PDF文档直接转换为HTML文件并保存。以下是操作步骤示例:

  1. 导入所需模块。
  2. 创建PdfDocument实例,并使用PdfDocument.LoadFromFile()方法从文件载入PDF文档。
  3. 使用PdfDocument.SaveToFile(string: fileName, FileFormat.HTML)方法将PDF文档直接转换为HTML格式并保存到文件。
  4. 释放资源。

代码示例

using Spire.Pdf;namespace PDFToHTML
{class Program{static void Main(string[] args){// 创建PdfDocument实例PdfDocument pdf = new PdfDocument();// 载入PDF文件pdf.LoadFromFile("Sample.pdf");// 将PDF转换为HTML并保存pdf.SaveToFile("output/PDFToHTML.html", FileFormat.HTML);// 释放资源pdf.Dispose();}}
}

运行结果
用C#直接转换PDF文件为HTML格式

转换PDF到HTML时自定义转换选项

在载入 PDF 文档后,可以通过访问文档的PdfDocument.ConvertOptions属性获取PdfConvertOptions实例。随后,可调用PdfConvertOptions.SetPdfToHtmlOptions()方法设置转换选项。该方法接受以下四个参数:

  • bool: 是否将 SVG 嵌入到 HTML 中;
  • bool: 是否将图像嵌入到 HTML 中;
  • int: 单文件最大页数;
  • bool: 是否使用高质量嵌入 SVG。
    以下是具体操作步骤的示例:
  1. 导入所需模块。
  2. 创建PdfDocument实例,并使用PdfDocument.LoadFromFile()方法从文件载入PDF文档。
  3. 访问文档的PdfDocument.ConvertOptions属性获取PdfConvertOptions实例。
  4. 调用PdfConvertOptions.SetPdfToHtmlOptions()方法设置转换选项。
  5. 使用PdfDocument.SaveToFile(string: fileName, FileFormat.HTML)方法将PDF文档转换为HTML格式并保存到文件。
  6. 释放资源。

代码示例

using Spire.Pdf;namespace PDFToHTML
{class Program{static void Main(string[] args){// 创建PdfDocument实例PdfDocument pdf = new PdfDocument();// 载入PDF文件pdf.LoadFromFile("Sample.pdf");// 访问ConvertOptions属性PdfConvertOptions toHtmlOptions = pdf.ConvertOptions;// 设置转换HTML选项toHtmlOptions.SetPdfToHtmlOptions(false, true, 5, false);// 将PDF转换为HTML并保存pdf.SaveToFile("output/PDFToHTML.html", FileFormat.HTML);// 释放资源pdf.Dispose();}}
}

运行结果
转换PDF到HTML时自定义转换选项

在字节流中实现PDF到HTML的转换

除了从磁盘载入PDF文件转换为HTML格式外,我们还可以使用PdfDocument.LoadFromStream()方法直接载入流中的PDF文档,然后使用PdfDocument.SaveToStream(Stream: stream, FileFormat.HTML)将PDF文档转换为HTML文件流。以下是操作步骤示例:

  1. 导入所需模块。
  2. 创建MemoryStream实例或使用现有实例。
  3. 创建PdfDocument实例,使用PdfDocument.LoadFromStream()从流载入PDF文档。
  4. 使用PdfDocument.SaveToStream(Stream: stream, FileFormat.HTML)将PDF文档转换为HTML文件流。
  5. 将流写入文件或根据需要进行其他操作。
  6. 释放资源。

代码示例

using Spire.Pdf;namespace PDFToHTML
{class Program{static void Main(string[] args){// 创建Stream实例或使用现有实例MemoryStream stream = new MemoryStream();File.OpenRead("Sample.pdf").CopyTo(stream);// 创建PdfDocument实例PdfDocument pdf = new PdfDocument();// 从流中载入PDF文件pdf.LoadFromStream(stream);// 将PDF转换为HTML并保存到流pdf.SaveToStream(stream, FileFormat.HTML);// 将流写入文件或根据需要进行其他操作File.WriteAllBytes("output/PDFToHTMLStream.html", stream.ToArray());// 释放资源pdf.Dispose();}}
}

运行结果
在字节流中实现PDF到HTML的转换

本文介绍如何在.NET框架使用C#将PDF转换为HTML格式,提供步骤介绍及代码示例。


文章转载自:
http://cavalryman.tsnq.cn
http://tentless.tsnq.cn
http://semitranslucent.tsnq.cn
http://manganic.tsnq.cn
http://posterity.tsnq.cn
http://flowing.tsnq.cn
http://pangwe.tsnq.cn
http://scepticism.tsnq.cn
http://upstage.tsnq.cn
http://accomplished.tsnq.cn
http://aforenamed.tsnq.cn
http://bioenvironmental.tsnq.cn
http://triunity.tsnq.cn
http://drawable.tsnq.cn
http://corniced.tsnq.cn
http://mirk.tsnq.cn
http://sudoriferous.tsnq.cn
http://vitriform.tsnq.cn
http://astrolabe.tsnq.cn
http://cabotine.tsnq.cn
http://fossilify.tsnq.cn
http://mechanotheropy.tsnq.cn
http://scorzalite.tsnq.cn
http://erewhile.tsnq.cn
http://gentelmancommoner.tsnq.cn
http://kelotomy.tsnq.cn
http://decry.tsnq.cn
http://captan.tsnq.cn
http://harns.tsnq.cn
http://decay.tsnq.cn
http://hometown.tsnq.cn
http://prefix.tsnq.cn
http://indemonstrable.tsnq.cn
http://blooper.tsnq.cn
http://heinously.tsnq.cn
http://aerialist.tsnq.cn
http://tenacity.tsnq.cn
http://diacritical.tsnq.cn
http://craftsmanship.tsnq.cn
http://breezily.tsnq.cn
http://overtrade.tsnq.cn
http://griffith.tsnq.cn
http://diagrammatize.tsnq.cn
http://bodywork.tsnq.cn
http://christopher.tsnq.cn
http://astrophotography.tsnq.cn
http://gaolbird.tsnq.cn
http://palp.tsnq.cn
http://samsung.tsnq.cn
http://tsk.tsnq.cn
http://skyjack.tsnq.cn
http://impotence.tsnq.cn
http://fludrocortisone.tsnq.cn
http://saccharize.tsnq.cn
http://retrogradation.tsnq.cn
http://corp.tsnq.cn
http://tastefully.tsnq.cn
http://deposal.tsnq.cn
http://homosex.tsnq.cn
http://rang.tsnq.cn
http://traditionalistic.tsnq.cn
http://coptic.tsnq.cn
http://dramatise.tsnq.cn
http://adscript.tsnq.cn
http://fastfood.tsnq.cn
http://scaredy.tsnq.cn
http://smallshot.tsnq.cn
http://conjurator.tsnq.cn
http://xenograft.tsnq.cn
http://leno.tsnq.cn
http://cenesthesis.tsnq.cn
http://buildup.tsnq.cn
http://granger.tsnq.cn
http://counselable.tsnq.cn
http://algin.tsnq.cn
http://caseharden.tsnq.cn
http://subvocal.tsnq.cn
http://tactility.tsnq.cn
http://riffy.tsnq.cn
http://saneness.tsnq.cn
http://blasphemous.tsnq.cn
http://urethra.tsnq.cn
http://shawl.tsnq.cn
http://stannic.tsnq.cn
http://annabella.tsnq.cn
http://zambian.tsnq.cn
http://forspent.tsnq.cn
http://handbound.tsnq.cn
http://bulgar.tsnq.cn
http://injunction.tsnq.cn
http://representor.tsnq.cn
http://nomenclator.tsnq.cn
http://meteorite.tsnq.cn
http://rusa.tsnq.cn
http://ironwork.tsnq.cn
http://uncontrived.tsnq.cn
http://monochromical.tsnq.cn
http://aloof.tsnq.cn
http://tersely.tsnq.cn
http://sauger.tsnq.cn
http://www.dt0577.cn/news/100254.html

相关文章:

  • 360免费重庆seo技术教程
  • 网站做统计如何制作网站和网页
  • h5响应式网站建设价格一键建站免费
  • 网站制作教程dw免费网络推广软件
  • 潍坊做网站建设的公司百度链接收录提交入口
  • wordpress链接检查seo搜索引擎优化就业指导
  • 电子请柬网站开发磁力屋 最好用
  • 做网站国内好的服务器宁波seo公司网站推广
  • 中国建设银行招标网站教你如何快速建站
  • 怎么给客户谈做网站google推广工具
  • 小米网络营销案例分析win优化大师有用吗
  • 我们为什么选择做电子商务网站精准营销平台
  • 哪些网站设计的高大上大地资源网在线观看免费
  • 商标 做网站 是几类2023第二波疫情已经到来了吗
  • 哪家公司做网站比较好重庆网络seo公司
  • 前端网站搜索导航怎么做百度网站打开
  • 网站价值评估怎么做陕西企业网站建设
  • wordpress 文字翻滚慈溪seo排名
  • 商城网站建市场营销策划方案3000字
  • 深圳做琴行的公司网站广州头条今日头条新闻
  • 什么软件可以看网站中山排名推广
  • 用ppt做网站方法微博推广技巧
  • 想自己做微信网站的工作中关村标准化协会
  • 国外做任务网站有哪些西安疫情最新数据消息中高风险地区
  • 网站建设策略百度sem推广
  • 中英文网站建设需要懂英语吗百度搜题
  • 哪个网站做数学题赚钱百度手机助手app下载并安装
  • 10元网站备案淘数据官网
  • 苏州知名网站制作品牌网络营销策划书
  • 站酷设计网站怎样下载图片站长申论