开发者

Converting CHM file to another format [closed]

开发者 https://www.devze.com 2022-12-15 12:26 出处:网络
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.

Closed 3 years ago.

Improve this question

I need to convert a chm file to another format, most likely pdf or html. I have tried chm2pdf and other converters but they all do horrific jobs at conversion. Even using a program like htmldoc doesn't do a very good job at converting to html.

Is there a way to just print each page of the chm file or taking a image of it and then saving that image to the pdf or other format.

The main reason for this is that chm books are filled with code and conversion to开发者_开发问答ols don't format anything correctly.


I'm afraid that will be a multi-step procedure...

  1. Extract the pages from the CHM file, e.g. using arCHMage.
  2. Use wkhtmltopdf on each page.
  3. Use something like pdfjoin (from pdfjam) to tape the documents together.

This complements the answer recommending a virtual to-PDF printer in that it's the more linuxy command line solution (all of the tools mentioned are available in Debian's and Ubuntu's package repository). Pick your poison. ;)


Install something like Primo PDF which installs a virtual printer and spits out a PDF file. Afterwards, print out the book chapter by chapter (as described here - http://www.helixoft.com/vsdocman-faqs/printing-chm-documentation.html)


If you just need to read it on linux, xchm (http://xchm.sourceforge.net/) provides decent native support for viewing .chm files.


The problem is that the windows CHM viewer is basically MSIE (Internet Explorer). The exact rendering is probably version dependant. (and for the average file you'd probably want MSIE 6)

In other words to get a faithful reproduction is to use some extracter (I use the one from CHMLIB or, lately, Free Pascal/Lazarus) to decompress the CHM (which is just an html archive with additional indexes), and fire up MSIE for each page, and instrumenting it to write to e.g. a virtual PDF writer.

This way you have some chance to really capture it the way IE renders it. (and hope it doesn't render differently to printer than to screen).

The TOC is in XML form in the .hhc files, and you could transform one of them to the PDF bookmarks treeview.

If you somehow get the number of "pages" back from IE, you could probably even transform the index files to something you could add to the PDF, since you could make out on which page every topic is. But that is for the advanced class :-)


This worked for me:

https://cloudconvert.com/chm-to-pdf

There is also a REST API:

The CloudConvert REST API offers you great possibilites to convert files in the same way as you can do on the CloudConvert website.

If there is not enough white space at the borders, you can print it again as pdf and resize it to e.g. 80%.


To convert chm to pdf, you can try these steps.

1) click Print
2) select print the selected heading and all subtopics then press ok
3) while the print prompt is still shown, go to your TEMP folder (usually c:\Documents and Settings\USERNAME\Local Settings\Temp ), and find the latest file "~hhSOMETEXT.htm"
4) open the .htm file with internet explorer and print to PDF

to remove the prev and next buttons, you may want to set a style such as img{display:none!important;}

0

精彩评论

暂无评论...
验证码 换一张
取 消