特别说明:需引用Aspose.PDF.dll

代码案例:

using System.IO;
using System;
using Aspose.Pdf;namespace Aspose.Pdf.Examples.CSharp.AsposePDF.DocumentConversion
{public class PDFToHTML{public static void Run(){// ExStart:PDFToHTML// The path to the documents directory.string dataDir = RunExamples.GetDataDir_AsposePdf_DocumentConversion();// Open the source PDF documentDocument pdfDocument = new Document(dataDir + "PDFToHTML.pdf");// Save the file into MS document formatpdfDocument.Save(dataDir + "output_out.html", SaveFormat.Html);// ExEnd:PDFToHTML}public static void ExcludeFontResources(){// ExStart:ExcludeFontResources// The path to the documents directory.string dataDir = RunExamples.GetDataDir_AsposePdf_DocumentConversion();string inFile = dataDir + "PDFToHTML.pdf";string outMainHtmlFile = dataDir + "ExcludeFontResources.pdf";// Initialize htmlOptionsHtmlSaveOptions htmlOptions = new HtmlSaveOptions{ExplicitListOfSavedPages = new[] { 1 },FixedLayout = true,CompressSvgGraphicsIfAny = false,SaveTransparentTexts = true,SaveShadowedTextsAsTransparentTexts = true,//FontSavingMode = HtmlSaveOptions.FontSavingModes.DontSave,ExcludeFontNameList = new[] { "ArialMT", "SymbolMT" },DefaultFontName = "Comic Sans MS",UseZOrder = true,LettersPositioningMethod = HtmlSaveOptions.LettersPositioningMethods.UseEmUnitsAndCompensationOfRoundingErrorsInCss,PartsEmbeddingMode = HtmlSaveOptions.PartsEmbeddingModes.NoEmbedding,RasterImagesSavingMode = HtmlSaveOptions.RasterImagesSavingModes.AsEmbeddedPartsOfPngPageBackground,SplitIntoPages = false};Document pdfDocument = new Document(inFile);// SavepdfDocument.Save(outMainHtmlFile, htmlOptions);// ExEnd:ExcludeFontResources}public static void MultiPageHTML(){// ExStart:MultiPageHTML// The path to the documents directory.string dataDir = RunExamples.GetDataDir_AsposePdf_DocumentConversion();// Open the source PDF documentDocument pdfDocument = new Document(dataDir + "PDFToHTML.pdf");// Instantiate HTML SaveOptions objectHtmlSaveOptions htmlOptions = new HtmlSaveOptions();// Specify to split the output into multiple pageshtmlOptions.SplitIntoPages = true;// Save the documentpdfDocument.Save(@"MultiPageHTML_out.html", htmlOptions);// ExEnd:MultiPageHTML}public static void SaveSVGFiles(){// ExStart:SaveSVGFiles// The path to the documents directory.string dataDir = RunExamples.GetDataDir_AsposePdf_DocumentConversion();// Load the PDF fileDocument doc = new Document(dataDir + "PDFToHTML.pdf");// Instantiate HTML save options objectHtmlSaveOptions newOptions = new HtmlSaveOptions();// Specify the folder where SVG images are saved during PDF to HTML conversionnewOptions.SpecialFolderForSvgImages = dataDir;// Save the output filedoc.Save(dataDir + "SaveSVGFiles_out.html", newOptions);// ExEnd:SaveSVGFiles}public static void CompressSVGImages(){// The path to the documents directory.string dataDir = RunExamples.GetDataDir_AsposePdf_DocumentConversion();// Load the PDF fileDocument doc = new Document(dataDir + "PDFToHTML.pdf");// ExStart:CompressSVGImages// Create HtmlSaveOption with tested featureHtmlSaveOptions newOptions = new HtmlSaveOptions();// Compress the SVG images if there are anynewOptions.CompressSvgGraphicsIfAny = true;// ExEnd:CompressSVGImages// Save the output filedoc.Save(dataDir + "CompressSVGImages_out.html", newOptions);}public static void SpecifyingImageFolder(){// The path to the documents directory.string dataDir = RunExamples.GetDataDir_AsposePdf_DocumentConversion();// Load the PDF fileDocument doc = new Document(dataDir + "PDFToHTML.pdf");// ExStart:SpecifyingImageFolder// Create HtmlSaveOption with tested featureHtmlSaveOptions newOptions = new HtmlSaveOptions();// Specify the separate folder to save imagesnewOptions.SpecialFolderForAllImages = dataDir;// ExEnd:SpecifyingImageFolder// Save the output filedoc.Save(dataDir + "SpecifyingImageFolder_out.html", newOptions);}public static void CreateSubsequentFiles(){// ExStart:CreateSubsequentFiles// The path to the documents directory.string dataDir = RunExamples.GetDataDir_AsposePdf_DocumentConversion();Document doc = new Document(dataDir + "PDFToHTML.pdf");HtmlSaveOptions options = new HtmlSaveOptions();// This is the tested settingoptions.HtmlMarkupGenerationMode = HtmlSaveOptions.HtmlMarkupGenerationModes.WriteOnlyBodyContent;options.SplitIntoPages = true;doc.Save(dataDir + "CreateSubsequentFiles_out.html", options);// ExEnd:CreateSubsequentFiles}public static void TransparentTextRendering(){// ExStart:TransparentTextRendering// The path to the documents directory.string dataDir = RunExamples.GetDataDir_AsposePdf_DocumentConversion();Document doc = new Document(dataDir + "PDFToHTML.pdf");HtmlSaveOptions htmlOptions = new HtmlSaveOptions();htmlOptions.SaveShadowedTextsAsTransparentTexts = true;htmlOptions.SaveTransparentTexts = true;doc.Save(dataDir + "TransparentTextRendering_out.html", htmlOptions);// ExEnd:TransparentTextRendering}public static void LayersRendering(){// ExStart:LayersRendering// The path to the documents directory.string dataDir = RunExamples.GetDataDir_AsposePdf_DocumentConversion();Document doc = new Document(dataDir + "PDFToHTML.pdf");// Instantiate HTML SaveOptions objectHtmlSaveOptions htmlOptions = new HtmlSaveOptions();// Specify to render PDF document layers separately in output HTMLhtmlOptions.ConvertMarkedContentToLayers = true;// Save the documentdoc.Save(dataDir + "LayersRendering_out.html", htmlOptions);// ExEnd:LayersRendering}public static void CreatingHtmlWithFullContentWidth(){//ExStart: CreatingHtmlWithFullContentWidth// The path to the documents directory.string dataDir = RunExamples.GetDataDir_AsposePdf_DocumentConversion();HtmlSaveOptions saveOptions = new HtmlSaveOptions();saveOptions.FixedLayout = (false);saveOptions.FlowLayoutParagraphFullWidth = true;Document doc = new Document(dataDir + "FlowLayoutParagraphFullWidth.Pdf");doc.Save(dataDir + "FlowLayoutParagraphFullWidth_out.html", saveOptions);//ExEnd: CreatingHtmlWithFullContentWidth}public static void CenterAlignText(){//ExStart: CenterAlignTextHtmlSaveOptions htmlOptions = new HtmlSaveOptions();// init MarginPartStyle with margin in 20 pointsvar commonMargin = new SaveOptions.MarginPartStyle(20);// init MarginPartStyle with margin value autovar autoMargin = new SaveOptions.MarginPartStyle(true);// set commonMargin to every page sidehtmlOptions.PageMarginIfAny = new HtmlSaveOptions.MarginInfo(commonMargin);// set horizontal page align to centerhtmlOptions.PageMarginIfAny.LeftMarginIfAny = autoMargin;htmlOptions.PageMarginIfAny.RightMarginIfAny = autoMargin;//ExEnd: CenterAlignText}}
}

C# PDF操作之-PDF转HTML相关推荐

  1. C# PDF操作之-PDF转TXT

    特别说明:需引用Aspose.PDF.dll 代码案例: using System.IO; using Aspose.Pdf; using Aspose.Pdf.Text; using System; ...

  2. C# PDF操作之-PDF转PPT

    特别说明:需引用Aspose.PDF.dll 代码案例: using System; using System.IO; using Aspose.Pdf;namespace Aspose.Pdf.Ex ...

  3. C# PDF操作之-PDF转EXCEL

    特别说明:需引用Aspose.PDF.dll 代码案例: OpenFileDialog openFileDialog1 = new OpenFileDialog(); //显示选择文件对话框 open ...

  4. Linux下PDF操作与转换

    Linux下PDF操作与转换 2013-07-02 09:44:58 分类: LINUX 如果说PDF是电子纸张,那么pdftk就是电子起钉器.打孔机.粘合剂.解密指环和 X光镜片.Pdftk是一个简 ...

  5. 打造全键盘操作的PDF阅读器

    其实我只想要一个非常简单的PDF阅读器,不要很花哨的功能,只要能够: 速度够快,不要翻一页等半天: 全键盘操作,不想在鼠标和键盘之间来回倒腾: 可以改变背景色,深夜的白光好刺眼: 自由旋转页面,有些P ...

  6. Aspose.Words操作Word.PDF,让图片和文本垂直居中,水平居中解决方案

    Aspose.Words操作Word.PDF,让图片和文本垂直居中,水平居中解决方案 参考文章: (1)Aspose.Words操作Word.PDF,让图片和文本垂直居中,水平居中解决方案 (2)ht ...

  7. 【报告分享】万达文旅项目新媒体营销操作手册.pdf(附下载链接)

    今天给大家分享的报告是万达文旅的<万达文旅项目新媒体营销操作手册.pdf>,需要搭建新媒体营销团队及方案的朋友们可以参考下,手册共包含如下七大部分: 1.新媒体营销操作手册目标: 2.新媒 ...

  8. 大多数人不敢想的PDF操作:添加书签,电子签名,压缩,修改文字,提取部分页面为新文件、批量导出为图片

    目录 PDF神仙级软件和网站(免费) PDF加书签 PDF电子签名 PDF文件压缩 修改PDF内的文字 提取部分页面为新PDF文件 PDF批量导出为图片 PDF神仙级软件和网站(免费) 主要以比较方便 ...

  9. 免费离线PDF工具箱,PDF工具大全,PDF合并PDF加密PDF解密PDF格式转换PDF分割PDF旋转以及从PDF中提取图片,满足对PDF操作的一切需求~完全免费无使用次数限制,文末附下载链接~

    一款 完全免费 的PDF工具箱,软件一共 内置45个和PDF文件操作相关的功能,无需注册登录 即可 免费使用,所有的功能都 不限制使用次数,你对PDF操作的大多数需求它都能满足!而且 所有操作均在本地 ...

最新文章

  1. 史上最大规模 DDoS 攻击,每秒 1720 万次 HTTP 请求
  2. mysql 缓存监控_MySQL监控性能的一些方法总结
  3. 计算机应用基础任务化教程知识点,计算机应用基础任务化教程
  4. 公众号点击图片变成另一张_微信公众号点击出现图片是怎么实现的?
  5. 晶创6电梯卡的数据结构_修改电梯卡发现“商机”,男子涉嫌盗窃罪!
  6. 【bzoj2406】矩阵 二分+有上下界可行流
  7. Careercup - Microsoft面试题 - 5680049562845184
  8. Java的对象序列化之serialVersionUID问题
  9. Sublime Text新增GBK编码支持
  10. 如何在计算机设置鼠标宏,鼠标宏怎么设置,教您鼠标如何设置宏
  11. 福州到横店嘉兴三日游(仅供参考)
  12. rk3288 linux 编译,RK3288系统编译及环境搭建
  13. latex 表格标题分行和居中
  14. 知识点3-设计模式与实践
  15. BUUCTF RE WP31-32 [WUSTCTF2020]level1、[GWCTF 2019]xxor
  16. 3dsmax网格重构细分
  17. 量子信息与量子计算_我们会看到量子计算革命吗?
  18. *6-3 节约小能手
  19. linux进程网络监控,linux下的进程、网络、性能监控命令
  20. 深入理解Android之Gradle

热门文章

  1. 西餐和计算机专业哪个好,烹饪专业学校前十排名有哪些
  2. Python中range与xrange的区别
  3. android手机收不到彩信,小米4手机收不到彩信是什么原因?小米4彩信设置教程
  4. 人工智能行业想当高校老师要做什么准备?
  5. 游戏成瘾是病?这些游戏却大受家长欢迎!
  6. NOIP2016提高组 第二天第三题 愤怒的小鸟angrybirds 题解
  7. 洛谷P2800 又上锁妖塔
  8. Mybatis 手动清除缓存
  9. FindWin10Old32ExE
  10. 在word中如何取消分隔符(转)