Set Data in Image and Print in actual size (sample is need)
Set Data in Image and Print in actual size (sample is need)
Hello
I've a worksheet as an image and need set my data into image (Only in memory, no change image putted in hard).
and next, need print the result in actual size.
i have not sample for whatever i needing.
give me a sample please .
Data be number or text, anything. example 1 to 20......
if maybe "Loop" use for set Data in cells.
thank you beforehand.
Attached Image:
http://rapidshare.com/files/261074999/W ... S.rar.html
5Kb
I've a worksheet as an image and need set my data into image (Only in memory, no change image putted in hard).
and next, need print the result in actual size.
i have not sample for whatever i needing.
give me a sample please .
Data be number or text, anything. example 1 to 20......
if maybe "Loop" use for set Data in cells.
thank you beforehand.
Attached Image:
http://rapidshare.com/files/261074999/W ... S.rar.html
5Kb

i try this:
Code: Select all
UseTIFFImageDecoder()
LoadImage(29, "C:\WorkSheetXLS.tif");<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Iw = ImageWidth(29) : Ih = ImageHeight(29);
StartDrawing(ImageOutput(29))
DrawingMode(1);
For x = 40 To Ih-20 Step 20
DrawText(100, x, "Test" + Space(10) + "Test" + Space(10) + "Test" + Space(10) + "Test" + Space(10) + "Test")
Next
StopDrawing()
#Win1=1;
OpenWindow(#Win1, 0, 0, Iw, Ih, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_Invisible);
ImageGadget(100, 0, 0, Iw, Ih, ImageID(29));
HideWindow(#Win1, 0);
Repeat
MyEvWin1 = WaitWindowEvent();
Select MyEvWin1
Case #WM_CLOSE
Exit = 1;
EndSelect
Until Exit = 1;
Oh, have you a pure way?
Please right click on pic and save as "C:\WorkSheetXLS.tif"
This code has followed pic result:
Microsoft Office Document Image Writer

and if i load same pic in MS-Word , i will have result with actual size:
Microsoft Office Document Image Writer

if you please ,help me friends.

Code: Select all
UseTIFFImageDecoder()
LoadImage(29, "C:\WorkSheetXLS.tif");<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Iw = ImageWidth(29) : Ih = ImageHeight(29);
StartDrawing(ImageOutput(29))
DrawingMode(1);
For x = 40 To Ih-20 Step 20
If x = 80 : x=x+3 : EndIf
DrawText(100, x, "Test" + Space(10) + "Test" + Space(10) + "Test" + Space(10) + "Test" + Space(10) + "Test")
Next
StopDrawing()
#Win1=1;
OpenWindow(#Win1, 0, 0, Iw, Ih, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_Invisible);
ImageGadget(100, 0, 0, Iw, Ih, ImageID(29));
HideWindow(#Win1, 0);
Repeat
MyEvWin1 = WaitWindowEvent();
Select MyEvWin1
Case #WM_CLOSE
Exit = 1;
EndSelect
Until Exit = 1;
PrintRequester()
StartPrinting("PureBasic Test")
StartDrawing(PrinterOutput())
DrawImage(ImageID(29), 0, 0, Iw, Ih);
StopDrawing()
StopPrinting()
End
This code has followed pic result:
Microsoft Office Document Image Writer

and if i load same pic in MS-Word , i will have result with actual size:
Microsoft Office Document Image Writer

if you please ,help me friends.

Hi Tomi,
The result is ok.
Why:
Your image has 432 x 508 pixel.
If your printer has a resolution of 600dpi, this results in:
0.72 inch x 0.8467 inch.
If you want a printout as expected (WYSIWIG
), you have to magnify the size of the picture by 8.33..
Explanation:
The computer screen has a defined resolution of 72dpi (should have).
If you want to print this on a 600dpi device you need a magnification by:
600 / 72 = 8.3333....
Best regards,
Bernd
The result is ok.
Why:
Your image has 432 x 508 pixel.
If your printer has a resolution of 600dpi, this results in:
0.72 inch x 0.8467 inch.
If you want a printout as expected (WYSIWIG

Explanation:
The computer screen has a defined resolution of 72dpi (should have).
If you want to print this on a 600dpi device you need a magnification by:
600 / 72 = 8.3333....
Code: Select all
StartDrawing(PrinterOutput())
DrawImage(ImageID(29), 0, 0, Iw * 8.33, Ih * 8.33);
StopDrawing()
Bernd
Hi again,
since different printers use different dpi, you have to find out the actual dpi
to calculate the magnification.
For this you can use the functions
PrinterPageWidth()
PrinterPageHeight()
If you use a fixed papersize, DIN A4 for example, than you can calculate the printer dpi with:
PrinterPageHeight() / 11.7
So the factor is:
PrinterPageHeight() / 11.7 / 72
or
PrinterPageHeight() / 842.4
Bernd
since different printers use different dpi, you have to find out the actual dpi
to calculate the magnification.
For this you can use the functions
PrinterPageWidth()
PrinterPageHeight()
If you use a fixed papersize, DIN A4 for example, than you can calculate the printer dpi with:
PrinterPageHeight() / 11.7
So the factor is:
PrinterPageHeight() / 11.7 / 72
or
PrinterPageHeight() / 842.4
Code: Select all
StartDrawing(PrinterOutput())
Magnification = PrinterPageHeight() / 842.4
DrawImage(ImageID(29), 0, 0, Iw * Magnification, Ih * Magnification);
StopDrawing()
Bernd
Last edited by infratec on Fri Jul 31, 2009 8:40 am, edited 6 times in total.
And also centered:
Bernd
Code: Select all
StartDrawing(PrinterOutput())
Magnification = PrinterPageHeight() / 842.4
DrawImage(ImageID(29), (PrinterPageWidth() - Iw * Magnification) / 2, (PrinterPageHeight() - Ih * Magnification) / 2, Iw * Magnification, Ih * Magnification);
StopDrawing()
Last edited by infratec on Fri Jul 31, 2009 8:40 am, edited 1 time in total.
Ok, i need result in A4 standard paper exactly
i knowledge is poor about printing
when i use:
result was very bad, sorry i think i don't understand your meaning as well.
this:
has near to actual size

i knowledge is poor about printing
when i use:
Code: Select all
DrawImage(ImageID(29), 0, 0, PrinterPageWidth(), PrinterPageHeight() / 11.7 / 72);
this:
Code: Select all
DrawImage(ImageID(29), 0, 0, PrinterPageWidth()/2.5, PrinterPageHeight() / 1.5);

oh ,on until i typing last post, you solve my problem as well.infratec wrote:And also centered:
BerndCode: Select all
StartDrawing(PrinterOutput()) Magnification = PrinterPageHeight() / 842.4 DrawImage(ImageID(0), (PrinterPageWidth() - Iw * Magnification) / 2, (PrinterPageHeight() - Ih * Magnification) / 2, Iw * Magnification, Ih * Magnification); StopDrawing()
Thankful
you have good information about printing.



Hi Tomi,
one last thing:
You need to test the result of StartPrinting().
Else, when someone cancel the printing, you run in trouble.
And:
That was my first thing I ever printed out with a own program.
Bernd
one last thing:
You need to test the result of StartPrinting().
Else, when someone cancel the printing, you run in trouble.
Code: Select all
If MessageRequester("Worksheet", "Do you want to print it?", #PB_MessageRequester_YesNo) = #PB_MessageRequester_Yes
PrintRequester()
If StartPrinting("PureBasic Test")
StartDrawing(PrinterOutput())
Magnification = PrinterPageHeight() / 842.4
DrawImage(ImageID(29), (PrinterPageWidth() - Iw * Magnification) / 2, (PrinterPageHeight() - Ih * Magnification) / 2, Iw * Magnification, Ih * Magnification);
StopDrawing()
StopPrinting()
EndIf
EndIf
That was my first thing I ever printed out with a own program.
Bernd