Extensions :  K-Meleon Forum
All about K-Meleon extensions. 
htm2pdf
Posted by: Rapido
Date: November 16, 2011 09:40PM

Hi! I'm in need of some help! I'm trying to make htm2pdf with a toolbar button and to work similar as this: web2pdf
but i'm not to good with macros. This is how the macros look like:

# ---------- htm2pdf ---------------
# convert webpages or raw html code into PDF documents
# macro by Matt
# http://www.htm2pdf.co.uk/

htm2pdf{
menugrayed=(hostname($URL)=="");
$OpenURL="http://www.htm2pdf.co.uk/?url=".$URL; $ExecMacros="OpenURL_InNew"; &ExecMacros_Frames;
}

htm2pdf2{
menugrayed=(hostname($LinkURL)=="");
$OpenURL="http://www.htm2pdf.co.uk/?url=".$LinkURL; $ExecMacros="OpenURL_InNew"; &ExecMacros_Frames;
}

htm2pdf3{
$htm2pdf = prompt("Enter URL you want convert into PDF:", "Convert webpages into PDF", "http://";);
$htm2pdf == "" ? "" : opentab("http://www.htm2pdf.co.uk/?url="; .$htm2pdf);
}

htm2pdf_BuildMenu{
setmenu("&Edit",macro,"Convert to PDF",htm2pdf,4);
setmenu("Web Document",macro,"Convert to PDF",htm2pdf2);
setmenu("Web Services",macro,"PDF Converter",htm2pdf3);
setmenu("Extra Services",macro,"Save As PDF",htm2pdf);
setmenu("Web Document",macro,"Save As PDF",htm2pdf2);
setmenu(OpenSave,macro,"Save As PDF..",htm2pdf,4);
}

htm2pdf_BuildToolbar{
$htm2pdf_Tooltip=_("Save As PDF");
pluginmsg(toolbars,"AddToolbar","htm2pdf,16,16","");
$htm2pdf=(pluginmsg(toolbars,"AddButton","htm2pdf,htm2pdf,macros("."htm2pdf"."),"." . ".",".$htm2pdf_Tooltip.",16,16,"."htm2pdf.bmp[1],htm2pdf.bmp[0]",""));
}

$OnInit=$OnInit."htm2pdf_BuildMenu;";
# ---------------------------------------------------------------------
$macroModules=$macroModules."htm2pdf;";


And this:

# ----------web dev popup menu-----------------------

wservmenu_BuildMenu{
setmenu(WebServices,popup, "Web Services",);
}

$OnInit=$OnInit."wservmenu_BuildMenu;";
# ---------------------------------------------------------------------------
$macroModules=$macroModules."wservmenumenu;";


And this:

# ----------link popup documents-----------------------

linkdocmenu_BuildMenu{
setmenu(LinkSave,inline,Web_Document);
setmenu(Web_Document,popup, "Web Document");
}

$OnInit=$OnInit."linkdocmenu_BuildMenu;";
# ---------------------------------------------------------------------------
$macroModules=$macroModules."linkdocmenu;";
[/b][/b]

I'ts obviously something wrong since i don't get a toolbar button so please advice. I should say that web2pdf extension doesn't work properly anymore so that is why i'm trying to manipulate this to work similar as that extension.

Yours: Rapido

Options: ReplyQuote
Re: htm2pdf
Posted by: JamesD
Date: November 16, 2011 11:39PM

I think it might be a problem with this line.
$htm2pdf=(pluginmsg(toolbars,"AddButton","htm2pdf,htm2pdf,macros("."htm2pdf"."),"." . ".",".$htm2pdf_Tooltip.",16,16,"."htm2pdf.bmp[1],htm2pdf.bmp[0]",""));

This is some code I just did for a button.
##  create toolbar
$_PClear_ToolbarName = "P_Clear" ;
$_PClear_BSize = "16" ;
$_PClear_LastItem = "" ;
$_PClear_AddBarTag = $_PClear_ToolbarName .",". $_PClear_BSize .",". $_PClear_BSize .",". $_PClear_LastItem ; 
pluginmsg(toolbars, "AddToolbar", $_PClear_AddBarTag);

##  create button
$_PClear_ButtonName = "FlipJS" ;
$_PClear_Command = "macros(_P_Clear_Destroy)" ;
$_PClear_MenuName = "P_Clear List" ;
$_PClear_tipText = "Clear all privacy items \nRight click for menu";
$_PClear_ImageHot = "P_Clear.bmp" ;
$_PClear_ImageCold = "P_Clear.bmp" ;
$_PClear_ImageDead = "P_Clear.bmp" ;
$_PClear_AddButtonTag = $_PClear_ToolbarName.",".$_PClear_ButtonName.",".$_PClear_Command.",".$_PClear_MenuName.",".$_PClear_tipText.",".$_PClear_BSize.",".$_PClear_BSize.",".$_PClear_ImageHot.",".$_PClear_ImageCold.",".$_PClear_ImageDead.",".$_PClear_LastItem ; 
pluginmsg(toolbars, "AddButton", $_PClear_AddButtonTag);
}

Your code seem to set the pluginmsg(toolbars, "AddButton" ... to a variable. In my code I just run that line.

Options: ReplyQuote
Re: htm2pdf
Posted by: Rapido
Date: November 21, 2011 11:02PM

Hi! I've changed a little in the macro and it look like this now:
# ---------- htm2pdf ---------------
# http://www.htm2pdf.co.uk/

htm2pdf{
menugrayed=(hostname($URL)=="");
$OpenURL="http://www.htm2pdf.co.uk/?url=".$URL; $ExecMacros="OpenURL_InNew"; &ExecMacros_Frames;
}

htm2pdf2{
menugrayed=(hostname($LinkURL)=="");
$OpenURL="http://www.htm2pdf.co.uk/?url=".$LinkURL; $ExecMacros="OpenURL_InNew"; &ExecMacros_Frames;
}

htm2pdf_BuildMenu{
setmenu("Extra Services",macro,"Save As PDF",htm2pdf);
setmenu("Web Document",macro,"Save As PDF",htm2pdf2);
setmenu(OpenSave,macro,"Save As PDF..",htm2pdf,4);
}

htm2pdf_BuildToolbar{
$htm2pdf_Tooltip=_("Save As PDF");
pluginmsg(toolbars,"AddToolbar","htm2pdf,16,16","");
$htm2pdf=(pluginmsg(toolbars,"AddButton","htm2pdf,htm2pdf,macros("."htm2pdf"."),"." . ".",".$htm2pdf_Tooltip.",16,16,"."htm2pdf.bmp[1],htm2pdf.bmp[0]",""));
}

$OnInit=$OnInit."htm2pdf_BuildMenu;";
$OnSetup=$OnSetup."htm2pdf_BuildToolbar;";
# ---------------------------------------------------------------------
$macroModules=$macroModules."htm2pdf;";


But there seeme to be some issues that i can't solve.
1: when i point at the icon it does not show: Save as PDF 2: Instead of getting to homepage it just loading and loading and nothing happens.
So could someone tell me what do do or point me in the right direction?

Yours: Rapido

Options: ReplyQuote
Re: htm2pdf
Posted by: JamesD
Date: November 22, 2011 06:28AM

It loaded for me but it took a very long time. The button is calling the macro "htm2pdf" which opens the URL. Did you want it do something else?



Edited 1 time(s). Last edit at 11/22/2011 06:33AM by JamesD.

Options: ReplyQuote
Re: htm2pdf
Posted by: JamesD
Date: November 22, 2011 10:02PM

@ Rapido

Can you attach the bmp for the button? I will do some more testing. Before I just clicked on the space for the button and after a long while I got the page. It contained a box which showed my homepage and button to download the PDF file. I am assuming that is what it is supposed to do.

Options: ReplyQuote
Re: htm2pdf
Posted by: Rapido
Date: November 23, 2011 10:17PM

Her is the bmp. It won't open for me and i'm running km1.5.4 and 1.6. I should tell you that I was using the web2pdf before and it just won't open url correctly anymore with km1.5 and 1.6 with useragent seamonkey2.1 and ff3.6 and above and it's the same with htm2pdf so it seems that something has changed but i don't know what. That is why i started to do this manipulating to find out if i could figure out what the problem was. I also attached the errrormessage i get when i'm trying to convert this page: Walkthrough
to pdf and i get a similar errormessage when i'm using htm2pdf.

Yours: Rapido
P.S. i should say that i'm running under WinXP
D.S.



Edited 3 time(s). Last edit at 11/23/2011 10:42PM by Rapido.

Attachments: htm2pdf.bmp (1.6 KB)   web2pdfconverter error.bmp (96.3 KB)  
Options: ReplyQuote
Re: htm2pdf
Posted by: JamesD
Date: November 23, 2011 11:52PM

I got the bmp installed and tried the htm2pdf. Fairly long time to display the page, but when it did I had the small image of the PDF. I clicked the download pdf button and got the attached file.

Length of time for the page could be just because I am in USA and site is in UK.

Could the error that you get be only for the page that you are trying to convert? I am sure you have tried other pages.

Edit: bigfishgames.com is the problem. The page never finishes loading.



Edited 1 time(s). Last edit at 11/23/2011 11:58PM by JamesD.

Attachments: 35569ca2-2f92-44b6-aa30-8f7bac7570ce.pdf (105.6 KB)  
Options: ReplyQuote


K-Meleon forum is powered by Phorum.