Extensions :  K-Meleon Forum
All about K-Meleon extensions. 
Print to file for review - Print Preview work a round
Posted by: JamesD
Date: December 05, 2016 04:40AM

Update 1

Included is new attachment, pfrv_13.7z. I hope this works better than the original.

items: Filename is automatic, file extension is automatic.
The temp file is deleted when the viewing window is closed.
A portable SumatraPDF still required. See below

I have made a small work-a-round for Print Preview. Since version 74 or 75 Print Preview has not worked in K-Meleon.


Reference http://kmeleonbrowser.org/forum/read.php?1,138874

The attached file is not all a user must have for this to work. One needs a portable SumatraPDF. It should be placed in the KMroot\browser\plugins folder.

I was able to obtain this one from the author's site.
Zip file: SumatraPDF-3.1.1.zip
From: http://www.sumatrapdfreader.org/download-prev.html

This is a work in progress. Suggestions and comments are welcome.

Note there is a 2 second delay before the preview window appears. This is to allow the file to be written to disk before being called for display. You may need to increase this for your system. Change the value 2 in
settimer(_pfrv_printfilereview2, 2);
in line 25 of the macro.



Edited 1 time(s). Last edit at 12/16/2016 03:21AM by JamesD.

Attachments: pfrv_13.7z (47.5 KB)  
Options: ReplyQuote
Re: Print to file for review - Print Preview work a round
Posted by: rodocop
Date: December 05, 2016 08:20AM

Well, being precise SumatraPDF.exe should be in the same folder as np-plugin is placed.
Whether it's rootfolder/plugins or rootfolder/browser/plugins.

I wrote this as general note about using SumatraPDF portable with K-Meleon.


Latest Release KM75.1 Latest dev KM76RC ||| Visit The K-Meleon Place and join me there!
Old good stuff: KM-1.6db+NS © dugbugoffice // KM-16-S2014 © Fred // KM-1.6beta2.6 © JamesD // KM Twin+ © rodocop // KM 1.8.24.22 © adodupan

RECOMMENDED! K-Meleon 76 Pro ==» Download portable: 7zip or EXE =//= Discuss on forum
K-Meleon 75.1 Pro: Download =//= Discuss || Portable Flash plugin (x86/x64 DLLs)

Options: ReplyQuote
Re: Print to file for review - Print Preview work a round
Posted by: JujuLand
Date: December 06, 2016 05:52PM

Hi,

I tried to bypass a bug concerning 'Print in a file' function, where the pdf is created, but empty, hoping it solves it.

Unfortunatelly, the problem is always here sad smiley

I don't know if it's a wine problem or a cups problem ...

The pdf is created but empty (3 empty pages for my test), exactly the same with or without your macro ... which returns that the file doesn't exists, what is false.

A+


Mozilla/5.0 (x11; U; Linux x86_64; fr-FR; rv:38.0) Gecko/20100101 Ubuntu/12.04 K-Meleon/76.0

Web: http://jujuland.pagesperso-orange.fr/
Mail : alain [dot] aupeix [at] wanadoo [dot] fr


Ubuntu 12.04 - Gramps 3.4.9 - Harbour 3.2.0 - Hwgui 2.20-3 - K-Meleon 76.0 rc



Options: ReplyQuote
Re: Print to file for review - Print Preview work a round
Posted by: JamesD
Date: December 07, 2016 01:51AM

Quote
JujuLand
The pdf is created but empty (3 empty pages for my test), exactly the same with or without your macro ... which returns that the file doesn't exists, what is false.

Alain, do you have printer drivers for PDF and/or XPF? My macro calls the same command ID as the print item in the KM file menu.

If you use File > Print and select a PDF driver as the printer, do you get a file with the current page's image?

Not at all sure about what is available under wine. Maybe PDF999 ?

Options: ReplyQuote
Re: Print to file for review - Print Preview work a round
Posted by: JohnHell
Date: December 07, 2016 02:52AM

Quote
JamesD
Quote
JujuLand
The pdf is created but empty (3 empty pages for my test), exactly the same with or without your macro ... which returns that the file doesn't exists, what is false.

Alain, do you have printer drivers for PDF and/or XPF? My macro calls the same command ID as the print item in the KM file menu.

If you use File > Print and select a PDF driver as the printer, do you get a file with the current page's image?

Not at all sure about what is available under wine. Maybe PDF999 ?



About that there is a problem.

Maybe thinking that Wine behaves similar to Windows 2000 (and probably XP, but I haven't tested that), when you print to file, you can set the path, not only the filename. If you set the file name, the file should be placed in the root of the program which called the print command, but it might depend in the run in/run from folder -I don't know how is called in english- (in other words, the path).

Said that, and having that in mind, the macro isn't set for a custom path, but for a set path ($_pfrv_path for the profile dir) which, in turn, if an user sets another filepath, the macro won't find the file.

The path might be hardcoded without user option (it is a preview, so, why care), but, if done, you need to know to pass a command to the printer spool (so you shouldn't be using ID_FILE_PRINT then), but you need to know which commands to use (that I don't have a clue myself).

Also, when printing to file with a printer driver, at least with PDF995, the file isn't a PDF, but a PS (PostScript), that, actually, it is almost a PDF, but not a PDF, and won't be opened by some readers. To convert that PS to PDF, you'll need Ghostscript (PDF995 uses it).

There are a few things to solve. But don't ask me, I don't have a clue how. I just recommended to print to PDF installing a PDF printer driver. Automate it escapes beyond me.



Options: ReplyQuote
Re: Print to file for review - Print Preview work a round
Posted by: JamesD
Date: December 07, 2016 07:59PM

Quote
JohnHell
If you set the file name, the file should be placed in the root of the program which called the print command, but it might depend in the run in/run from folder -I don't know how is called in english- (in other words, the path).

I used a path set to the user's profile because that is certain to have write authority and KM needs to know where to find the file in order to load it.

The CNTL + V paste is supposed to contain the full path to the file. That should override anything in the print dialog, I thought.

I don't have any operating systems other than Win 10, on which I can test the macro.

Options: ReplyQuote
Re: Print to file for review - Print Preview work a round
Posted by: JohnHell
Date: December 07, 2016 11:45PM

Quote
JamesD

The CNTL + V paste is supposed to contain the full path to the file. That should override anything in the print dialog, I thought.

Oh, true, you are right, in the warning is told.

Maybe is me who behave differently grinning smiley



Options: ReplyQuote
Re: Print to file for review - Print Preview work a round
Posted by: JujuLand
Date: December 08, 2016 11:43PM

Hi all,

The problem I have to keep an empty pdf was already here, previously using the macro. I signaled it here there is a few month.

And it's my principal problem. The curious thing is that when opening the pdf, it seems to have has the good number of pages.

One thing I haven't tried is to open it in Acrobat. I remember a problem I had with posterazor, where the image was set as background, and the printer dooesn't print it. But I don't think it's the same reason, I'll try it ...

After, concerning the fact that the file which was created (in the user folder) isn't found is probably due to the path \ instead of /, and so on ...

A+


Mozilla/5.0 (x11; U; Linux x86_64; fr-FR; rv:38.0) Gecko/20100101 Ubuntu/12.04 K-Meleon/76.0

Web: http://jujuland.pagesperso-orange.fr/
Mail : alain [dot] aupeix [at] wanadoo [dot] fr


Ubuntu 12.04 - Gramps 3.4.9 - Harbour 3.2.0 - Hwgui 2.20-3 - K-Meleon 76.0 rc



Options: ReplyQuote
Re: Print to file for review - Print Preview work a round
Posted by: JamesD
Date: December 09, 2016 01:13AM

Quote
JujuLand
After, concerning the fact that the file which was created (in the user folder) isn't found is probably due to the path \ instead of /, and so on ...

Not sure about how things work under wine, but I changed a line of code in the macro for test and Windows says it is not correct for a filename.

$_pfrv_filespec = $_pfrv_path ."\\" . $_pfrv_file ; works.

$_pfrv_filespec = $_pfrv_path ."//" . $_pfrv_file ; does not work.

All other backslashes provided by KM.

URLBAR when KM is displaying the output file.
file:///C:/KM_pgms/K-Meleon76RC2/Profiles/fdfoh56r.default/ext_pfrv.oxps

The file as shown in KM history.
/C:/KM_pgms/K-Meleon76RC2/Profiles/fdfoh56r.default/ext_pfrv.oxps

The path to my profile. ( in file manager )
C:\KM_pgms\K-Meleon76RC2\Profiles\fdfoh56r.default

It is confusing to me that some slant one way some slant the other way.

Options: ReplyQuote
Re: Print to file for review - Print Preview work a round
Posted by: rodocop
Date: December 09, 2016 09:46PM

James,
your files created are OXPS, and my - XPS. May this be the reason?


Latest Release KM75.1 Latest dev KM76RC ||| Visit The K-Meleon Place and join me there!
Old good stuff: KM-1.6db+NS © dugbugoffice // KM-16-S2014 © Fred // KM-1.6beta2.6 © JamesD // KM Twin+ © rodocop // KM 1.8.24.22 © adodupan

RECOMMENDED! K-Meleon 76 Pro ==» Download portable: 7zip or EXE =//= Discuss on forum
K-Meleon 75.1 Pro: Download =//= Discuss || Portable Flash plugin (x86/x64 DLLs)

Options: ReplyQuote
Re: Print to file for review - Print Preview work a round
Posted by: JujuLand
Date: December 09, 2016 11:43PM

Well, I haven't correctly explain the problem with path separators.

To search or open a file, K-Meleon uses windows way, and it's normal
For example, user profile under Windows is located under C:\... (I don't remember the path), which is, under Linux: Z:\home
And it's why I created km_open, and set a linux specific mimetypes.rdf

km-open adapts linux pathes to windows pathes to allow k-meleon to open files.

Your macro isn't able to find and open the pdf files because of this reason unde Linux.
It can probable be corrected, but I have not too much time now to do it, and in fact till we haven't found the reason why pdf files are empty, there is no reason to search for this path problem.

A+


Mozilla/5.0 (x11; U; Linux x86_64; fr-FR; rv:38.0) Gecko/20100101 Ubuntu/12.04 K-Meleon/76.0

Web: http://jujuland.pagesperso-orange.fr/
Mail : alain [dot] aupeix [at] wanadoo [dot] fr


Ubuntu 12.04 - Gramps 3.4.9 - Harbour 3.2.0 - Hwgui 2.20-3 - K-Meleon 76.0 rc



Options: ReplyQuote
Re: Print to file for review - Print Preview work a round
Posted by: JamesD
Date: December 10, 2016 02:22AM

Quote
rodocop
James,
your files created are OXPS, and my - XPS. May this be the reason?

WOW! Yes, I think so. I had the problem in reverse during testing. I was just keeping the pdf or xps as the displayed item for the user and never could find xps because my version makes the file extension oxps. The version in your system for xps writer must be different from mine.

Try changing the "oxps" to "xps" in line 16 of my macro.

Options: ReplyQuote
Re: Print to file for review - Print Preview work a round
Posted by: rodocop
Date: December 10, 2016 02:32AM

well, now it works even for PDFs!!! (XPS sure too)


Latest Release KM75.1 Latest dev KM76RC ||| Visit The K-Meleon Place and join me there!
Old good stuff: KM-1.6db+NS © dugbugoffice // KM-16-S2014 © Fred // KM-1.6beta2.6 © JamesD // KM Twin+ © rodocop // KM 1.8.24.22 © adodupan

RECOMMENDED! K-Meleon 76 Pro ==» Download portable: 7zip or EXE =//= Discuss on forum
K-Meleon 75.1 Pro: Download =//= Discuss || Portable Flash plugin (x86/x64 DLLs)

Options: ReplyQuote
Re: Print to file for review - Print Preview work a round
Posted by: JamesD
Date: December 10, 2016 02:33AM

Quote
JujuLand
Your macro isn't able to find and open the pdf files because of this reason unde Linux.
It can probable be corrected, but I have not too much time now to do it, and in fact till we haven't found the reason why pdf files are empty, there is no reason to search for this path problem.

Since I don't know how exactly a printer driver works, I am not sure that can be of much help.

When using a driver for PDF without my macro, if the file is created but no data is written there, could the printer driver fall victim to the same problem? If the driver correctly makes the file, but writes the data someplace that does not exist, equates to current situation?

Options: ReplyQuote
Re: Print to file for review - Print Preview work a round
Posted by: rodocop
Date: December 10, 2016 02:34AM

and even with default (2s) delay!


Latest Release KM75.1 Latest dev KM76RC ||| Visit The K-Meleon Place and join me there!
Old good stuff: KM-1.6db+NS © dugbugoffice // KM-16-S2014 © Fred // KM-1.6beta2.6 © JamesD // KM Twin+ © rodocop // KM 1.8.24.22 © adodupan

RECOMMENDED! K-Meleon 76 Pro ==» Download portable: 7zip or EXE =//= Discuss on forum
K-Meleon 75.1 Pro: Download =//= Discuss || Portable Flash plugin (x86/x64 DLLs)

Options: ReplyQuote
Re: Print to file for review - Print Preview work a round
Posted by: JamesD
Date: December 10, 2016 05:23AM

I was hoping not to have to include a lot of text strings explaining to user that they might have to print files using driver. Then input the extension(s) to be held in a pref(s) so the macro would know what file to load for review.

I am going to have to rethink that now, or go another direction.

Options: ReplyQuote
Re: Print to file for review - Print Preview work a round
Posted by: JujuLand
Date: December 10, 2016 03:13PM

Testing the empty pdf with Acrobat fails with this message:

Adobe Reader can't open test.pdf, because the filetype isn't known or the file is damaged.

When I open the pdf with an hex editor, I say the header :

%!PS-Adobe-3.0%%Creator: Wine PostScript Driver.%Title: ...."

The wine driver then calls cups which is the print manager of Linux.
As I have no problem with cups, I suppose the problem is near the wine PostScript driver.

As my wine version is old, due to my Ubuntu version, I will try with a more recent version of Ubuntu (Xubuntu exactly) and then a newer wine version.

A+


Mozilla/5.0 (x11; U; Linux x86_64; fr-FR; rv:38.0) Gecko/20100101 Ubuntu/12.04 K-Meleon/76.0

Web: http://jujuland.pagesperso-orange.fr/
Mail : alain [dot] aupeix [at] wanadoo [dot] fr


Ubuntu 12.04 - Gramps 3.4.9 - Harbour 3.2.0 - Hwgui 2.20-3 - K-Meleon 76.0 rc



Options: ReplyQuote
Re: Print to file for review - Print Preview workaround
Posted by: siria
Date: December 10, 2016 06:23PM

There are also plenty of print-prefs, and that's not even all yet:
http://kb.mozillazine.org/About:config_entries#Print.
Linux with PS and cups have own prefs too, which you probably have long since already, but just in case may check in 76 profile again.
Have yesterday finally reactivated that vista thing again to experiment a bit with all those prefs (win prefs of course), but no luck either.

Options: ReplyQuote
Re: Print to file for review - Print Preview workaround
Posted by: JujuLand
Date: December 10, 2016 10:55PM

Hi,

The test under Xubuntu 16.04 with wine 1.6.2 works

So, I just have to locate the files which are used and try to replace it.

No sure it will works.

The header of the pdf is now:
%!PS-Adobe-3.0
%cupsJobTicket: media=A4
%cupsJobTicket: sides=one-sided
%%Creator: Wine PostScript Driver
%%Title: K-Mel....

A+


Mozilla/5.0 (x11; U; Linux x86_64; fr-FR; rv:38.0) Gecko/20100101 Ubuntu/12.04 K-Meleon/76.0

Web: http://jujuland.pagesperso-orange.fr/
Mail : alain [dot] aupeix [at] wanadoo [dot] fr


Ubuntu 12.04 - Gramps 3.4.9 - Harbour 3.2.0 - Hwgui 2.20-3 - K-Meleon 76.0 rc



Options: ReplyQuote
Re: Print to file for review - Print Preview workaround
Posted by: JohnHell
Date: December 11, 2016 02:10AM

That should be because it happens what I said about some PDF printer drivers (if not all) output a PostScript (PS Adobe 3) when printing to file.

GhostScript has the ability with a simple batch file to convert ps2pdf (ps2pdf.bat under windows).



Options: ReplyQuote
Re: Print to file for review - Print Preview workaround
Posted by: JujuLand
Date: December 11, 2016 10:52PM

Hi,

I have tried some things:

1) _pfrv_GetPath{}:
_pfrv_GetPath {
   if($tux=="")
   {
      $_pfrv_path = getfolder( ProfileFolder );
   }
   else
   {
      $_user=readreg("HKCU","Environment\\TEMP");
      $_user=gsub("\\","",$_user);
      $_user=sub("C:users","",$_user);
      $_user=sub("Temp","",$_user)
      $_pfrv_path ="Z:\\home\\".$_user."\\.wine\\drive_c\\users\\".$_user."\\Temp";
   }
}
This force the default target path to temp user path

2) in _pfrv_printfilereview{}, modified the build of _pfrv_filespec, automatically adding the extension (so no more need to add extension)
$_pfrv_filespec = $_pfrv_path ."\\" . $_pfrv_file . "." . $_pfrv_filetype;
so _pfrv_printfilereview2{} is now modified like this:
fileexists( $_pfrv_filespec ) ? opennew( $_pfrv_filespec ): alert("File not found");

But, if the file is now found, I have a problem using sumatraPDF to look it in a new window, because, as we are trying to open the file with a browser, SumatraPDF creates a tmp file and even the temp file is created, says he doesn't find it.
3017055 -rw-rw-r--  1 alain alain 178949 déc.  11 16:43 nPV64e3.tmp
3014714 -rw-rw-r--  1 alain alain 178949 déc.  11 16:42 toto.pdf

Error Loading C:\users\alain\nPV64e3.tmp

If I change the values in file type to use km-open which ought to open it with the default linux pdf reader, it doesn't work anymore ...

Another ennoying problem: if I change the mimetype value of pdf filetype, from plugin to km-open, the entry in mimetypes.rdf isn't anymore in mimetypes.rdf, and I must reintroduce it manually out of K-meleon ...


A+


Mozilla/5.0 (x11; U; Linux x86_64; fr-FR; rv:38.0) Gecko/20100101 Ubuntu/12.04 K-Meleon/76.0

Web: http://jujuland.pagesperso-orange.fr/
Mail : alain [dot] aupeix [at] wanadoo [dot] fr


Ubuntu 12.04 - Gramps 3.4.9 - Harbour 3.2.0 - Hwgui 2.20-3 - K-Meleon 76.0 rc




Edited 2 time(s). Last edit at 12/11/2016 10:59PM by JujuLand.

Options: ReplyQuote
Re: Print to file for review - Print Preview workaround
Posted by: siria
Date: December 11, 2016 11:19PM

In some of my older macros I had to add "file:///" to a path or KM wouldn't open it. Guess have already mentioned it in the other thread, but no idea if anyone tried it yet. And for testing the "fileexist" could be dropped if the macro warning shows up.
opentab("file:///".$_pfrv_filespec);

Options: ReplyQuote
Re: Print to file for review - Print Preview workaround
Posted by: JamesD
Date: December 14, 2016 03:22AM

Would it help if I put into setup a way for the user to create the filetype and save that in a pref? It could be pdf, xps, oxps, or whatever the output is from the user's print driver as long as SumatraPDF or any other PDF reader software installed will be used from within KM.

I had no idea how complex this could be when I began working on my work-a-round.

Options: ReplyQuote
Re: Print to file for review - Print Preview workaround
Posted by: JamesD
Date: December 15, 2016 05:19AM

I have made another attempt to get the print preview macro to work a little better for users other than myself.

Only the macro is in this attachment.

JujuLand

I don't know enough about tux to use it much. If I can make a change that will help your situation, just let me know.

Attachments: pfrv.kmm (1.9 KB)  
Options: ReplyQuote
Re: Print to file for review - Print Preview workaround
Posted by: JamesD
Date: December 16, 2016 05:10AM
Options: ReplyQuote
Re: Print to file for review - Print Preview workaround
Posted by: JujuLand
Date: December 16, 2016 03:39PM

Hi,
Quote
siria
opentab("file:///".$_pfrv_filespec);

I tried it, and I think it must be like this, but the problem is not here.
K-Meleon which is a windows program uses windows style path, and, if I want to use a linux program to see pdf I must transform windows path to linux path.

I had a program which calls the linux program with linux path, and I must call it (km-open) to be able to use it. For now it doesn't work.

Another problem, if I change the param of mimetype to open with the plugin, I'm no more able to revert to km-open.exe, as the record has been deleted from mimetypes.rdf.

Well, for now, I'm too much busy, and I'm not able to finish quickly...

Thanks
A+


Mozilla/5.0 (x11; U; Linux x86_64; fr-FR; rv:38.0) Gecko/20100101 Ubuntu/12.04 K-Meleon/76.0

Web: http://jujuland.pagesperso-orange.fr/
Mail : alain [dot] aupeix [at] wanadoo [dot] fr


Ubuntu 12.04 - Gramps 3.4.9 - Harbour 3.2.0 - Hwgui 2.20-3 - K-Meleon 76.0 rc



Options: ReplyQuote
Re: Print to file for review - Print Preview workaround
Posted by: JamesD
Date: December 16, 2016 07:37PM

Quote
JujuLand
K-Meleon which is a windows program uses windows style path, and, if I want to use a linux program to see pdf I must transform windows path to linux path.

Yes, paths can be a problem. In the most recent version, I have the created file deleted when the user closes the window. It drove me crazy that I couldn't make that work until I saw that the URL and path were equal except that the slashes are forward one place and backward in the other. And that is without Linux involvment.

Options: ReplyQuote


K-Meleon forum is powered by Phorum.