首页 \ 问答 \ 如何将多个网页转换为一个pdf文档?(How do I convert several web pages into one pdf document?)

如何将多个网页转换为一个pdf文档?(How do I convert several web pages into one pdf document?)

public FileResult Download() 
{ 

    var doc = new EO.Pdf.PdfDocument(); 
    EO.Pdf.HtmlToPdf.ConvertUrl("http://www.google.com/", doc); 

    var ms = new MemoryStream();     
    doc.Save(ms); 

    ms.Position = 0; 

    return new FileStreamResult(ms, "application/pdf") 
               { 
                   FileDownloadName = "download.pdf"
               }; 
}

如果可能的话,请您展示如何扩展上面的代码,以便能够将多个网页转换成一个pdf文档?

棘手的部分是我们不知道用户可能尝试转换的页面。

因此,如上面的代码所示,对网页进行硬编码并没有帮助我们。

任何帮助是极大的赞赏。

//Create a new PdfDocument object
var doc = new EO.Pdf.PdfDocument();

//Convert two ore more different pages into the same PdfDocument

EO.Pdf.HtmlToPdf.ConvertUrl("c:\\1.html", doc);

EO.Pdf.HtmlToPdf.ConvertUrl("c:\\2.html", doc);

最新代码:

public FileResult Download() 
{ 
    var doc = new EO.Pdf.PdfDocument(); 

foreach(var url in passedUrls)  
{ 
EO.Pdf.HtmlToPdf.ConvertUrl(url, doc);   
doc.Save(ms);   
}


    ms.Position = 0; 

    return new FileStreamResult(ms, "application/pdf") 
               { 
                   FileDownloadName = "download.pdf"
               }; 
}

亚当的最新消息(谢谢先生)

public FileResult Download() 
{ 

var documents = new List<EO.Pdf.PdfDocument>(); 
foreach(var url in passedUrls) 
{ 
    var doc = new EO.Pdf.PdfDocument(); 
    EO.Pdf.HtmlToPdf.ConvertUrl(url, doc); 
    documents.Add(doc); 
} 

EO.Pdf.PdfDocument mergedDocument = EO.Pdf.PdfDocument.Merge(documents.ToArray()); 
}

希望其他人发现这些代码很有用。


public FileResult Download() 
{ 

    var doc = new EO.Pdf.PdfDocument(); 
    EO.Pdf.HtmlToPdf.ConvertUrl("http://www.google.com/", doc); 

    var ms = new MemoryStream();     
    doc.Save(ms); 

    ms.Position = 0; 

    return new FileStreamResult(ms, "application/pdf") 
               { 
                   FileDownloadName = "download.pdf"
               }; 
}

Can you please show if possible, how to extend the code above to be able to convert several web pages into one pdf document?

The tricky part is that we don't know what pages a user is likely to attempt to convert.

So, hardcoding the webpages as the code above shows isn't helping us.

Any help is greatly appreciated.

//Create a new PdfDocument object
var doc = new EO.Pdf.PdfDocument();

//Convert two ore more different pages into the same PdfDocument

EO.Pdf.HtmlToPdf.ConvertUrl("c:\\1.html", doc);

EO.Pdf.HtmlToPdf.ConvertUrl("c:\\2.html", doc);

Latest code:

public FileResult Download() 
{ 
    var doc = new EO.Pdf.PdfDocument(); 

foreach(var url in passedUrls)  
{ 
EO.Pdf.HtmlToPdf.ConvertUrl(url, doc);   
doc.Save(ms);   
}


    ms.Position = 0; 

    return new FileStreamResult(ms, "application/pdf") 
               { 
                   FileDownloadName = "download.pdf"
               }; 
}

Latest from Adam (thank you sir)

public FileResult Download() 
{ 

var documents = new List<EO.Pdf.PdfDocument>(); 
foreach(var url in passedUrls) 
{ 
    var doc = new EO.Pdf.PdfDocument(); 
    EO.Pdf.HtmlToPdf.ConvertUrl(url, doc); 
    documents.Add(doc); 
} 

EO.Pdf.PdfDocument mergedDocument = EO.Pdf.PdfDocument.Merge(documents.ToArray()); 
}

Hopefully, others find these codes useful.


原文:
更新时间:2022-01-25 22:01

最满意答案

就像熊会吃你说的,似乎这两位编辑对选项卡的广泛程度有不同的看法。 默认情况下,一个制表符( \t )在emacs上是8个空格。 也许TextMate在您的配置中显示一个标签为4个空格?

您可以在emacs中设置您的制表符宽度(在这种情况下为4个空格),方法是将以下内容添加到.emacs中:

(setq-default tab-width 4)

我对配置TextMate一无所知。

或者,您可以配置emacs使用空格而不是制表符来缩进:

(setq-default indent-tabs-mode nil)

同样,我不知道你是如何用TextMate做到的。


Like Bears will eat you said, it seems like the two editors have differing opinions on how wide a tab is. Be default a tab character (\t) is 8 spaces wide on emacs. Maybe TextMate shows a tab as 4 spaces in your configuration?

You can set your tab-width in emacs (to 4 spaces in this case) by adding the following to your .emacs:

(setq-default tab-width 4)

I don't know anything about configuring TextMate.

Alternatively you can configure emacs to use spaces rather than tabs for indentation:

(setq-default indent-tabs-mode nil)

Again, I don't know how you do that with TextMate.

相关问答

更多
  • 在过去4个月里,邮件列表中有一个强烈的暗示或者直截了当的说法,几乎是肯定的,到2009年夏天至少会有一个测试版,但是我还没有能够挖掘它,所以我不确定。 说实话,我并不关心TextMate。 当然,我很乐意看到,因为新的东西总是很酷; 但在我看来,TextMate - 拆分窗格查看和更好的撤消支持中只有2个大功能缺失 - 我发现没有这些功能就可以生活。 TextMate 2可能会很棒,但是现在的TextMate是一个很好的编辑器,我不用担心TM2出来。 更新:公众阿尔法将于 2011年圣诞节到期 。 更新:现 ...
  • 这很简单: Cx rt It's as simple as this: C-x r t
  • 拉起椅子的儿子,让我讲这个。 在Xcode之前,有VIM和Emacs。 我知道这很难想象,但这是真的。 许多人习惯了VIM / Emacs,因此继续使用它。 Emacs是非常可定制的,并提供几乎可以想象的一切(包括内置收缩和河内的塔)。 您可以轻松地从Emacs调用编译器,并根据需要创建自己的扩展。 VIM具有令人难以置信的正则表达式引擎(Emacs也是如此),非常方便,因为(VI)几乎每个Unix操作系统都有,如果没有箭头键(是啊,真正的老学校) 人们使用键移动文件是非常好的,而不必使用鼠标。 Emacs ...
  • 您必须创建一个Bundle Command和一个键盘快捷方式来执行此操作。 在TextMate中,转到Bundles - > Bundle Editor 在我们自己的Bundle中创建一个新命令。 称之为“在终端执行” 将“保存”设置为“无”,将“输入”设置为“选定文本”,将“或”设置为“线”。 将“输出设置为丢弃” 在“激活”中选择您自己的快捷方式。 我选择了Apple Shift U. 将下面的命令粘贴到“命令”框中(格式化导致我麻烦) 关闭Bundle Editor,然后选择Bundles - > B ...
  • 更简单的答案: 安装MacRuby 转到TextMate-> Preferences-> Advanced-> Shell Variables,并添加一个名为TM_RUBY的变量设置为/usr/local/bin/macruby 。 或者,编辑PATH变量以包含/usr/local/bin/ ,并将TM_RUBY设置为macruby 。 如果你已经通过RVM安装了MacRuby,那么改为: 生成稳定的包装: rvm wrapper macruby-0.8 macruby #创建〜/ .rvm / bin / ...
  • TextMate在2006年试用时感觉“神奇”。它的Tab-Completion / Snippets系统,矩形选择/编辑,可扩展性,很好的SVN集成和整体风格使它比TextWrangler,DreamWeaver或我在时间。 我对此感到非常兴奋,并向我传播了它的力量。 我在完成了一个试用版的项目后才购买它。 那个时候对我来说每一分钱都是值得的。 不过,我花了大约一年的时间才达到高原。 我非常了解TextMate,但它开始感觉“有限”。 实际上,TextMate非常有影响力:现在许多IDE /编辑器都有许多 ...
  • 我认为这些设置应该做到这一点: (defun my-html-mode-hook () (setq tab-width 4) (setq indent-tabs-mode t) (define-key html-mode-map (kbd "") 'my-insert-tab) (define-key html-mode-map (kbd "C->") 'sgml-close-tag)) (defun my-insert-tab (&optional arg) (intera ...
  • 要清楚,您应该单击TextMate>首选项>高级> Shell变量 然后添加一个名为'TM_GROOVY'的变量,其值为'/Applications/groovy-1.8.4/bin/groovy' 不知道为什么但是对于我的实例我实际上明确指定了'... / groovy'。 To be clear you should click on TextMate > Preferences > Advanced > Shell Variables Then add a Variable named 'TM_GRO ...
  • 如何从emacs启动vi或TextMate(配对)? (async-shell-command "vi") ;; From Emacs 23.2 (shell-command "vi &") ;; Before Emacs 23.2 要启动TextMate,你需要安装TextMate的命令行工具,然后从emacs中,它是(thx Chetan): (async-shell-command "mate") ;; From Emacs 23.2 (shell-command "mate &") ;; ...
  • 就像熊会吃你说的,似乎这两位编辑对选项卡的广泛程度有不同的看法。 默认情况下,一个制表符( \t )在emacs上是8个空格。 也许TextMate在您的配置中显示一个标签为4个空格? 您可以在emacs中设置您的制表符宽度(在这种情况下为4个空格),方法是将以下内容添加到.emacs中: (setq-default tab-width 4) 我对配置TextMate一无所知。 或者,您可以配置emacs使用空格而不是制表符来缩进: (setq-default indent-tabs-mode nil) ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)