wxHtmlEasyPrinting, An issue, or invalid usage?

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
wxTNewb
Knows some wx things
Knows some wx things
Posts: 28
Joined: Tue Sep 04, 2007 3:57 pm

wxHtmlEasyPrinting, An issue, or invalid usage?

Post by wxTNewb »

Using wxMSW on Visual C 2008.

I've been trying to enable printing on an application, and it's been going rather awry.

I went from attempting to use wxHtmlEasyPrinting, and then through all kinds of other classes covered in the printing overview documentation, all with bad results...

Will start at the beginning.
The code to execute printing was as follows:

Code: Select all

Printer.PreviewFile(wxT("Test.html"));
And the contents of the file are:

Code: Select all


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
  <title>Label</title>
</head>
<body>
<img style="width: 320px; height: 60px;" alt="Picture?"
 src="Test.jpg">
</body>
</html>
The file Test.jpg IS the size specified in the style.

However, print-preview (And print) claim that the algorithm fails to calculate page count and gives up at 1000 pages.

Related to that problem is my second question, How do I set the paper type when it isn't on the list for wxPaperSize ? I am trying to save the settings set by the user...

The printer in question is a Brother QL-570, which is incapable of standard paper sizes, and has a big list of other paper sizes. The paper size I'm using is 27mm x 89mm, with 300 DPI is more then enough to print the requested image... I've tried printing with more manual means in wxPrintout, but even though it works, the printout becomes incredibly fuzzy and unreadable. =(
Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria »

About HTMl : are you able to view the same HTML document in a HTML control (without printing) ? The thing is, wxWidgets' HTML control is quite poor, so it may just be a limitation there. I especially very much doubt it supports CSS; you'd need to use wxWebKit for this
"Keyboard not detected. Press F1 to continue"
-- Windows
JoeB
In need of some credit
In need of some credit
Posts: 6
Joined: Wed Jun 03, 2009 3:33 pm
Location: Tucson, AZ
Contact:

Easy print problem

Post by JoeB »

Hello
We're having the same problem when trying to print a graphic. Ive tried various file formats, all had the same problem. Then we set the width and height parms to a pixel size (not percent) that would fit on the actual preview display, even below any header in the html document.

This worked for a while, and on most PCs. Then one day I did some kind of printing on my machine, and now it's broken again. It keeps on trying to print out countless pages.

I'm now trying to print images by drawing them directly on the wxDC. I no longer have the page issue, bow Im having scale issues where my drawing on my panel is different than on the paper. I've tried the scalaing and maping methods, but not just "right".

Another issue, easyHTML worked good to go from portrait to landscape, but the printout method only goes to landscape after the first print request. This even happens with the sample code I got from the website.

Any Clues?

Otherwise, wxWidgets has been great. we use it for our new machine and I can provide user interfaces in both winders and Linux with very few changes. Most actual GUI files need no change at all!

Thank you.
wxTNewb
Knows some wx things
Knows some wx things
Posts: 28
Joined: Tue Sep 04, 2007 3:57 pm

Post by wxTNewb »

Auria wrote:About HTMl : are you able to view the same HTML document in a HTML control (without printing) ? The thing is, wxWidgets' HTML control is quite poor, so it may just be a limitation there. I especially very much doubt it supports CSS; you'd need to use wxWebKit for this
I am quite able to print the same HTML to a HTML control... via a wxHtmlWindow in a wxPanel/wxNotebook. There is no CSS used, just one image. And an odd printer... For some reason, using wxPrintout works partially, but the clarity of the printed image is too fuzzy to do anything with. (Loading the image in a web browser and printing is fine).

The COMPLETE html page I am trying to print is in the code block. There's nothing there but one image. Basically I was looking for an easy way to quickly print a generated image.

... By the way, I figure there's a 99% chance the answer is no, but just in case I'll throw this out ...
Is there any interest by anyone for me to release the wxBarcode class I'm using?
It's a pretty simple class based on work done by others...

Code: Select all

BOOL wxBarCode::Encode(const wxChar *pszCodeIn);
void wxBarCode::DrawBarcode(wxDC& hDC,wxRect Position, const wxColour clrBar,const wxColour clrSpace,const int iPenW);
wxTNewb
Knows some wx things
Knows some wx things
Posts: 28
Joined: Tue Sep 04, 2007 3:57 pm

Re: Easy print problem

Post by wxTNewb »

JoeB wrote: Another issue, easyHTML worked good to go from portrait to landscape, but the printout method only goes to landscape after the first print request. This even happens with the sample code I got from the website.
That might be of some interest to my problem... The printed materials in question are done landscape.

Of course, the page size is roughly 3/4 inch by 3 inch, so it almost has to be done landscape!
JoeB
In need of some credit
In need of some credit
Posts: 6
Joined: Wed Jun 03, 2009 3:33 pm
Location: Tucson, AZ
Contact:

HTMLEasyPrint - Found my problem

Post by JoeB »

Hello -

As I suspected, the height and width parameters did not apply to the size of the original image I was trying to print (the jpg file), rather the "real estate" on the final printout, be that the preview or the actual printed paper. So when I had height='100%', for the image, there wasn't enough room. I did not specify height for the header, though it obviously did take some percentage of the height of the final printout, as did the footer. So after the header took it's percent, and the footer, it's share, there wasn't 100% of the height left for the body!

The size includes space taken by the header and footer. The sizes aren't precise either, just suggestions.

My solution was to SetHeader with something that included width='100%' height='10%'

Then SetFooter with something similar like width='100%' height='10%'

Since both the header and footer together use 20% of the height of the final printout, the body image could not use more than 80% --- <img src='xyz.jpg' width='100%' height='80%' />

Because I didn't have any column stuff, the width of 100% worked. Also, not knowing the "true" pixel dimensions of the printed paper, the % stuff worked.

The % stuff alone, did clip some of the right edge of the image until I got a hold of the page setup stuff and set the margins to something small. This did however require a size other than %, but it appears to be set in mm.

Good luck, hope that works for you too.
Post Reply