网页打印媒体 - 解决方案?

时间:2022-09-25 23:34:37

I've been a big fan of MediaWiki and similar wiki-based text editors. I like the ability to quickly add text, collaborate, and share. However, there's always still the need for nicely formatted print output. Things like headers and footers (that say what I want them to say), page breaks, margins, etc.

我一直是MediaWiki和类似的基于wiki的文本编辑的忠实粉丝。我喜欢快速添加文本,协作和分享的能力。但是,仍然需要格式良好的打印输出。标题和页脚(表示我想要他们说的),分页符,边距等等。

Most solutions I've seen involve some sort of conversion to a intermediate print-media format (maybe MediaWiki to Microsoft Word or maybe some custom scripting that generates a PDF from the contents of a web page (with a lot of hard-coded references).

我见过的大多数解决方案涉及到某种中间打印媒体格式的转换(可能是MediaWiki到Microsoft Word,也可能是某些自定义脚本,它从网页内容生成PDF(带有大量硬编码引用) 。

Is there any more generic solution that exists for this problem? Any framework that seeks to merge HTML and web content in general into a print media output format?

是否存在针对此问题的更通用解决方案?任何寻求将HTML和Web内容合并为打印媒体输出格式的框架?

Any solutions, discussion regarding the pro's or con's, or whatever is welcome.

任何解决方案,关于赞成或反对的讨论,或任何欢迎。

Thanks!

Update: I think CSS will only get me so far though... I've used CSS for similar type output (MediaWiki by default has a print format that hides much of the nav bar stuff). Think of a MediaWiki article though -- imagine me being able to tweak a tag in the content or something similar and now my margin is 1 inch instead of .5 inches. That's more along the lines of what I'm aiming for.

更新:我认为CSS只会让我到目前为止...我已经使用CSS进行类似的输出(MediaWiki默认情况下有一种打印格式隐藏了大部分导航栏的东西)。想想一下MediaWiki的文章 - 想象一下我能够在内容中调整一个标签或者类似的东西,现在我的边距是1英寸而不是0.5英寸。这更符合我的目标。

6 个解决方案

#1


You may have heard of PediaPress, a company that has done a "wiki to print" (i.e PDF, but also ODF) deal with the Wikimedia Foundation. (See "Wikis Go Printable".) Their code is designed to work with MediaWiki and is open source.

您可能听说过PediaPress,这家公司已经与维基媒体基金会签订了“维基打印”(即PDF,但也包括ODF)。 (参见“Wikis Go Printable”。)他们的代码旨在与MediaWiki一起使用,并且是开源的。

But! It's even better than that. Check out this bookmarklet. You can use it to create PDFs or ODFs of any publicly-accessible MediaWiki page (maybe it needs the API to be enabled too...). And you can bundle multiple pages, from a single MediaWiki or multiple MediaWikis, into a single document. It's pretty freaking awesome in my book. :)

但!它甚至比那更好。看看这个书签。您可以使用它来创建任何可公开访问的MediaWiki页面的PDF或ODF(也许它也需要启用API ...)。您可以将多个页面从单个MediaWiki或多个MediaWikis捆绑到一个文档中。这本书在我的书中非常棒。 :)

ETA: PediaPress have put significant work into making something that looks really nice to read. It's not just the equivalent of MediaWiki's printable version converted to PDF.

ETA:PediaPress已经做了大量的工作来制作看起来非常好看的东西。它不仅仅相当于MediaWiki的可打印版本转换为PDF。

#2


http://www.princexml.com/

could be something for you. It converts xml and html pages to pdf documents.

可能适合你。它将xml和html页面转换为pdf文档。

#3


Using print CSS files is a really slick approach to reformatting pages for printing.

使用打印CSS文件是重新格式化打印页面的一种非常灵活的方法。

A lot of people fall back to PDF because it can be more powerful and easier.

很多人都回归到PDF,因为它可以更强大,更容易。

For most things, though, I think CSS markup is simpler and easier.

但是,对于大多数事情,我认为CSS标记更简单,更容易。

Look at the source for pages in * and you'll see references to media="print" (print.css)--a set of styles applied only when a browser prints the page.

查看*中页面的来源,您将看到对media =“print”(print.css)的引用 - 仅在浏览器打印页面时应用一组样式。

<link href="/Content/print.css" rel="stylesheet" media="print" type="text/css" />

You can use these to hide navbars, ads (or show different ads). Do some basic pagination, etc.

您可以使用这些来隐藏导航栏,广告(或显示不同的广告)。做一些基本的分页等

If you need more control over things like margins, you have to go outside the browser (PDF, Word, XPS, etc.).

如果您需要更多控制边距等内容,则必须在浏览器之外(PDF,Word,XPS等)。

#4


I've written a MediaWiki to LaTeX converter that tries to maintain the document structure of the source text. The document is then typeset with pdflatex to produce a very high quality, paginated document. Math markup is directly rendered by LaTeX, so the equations look great. The LaTeX documentclass / stylesheet is configurable from specialized commands in the wiki to directly control margins, page layout, fonts, extra packages and so on. This would fall in your second category of a custom script rather than a generic framework.

我已经编写了一个MediaWiki到LaTeX转换器,试图维护源文本的文档结构。然后使用pdflatex对文档进行排版,以生成质量非常高的分页文档。数学标记由LaTeX直接渲染,因此方程看起来很棒。 LaTeX文档类/样式表可以通过wiki中的专用命令进行配置,以直接控制边距,页面布局,字体,额外包等。这将属于您的第二类自定义脚本而不是通用框架。

There are many others, such as the Extension:Pdf_Export that uses htmldoc. While it is more general, it does a very poor job of pagination and creates lots of widows and orphans, doesn't do optimal text justification and doesn't do indexes, figures, self-references, etc. Additionally, if you use <math> markup in MediaWiki it only includes the low-res PNG files.

还有很多其他的,例如使用htmldoc的Extension:Pdf_Export。虽然它更通用,但它的分页工作非常糟糕,并且创造了大量的寡妇和孤儿,没有做出最佳的文本证明,也没有做索引,数字,自我引用等。另外,如果你使用 <在mediawiki中的math> markup它只包含低分辨率的PNG文件。

princexml is specialized for MediaWiki and produces good looking documents, but isn't available under a Free license. Since it is a closed-source product, your ability to control the output is limited.

princexml专门用于MediaWiki并生成外观漂亮的文档,但在免费许可下不可用。由于它是闭源产品,因此您控制输出的能力有限。

#5


In general, use CSS print styles + some webpage-to-PDF tool (headless Chrome, Electron, wkhtmltopdf, Prince XML, or just your web browser's print to PDF feature if you don't need to automate it).

通常,使用CSS打印样式+一些网页到PDF工具(无头Chrome,Electron,wkhtmltopdf,Prince XML,或者只是您的网络浏览器的打印到PDF功能,如果您不需要自动化它)。

Specifically for MediaWiki, the ElectronPdfService extension does this for you. (Also, print styles are being rewritten right now; check back in a month or two for improved presentation.)

特别是对于MediaWiki,ElectronPdfService扩展为您完成此操作。 (另外,现在正在重写打印样式;请在一两个月后再回来查看改进的演示文稿。)

#6


<style type="text/css">
    @media print {
        /***css rules for print mode ***/
        aside#sidebar, header[role="banner"], footer, #comments, #respond, #header-v1, .breadcrumbs, #footer-v1,.topbar-v1,.header-v1,.fcbtnremove {
            display: none;
        }

        .container.content-xs {
            width: 98%;
            margin: 0px;
            padding: 0px;
        }
    }

    @media screen {
        /***css rules for screen , it is sometiems opposite of print mode ***/
        #header-v1, .breadcrumbs, #footer-v1,.topbar-v1,.header-v1 {
            display: block;
        }
    }

    table td , table th{text-align:center;vertical-align:middle}
</style>

#1


You may have heard of PediaPress, a company that has done a "wiki to print" (i.e PDF, but also ODF) deal with the Wikimedia Foundation. (See "Wikis Go Printable".) Their code is designed to work with MediaWiki and is open source.

您可能听说过PediaPress,这家公司已经与维基媒体基金会签订了“维基打印”(即PDF,但也包括ODF)。 (参见“Wikis Go Printable”。)他们的代码旨在与MediaWiki一起使用,并且是开源的。

But! It's even better than that. Check out this bookmarklet. You can use it to create PDFs or ODFs of any publicly-accessible MediaWiki page (maybe it needs the API to be enabled too...). And you can bundle multiple pages, from a single MediaWiki or multiple MediaWikis, into a single document. It's pretty freaking awesome in my book. :)

但!它甚至比那更好。看看这个书签。您可以使用它来创建任何可公开访问的MediaWiki页面的PDF或ODF(也许它也需要启用API ...)。您可以将多个页面从单个MediaWiki或多个MediaWikis捆绑到一个文档中。这本书在我的书中非常棒。 :)

ETA: PediaPress have put significant work into making something that looks really nice to read. It's not just the equivalent of MediaWiki's printable version converted to PDF.

ETA:PediaPress已经做了大量的工作来制作看起来非常好看的东西。它不仅仅相当于MediaWiki的可打印版本转换为PDF。

#2


http://www.princexml.com/

could be something for you. It converts xml and html pages to pdf documents.

可能适合你。它将xml和html页面转换为pdf文档。

#3


Using print CSS files is a really slick approach to reformatting pages for printing.

使用打印CSS文件是重新格式化打印页面的一种非常灵活的方法。

A lot of people fall back to PDF because it can be more powerful and easier.

很多人都回归到PDF,因为它可以更强大,更容易。

For most things, though, I think CSS markup is simpler and easier.

但是,对于大多数事情,我认为CSS标记更简单,更容易。

Look at the source for pages in * and you'll see references to media="print" (print.css)--a set of styles applied only when a browser prints the page.

查看*中页面的来源,您将看到对media =“print”(print.css)的引用 - 仅在浏览器打印页面时应用一组样式。

<link href="/Content/print.css" rel="stylesheet" media="print" type="text/css" />

You can use these to hide navbars, ads (or show different ads). Do some basic pagination, etc.

您可以使用这些来隐藏导航栏,广告(或显示不同的广告)。做一些基本的分页等

If you need more control over things like margins, you have to go outside the browser (PDF, Word, XPS, etc.).

如果您需要更多控制边距等内容,则必须在浏览器之外(PDF,Word,XPS等)。

#4


I've written a MediaWiki to LaTeX converter that tries to maintain the document structure of the source text. The document is then typeset with pdflatex to produce a very high quality, paginated document. Math markup is directly rendered by LaTeX, so the equations look great. The LaTeX documentclass / stylesheet is configurable from specialized commands in the wiki to directly control margins, page layout, fonts, extra packages and so on. This would fall in your second category of a custom script rather than a generic framework.

我已经编写了一个MediaWiki到LaTeX转换器,试图维护源文本的文档结构。然后使用pdflatex对文档进行排版,以生成质量非常高的分页文档。数学标记由LaTeX直接渲染,因此方程看起来很棒。 LaTeX文档类/样式表可以通过wiki中的专用命令进行配置,以直接控制边距,页面布局,字体,额外包等。这将属于您的第二类自定义脚本而不是通用框架。

There are many others, such as the Extension:Pdf_Export that uses htmldoc. While it is more general, it does a very poor job of pagination and creates lots of widows and orphans, doesn't do optimal text justification and doesn't do indexes, figures, self-references, etc. Additionally, if you use <math> markup in MediaWiki it only includes the low-res PNG files.

还有很多其他的,例如使用htmldoc的Extension:Pdf_Export。虽然它更通用,但它的分页工作非常糟糕,并且创造了大量的寡妇和孤儿,没有做出最佳的文本证明,也没有做索引,数字,自我引用等。另外,如果你使用 <在mediawiki中的math> markup它只包含低分辨率的PNG文件。

princexml is specialized for MediaWiki and produces good looking documents, but isn't available under a Free license. Since it is a closed-source product, your ability to control the output is limited.

princexml专门用于MediaWiki并生成外观漂亮的文档,但在免费许可下不可用。由于它是闭源产品,因此您控制输出的能力有限。

#5


In general, use CSS print styles + some webpage-to-PDF tool (headless Chrome, Electron, wkhtmltopdf, Prince XML, or just your web browser's print to PDF feature if you don't need to automate it).

通常,使用CSS打印样式+一些网页到PDF工具(无头Chrome,Electron,wkhtmltopdf,Prince XML,或者只是您的网络浏览器的打印到PDF功能,如果您不需要自动化它)。

Specifically for MediaWiki, the ElectronPdfService extension does this for you. (Also, print styles are being rewritten right now; check back in a month or two for improved presentation.)

特别是对于MediaWiki,ElectronPdfService扩展为您完成此操作。 (另外,现在正在重写打印样式;请在一两个月后再回来查看改进的演示文稿。)

#6


<style type="text/css">
    @media print {
        /***css rules for print mode ***/
        aside#sidebar, header[role="banner"], footer, #comments, #respond, #header-v1, .breadcrumbs, #footer-v1,.topbar-v1,.header-v1,.fcbtnremove {
            display: none;
        }

        .container.content-xs {
            width: 98%;
            margin: 0px;
            padding: 0px;
        }
    }

    @media screen {
        /***css rules for screen , it is sometiems opposite of print mode ***/
        #header-v1, .breadcrumbs, #footer-v1,.topbar-v1,.header-v1 {
            display: block;
        }
    }

    table td , table th{text-align:center;vertical-align:middle}
</style>