LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   PDF preview for Tcl/Tk (https://www.linuxquestions.org/questions/programming-9/pdf-preview-for-tcl-tk-4175463174/)

jlinkels 05-23-2013 11:06 AM

PDF preview for Tcl/Tk
 
I need a preview pane for PDF files in a Tcl/Tk application, but it seems I cannot find one.

I have found a DVI viewer, and PDF generation tools, but not a PDF viewer. Apparently the wrong way of Googling?

Bottom line I could start an external application to convert PDF -> JPG and display those images but I try to avoid that.

Note it is just for viewing, strictly read-only.

jlinkels

business_kid 05-23-2013 11:53 AM

gs?

Janus_Hyperion 05-23-2013 12:02 PM

Ghostscript viewer may be?

jlinkels 05-24-2013 11:23 AM

Mentioning Ghostscript did help for defining better keys for Google. As it seems, the preferred way is to convert the PDF to an image which can be shown on a canvas. I had hoped this could be done without temporary files etc.

Thanks all.

jlinkels

Guttorm 05-24-2013 11:33 AM

Hi

I don't know tcl/tk at all, but if you can use regular libraries, you should check out libpoppler.

http://en.wikipedia.org/wiki/Poppler_%28software%29

Edit:
If it's a problem, you could also try pdftoppm from poppler-utils and pipe the result to some other viewer. Just turn of all compression, and it could be fast enough.

jlinkels 05-24-2013 09:30 PM

Tcl/Tk is a scripting language. When a function like viewing PDF's has to be implemented, one would write it in C and make the call available in Tcl. Tk is just the graphical framework.

When one would write the functions in C, libpoppler could have been used.

Unfortunately no-one had found the need to write this function. Maybe understandable as Tcl is considered old and outdated.

Although I don't even consider to write such functions your information is useful, thanks.

jlinkels

jlinkels 08-29-2019 05:33 PM

I am necroposting in my own thread :D

It seems that finally an exact match to my requirements has been published. But only in 2016, so back in 2013 when I asked the question it was not there yet. It the mean time I had my application working with external conversion of PDF through GS into multiple JPG files which were all converted to Tk images. Very messy and slow, but it worked.

The correct solution is this:
https://wiki.tcl-lang.org/page/tclMuPdf

A Tcl/Tk interface to the muPDF package.

I did some quick rudimentary tests, and it seems to work very fast. Also the option to convert a PDF to pages and the pages into images, directly in Tcl/Tk is very elegant.

Since I am now developing another application it might take some time before I can actually rewrite my original application using the tclMuPDF package.

Comments from others who use it are appreciated.

jlinkels


All times are GMT -5. The time now is 03:16 PM.