HPDFPRINT IMAGE Image cannot be loaded

Moderator: Rathinagiri

User avatar
mustafa
Posts: 862
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Been thanked: 132 times
Contact:

Re: HPDFPRINT IMAGE Image cannot be loaded

Post by mustafa » Fri Nov 22, 2019 3:59 pm

Será por el tamaño de la Imagen ?
He modificado mi SampleJPG y modifique medidas de tamaño
de JPG y Funciona PNG y JPG y he añadido TYPE JPG
Muy raro ? :oops: :(

Code: Select all

*------------------------------------------------ Cuadro General ------------------------------*
     @ 005,005  HPDFPRINT RECTANGLE TO 292, 206 PENWIDTH 1 ROUNDED CURVE 1  
     @ 007,007  HPDFPRINT RECTANGLE TO 290, 204            ROUNDED CURVE 1                  
*----------------------------------------------------------------------------------------------*  
     @ 021,025 HPDFPRINT IMAGE "Resource\Business-Pie.png" width 15 height 15       
     @ 032,065 HPDFPRINT "DataBase WebCam Photo"  FONT "Times-Roman" SIZE 22 ITALIC   
     @ 032,150 HPDFPRINT DTOC(DATE())             FONT "Times-Roman" SIZE 18 ITALIC

     @ 047, 060 HPDFPRINT IMAGE "Resource\00001.jpg"  WIDTH 50 HEIGHT 50 TYPE JPG   // WIDTH 55 HEIGHT 50    
     @ 107, 100 HPDFPRINT IMAGE "Resource\00007.jpg"  WIDTH 50 HEIGHT 50 TYPE JPG   // WIDTH 55 HEIGHT 50    <-------  Modificado Tamaño 
     @ 167, 030 HPDFPRINT IMAGE "Resource\00005.jpg"  WIDTH 85 HEIGHT 80 TYPE JPG   // WIDTH 85 HEIGHT 80                  
 *-----------------------------------------------------------------------------------------------*
Saludos
Mustafa

franco
Posts: 369
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Been thanked: 11 times

Post by franco » Sat Nov 23, 2019 7:26 pm

Could someone help figure this out'
This code works if:
1. I print it to printer and then in preview save to disk as pdf, then go out of program.
2. take picture then go out of program and edit picture with paint and do nothing but save as pdf. The file is much smaller then original.
Then I go back in program and do not take a new picture. Then print to pdf. It now works.
You need a laptop or windows tablet to use this so you can take a picture with internal camera.
If I use external camera or any hmg pre-printed jpeg files it works;

Put this code in a folder and complile or build with. build.bat
build.bat in this folder
@ECHO OFF
call c:\hmg.3.4.4\build.bat main %*

you will also need CAMERA.SWF in this folder

Code: Select all


#include <hmg.ch>
Function Main
	LOCAL PD := .F.

	IF ! FILE('WEBCAM.HTML')
		WEBCAM('WEBCAM','CAMERA.SWF','300','300')
	ENDIF

	READYCAM()

	IF MSGYESNO('Do You Want to Print to PDF')
		PD := .T.
		SELECT PRINTER PDF 'MiPDF.pdf' TO lSuccess 
		IF LSUCCESS == .F.
			MSGINFO('PDF File Not Available')
			RETURN
		ENDIF
	ELSE
		SELECT  PRINTER DEFAULT TO lSUCCESS preview ;
		ORIENTATION PRINTER_ORIENT_PORTRAIT ;
		PAPERSIZE PRINTER_PAPER_LETTER ;
		QUALITY PRINTER_RES_MEDIUM
	ENDIF
	
	IF LSUCCESS == .F.
		MSGINFO('Printer Not Available')
		RETURN
	ENDIF
	
		START PRINTDOC
		START PRINTPAGE
 
		PL := 8
		@ PL,10 PRINT ' Hello to all:' 
		@ PL,170 PRINT 'Date: '+DTOC(DATE()) SIZE 10
		PL:= PL+20
		IF FILE(getcurrentfolder()+'\test.jpg')
			@ PL,10 PRINT IMAGE getcurrentfolder()+'\TEST.JPG' WIDTH 80 HEIGHT 60 TYPE JPG  
		ENDIF 
		@ 100,90 PRINT 'End of Report:'

	END PRINTPAGE
	END PRINTDOC

	IF PD = .T.
		EXECUTE FILE 'MIPDF.PDF'
	ENDIF
	PD := .F.

Return

FUNCTION READYCAM(PICT)

IF !ISWINDOWACTIVE(CAMFORM)            //330        (GETDESKTOPwidth())-35                                        
	DEFINE WINDOW CAMFORM AT 65,30 WIDTH 620  HEIGHT 310  TITLE 'Shot Image ** Escape to Cancel'  ICON 'WEBCAM.ICO' MODAL  SYSMENU .F. ;
		BACKCOLOR (143,200,220)
	ON KEY ESCAPE OF CAMFORM ACTION {||{ANS := 'F'},{CAMFORM.RELEASE}}
	DEFINE ACTIVEX ACTIVEX2 
		ROW   10
		COL   7   
		HEIGHT 300   //230   //300
		WIDTH 230
		PROGID "SHELL.EXPLORER.2"
	END ACTIVEX

	DEFINE BUTTON BUTTON1
        ROW    5  //250
        COL    350  //120
        WIDTH  100
        HEIGHT 100   //28
        ACTION SNAPSHOT()   
        CAPTION "Snap Shot"
		PICTURE 'CAMERA'
        FONTNAME "Arial"
        FONTSIZE 10
		*visible .F.
    END BUTTON
		DEFINE BUTTON BUTTON2
        ROW    160 //250
        COL    350   //170  //120
        WIDTH  100
        HEIGHT 100   //28
        ACTION {||{ANS := 'F'},{CAMFORM.RELEASE}}
        CAPTION "Exit"
		PICTURE 'hp_close'
        FONTNAME "Arial"
        FONTSIZE 10
		*visible .F.
    END BUTTON
	END WINDOW
	CAMFORM.ACTIVEX2.OBJECT:NAVIGATE(GETCURRENTFOLDER()+"\WEBCAM.HTML")
	CAMFORM.ACTIVATE
ELSE
	MSGBOX('Not Available')
ENDIF
RETURN

FUNCTION SNAPSHOT   

CAMFORM.CAPTURE('TEST.JPG',15,7,300,230)     
PLAYBEEP()
CAMFORM.RELEASE
RETURN

FUNCTION WEBCAM
PRIVATE   _cfile, _cimage, _cwidth, _cheight
PARAMETER _cfile, _cimage, _cwidth, _cheight
_cfile:=_cfile+".html"
TEXT TO FILE &_cfile
<html>
	<body style="overflow: hidden; margin: 0; padding: 0;"
		ondragstart="return false;" ondrop="return false;" oncontextmenu="return false;" onmousedown="return false;">
		<PARAM NAME="SCALE" VALUE="exactfit">
		<embed src="&_cimage" quality="high" type="application/x-shockwave-flash" width="100%" height="100%"
		allowScriptAccess="always" menu="false">
		</body>
</html>
ENDTEXT
RETURN
I have spent 2 weeks on this and am now using the print to printer a rename file name to pdf
I have also tried this with hpdfprint acts the same.
Is there a save as in hmg.3.4.4
Is there a way to (SAVE AS) the same name.pdf after the picture is captured to do what the disk in the print preview does.
Thanks to all
Franco
Franco Bushie
Canada

franco
Posts: 369
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Been thanked: 11 times

Post by franco » Thu Nov 28, 2019 12:20 am

Has anyone had a chance to try this.
I have changed a couple of things from previous post, but still does not work. win10

Code: Select all


#include <hmg.ch>
Function Main
	LOCAL PD := .F.

	IF ! FILE('WEBCAM.HTML')
		WEBCAM('WEBCAM','CAMERA.SWF','300','300')
	ENDIF

	READYCAM()

	IF MSGYESNO('Do You Want to Print to PDF')
		PD := .T.
		SELECT PRINTER PDF 'MiPDF.pdf' TO lSuccess 
		IF LSUCCESS == .F.
			MSGINFO('PDF File Not Available')
			RETURN
		ENDIF
	ELSE
		SELECT  PRINTER DEFAULT TO lSUCCESS preview ;
		ORIENTATION PRINTER_ORIENT_PORTRAIT ;
		PAPERSIZE PRINTER_PAPER_LETTER ;
		QUALITY PRINTER_RES_MEDIUM
	ENDIF
	
	IF LSUCCESS == .F.
		MSGINFO('Printer Not Available')
		RETURN
	ENDIF
	
		START PRINTDOC
		START PRINTPAGE
 
		PL := 8
		@ PL,10 PRINT ' Hello to all:' 
		@ PL,170 PRINT 'Date: '+DTOC(DATE()) SIZE 10
		PL:= PL+20
		IF FILE(getcurrentfolder()+'\test.jpg')
			@ PL,10 PRINT IMAGE getcurrentfolder()+'\TEST.JPG' WIDTH 80 HEIGHT 60 TYPE JPG  
		ENDIF 
		@ 100,90 PRINT 'End of Report:'

	END PRINTPAGE
	END PRINTDOC

	IF PD = .T.
		EXECUTE FILE 'MIPDF.PDF'
	ENDIF
	PD := .F.

Return

FUNCTION READYCAM(PICT)

IF !ISWINDOWACTIVE(CAMFORM)            //330        (GETDESKTOPwidth())-35                                        
	DEFINE WINDOW CAMFORM AT 65,30 WIDTH 620  HEIGHT 310  TITLE 'Shot Image ** Escape to Cancel'  ICON 'WEBCAM.ICO' MODAL  SYSMENU .F. ;
		BACKCOLOR (143,200,220)
	ON KEY ESCAPE OF CAMFORM ACTION {||{ANS := 'F'},{CAMFORM.RELEASE}}
	DEFINE ACTIVEX ACTIVEX2 
		ROW   10
		COL   7   
		HEIGHT 300   //230   //300
		WIDTH 230
		PROGID "SHELL.EXPLORER.2"
	END ACTIVEX

	DEFINE BUTTON BUTTON1
        ROW    5  //250
        COL    350  //120
        WIDTH  100
        HEIGHT 100   //28
        ACTION SNAPSHOT()   
        CAPTION "Snap Shot"
		PICTURE 'CAMERA'
        FONTNAME "Arial"
        FONTSIZE 10
		*visible .F.
    END BUTTON
		DEFINE BUTTON BUTTON2
        ROW    160 //250
        COL    350   //170  //120
        WIDTH  100
        HEIGHT 100   //28
        ACTION {||{ANS := 'F'},{CAMFORM.RELEASE}}
        CAPTION "Exit"
		PICTURE 'hp_close'
        FONTNAME "Arial"
        FONTSIZE 10
		*visible .F.
    END BUTTON
	END WINDOW
	CAMFORM.ACTIVEX2.OBJECT:NAVIGATE(GETCURRENTFOLDER()+"\WEBCAM.HTML")
	CAMFORM.ACTIVATE
ELSE
	MSGBOX('Not Available')
ENDIF
RETURN

FUNCTION SNAPSHOT   

CAMFORM.CAPTURE('TEST.JPG',15,7,300,230)     
PLAYBEEP()
CAMFORM.RELEASE
RETURN

FUNCTION WEBCAM
PRIVATE   _cfile, _cimage, _cwidth, _cheight
PARAMETER _cfile, _cimage, _cwidth, _cheight
_cfile:=_cfile+".html"
TEXT TO FILE &_cfile
<html>
	<body style="overflow: hidden; margin: 0; padding: 0;"
		ondragstart="return false;" ondrop="return false;" oncontextmenu="return false;" onmousedown="return false;">
		<PARAM NAME="SCALE" VALUE="exactfit">
		<embed src="&_cimage" quality="high" type="application/x-shockwave-flash" width="100%" height="100%"
		allowScriptAccess="always" menu="false">
		</body>
</html>
ENDTEXT
RETURN
Franco
Franco Bushie
Canada

User avatar
AUGE_OHR
Posts: 290
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany
Has thanked: 32 times
Been thanked: 39 times

Post by AUGE_OHR » Thu Nov 28, 2019 1:43 am

hi
franco wrote:
Sat Nov 23, 2019 7:26 pm
you will also need CAMERA.SWF in this folder
can you tell me please where do i get that Flash file :?:

franco
Posts: 369
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Been thanked: 11 times

Post by franco » Thu Nov 28, 2019 1:50 am

I no not know how to send links, but I type camera.swf in active topic search box and testcam.zip comes up and it is in there.
Franco Bushie
Canada

User avatar
AUGE_OHR
Posts: 290
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany
Has thanked: 32 times
Been thanked: 39 times

Post by AUGE_OHR » Thu Nov 28, 2019 1:59 am

franco wrote:
Thu Nov 28, 2019 1:50 am
I no not know how to send links, but I type camera.swf in active topic search box and testcam.zip comes up and it is in there.
THX
i found it in this Thread viewtopic.php?f=14&t=4862

User avatar
mustafa
Posts: 862
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Been thanked: 132 times
Contact:

Post by mustafa » Thu Nov 28, 2019 4:12 pm

Hola amigo Franco
He estado revisando tu Sample y lo he modificado
un poco, pero el resultado no me está gustando
demasiado y creo que la causa es por fichero
camera.swf que no está dando la calidad necesario
un fichero JPG generado al cargarlo con Pain Shop
me está dando este mensaje al intentar cargarlo
"Este no es un archivo válido JPEG-JFIF"

Solo no me está dando Error de está forma
mira--> HMG_PrintFile1.PDF
Saludos
Mustafa
*-------------------------------------------------

Hi friend Franco
I've been checking your Sample and I have modified it
a bit, but I don't like the result
too much and I think the cause is per file
camera.swf that is not giving the necessary quality
a JPG file generated when loaded with Pain Shop
You are giving me this message when you try to load it
"This is not a valid JPEG-JFIF file"

It's just not giving me Error this way
look -> HMG_PrintFile1.PDF
Regards
Mustafa :x :mrgreen:
Attachments
Web_Cam.zip
(430.63 KiB) Downloaded 17 times

franco
Posts: 369
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Been thanked: 11 times

Post by franco » Thu Nov 28, 2019 7:02 pm

Mustafa, Thanks for helping.
I have adjusted the code below. If print to file, print preview is wrong but pdf file is right.
If print to printer, printer is right pff will be wrong.
We must find out what the disk print does.
Also as I said before if I load the jpeg file with paint then just save it, it will be right. paint does something in the save.

Code: Select all

#include <hmg.ch>
Function Main
	LOCAL PD := .F., LSUCCESS

	IF ! FILE('WEBCAM.HTML')
		WEBCAM('WEBCAM','CAMERA.SWF','300','300')     //'230')
	ENDIF

	READYCAM()         
		


	IF MSGYESNO('Do You Want to Print to *** DISK***')    /// NEW ADDED DISK FROM PRINT PREVIEW
		PD := .T.
	ENDIF
		SELECT  PRINTER DEFAULT TO LSUCCESS preview ;
		ORIENTATION PRINTER_ORIENT_PORTRAIT ;
		PAPERSIZE PRINTER_PAPER_LETTER ;
		QUALITY PRINTER_RES_MEDIUM
	
	IF LSUCCESS == .F.
		MSGINFO('Printer Not Available')
		RETURN
	ENDIF

		START PRINTDOC
		START PRINTPAGE
 
		PL := 8
		@ PL,10 PRINT ' Hello to all:' 
		@ PL,170 PRINT 'Date: '+DTOC(DATE()) SIZE 10
		PL:= PL+20
		IF FILE(getcurrentfolder()+'\test1.jpg')  //BT_BitmapSaveFile(hBitmap, cImageFileName )
			IF PD = .T.
				@ PL,10 PRINT IMAGE 'C:\TRYPD\TRYPD2\test.jpg' WIDTH 40 HEIGHT 80 TYPE jpg  STRETCH 
			ELSE
				@ PL,10 PRINT IMAGE 'C:\TRYPD\TRYPD2\test.jpg' WIDTH 80 HEIGHT 60 TYPE jpg  
			ENDIF
		ENDIF 
		@ 100,90 PRINT 'End of Report:'

	END PRINTPAGE
	END PRINTDOC

	IF PD = .T.
		EXECUTE FILE 'HMG_PRINTFILE.PDF '  
	ENDIF
	PD := .F.

Return

FUNCTION READYCAM(PICT)

IF !ISWINDOWACTIVE(CAMFORM)            //330        (GETDESKTOPwidth())-35                                        
	DEFINE WINDOW CAMFORM AT 65,30 WIDTH 620  HEIGHT 310  TITLE 'Shot Image ** Escape to Cancel'  ICON 'WEBCAM.ICO' MODAL  SYSMENU .F. ;
		BACKCOLOR (143,200,220)
	ON KEY ESCAPE OF CAMFORM ACTION {||{ANS := 'F'},{CAMFORM.RELEASE}}
	DEFINE ACTIVEX ACTIVEX2 
		ROW   10
		COL   7   
		HEIGHT 230      //300
		WIDTH 300        //230
		PROGID "SHELL.EXPLORER.2"
	END ACTIVEX

	DEFINE BUTTON BUTTON1
        ROW    5  //250
        COL    350  //120
        WIDTH  100
        HEIGHT 100   //28
        ACTION SNAPSHOT()   
        CAPTION "Snap Shot"
		PICTURE 'CAMERA'
        FONTNAME "Arial"
        FONTSIZE 10
		*visible .F.
    END BUTTON
		DEFINE BUTTON BUTTON2
        ROW    160 //250
        COL    350   //170  //120
        WIDTH  100
        HEIGHT 100   //28
        ACTION {||{ANS := 'F'},{CAMFORM.RELEASE}}
        CAPTION "Exit"
		PICTURE 'hp_close'
        FONTNAME "Arial"
        FONTSIZE 10
		*visible .F.
    END BUTTON
	END WINDOW
	CAMFORM.ACTIVEX2.OBJECT:NAVIGATE(GETCURRENTFOLDER()+"\WEBCAM.HTML")
	CAMFORM.ACTIVATE
ELSE
	MSGBOX('Not Available')
ENDIF
RETURN

FUNCTION SNAPSHOT   

CAMFORM.CAPTURE('TEST.JPG',45,50,260,170)     
PLAYBEEP()
copy file test.jpg to test1.jpg                                          //ADDED THIS NOT NEEDED JUST FOR CHECKING PHOTO

CAMFORM.RELEASE
RETURN

FUNCTION WEBCAM
PRIVATE   _cfile, _cimage, _cwidth, _cheight
PARAMETER _cfile, _cimage, _cwidth, _cheight
_cfile:=_cfile+".html"
TEXT TO FILE &_cfile

<html>
	<body style="overflow: hidden; margin: 0; padding: 0;"
		ondragstart="return false;" ondrop="return false;" oncontextmenu="return false;" onmousedown="return false;">
		<PARAM NAME="SCALE" VALUE="exactfit">
		<embed src="&_cimage" quality="high" type="application/x-shockwave-flash" width="100%" height="100%"
		allowScriptAccess="always" menu="false">
		</body>
</html>
ENDTEXT
RETURN
This works but is not the right way to do things.
Thanks for help,
Franco
Franco Bushie
Canada

User avatar
mustafa
Posts: 862
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Been thanked: 132 times
Contact:

Post by mustafa » Fri Nov 29, 2019 2:07 pm

Hola amigo Franco
He seguido con las investigación he creado una pequeña
aplicación para imprimir PDF y veo que con fotos
normales se genera PDF --> 00004.jpg y 00005.jpg pero
con 00002.jpg generado con "camera.swf" si ves la
información en "Info_Image.jpg" 00002.jpg No tiene
Compresión ni Resolución , encambio el mismo fichero
Salvado como 00021.jpg con el Paint de Windows
ya tiene Compresión "JPEG,quality:95 y una Resolución
de 96x96 PPP

En mi Sample todos los ficheros se imprimen menos
el 00002.jpg que esta dando Error

Creo que el problema es "camera.swf" no la programación
Harbour-HMG

Saludos
Mustafa
*--------------------------------------------------------------*
Hi friend Franco
I have continued with the research I created a small
application to print PDF and I see that with photos
Normal PDF is generated -> 00004.jpg and 00005.jpg but
with 00002.jpg generated with "camera.swf" if you see the
information in "Info_Image.jpg" 00002.jpg You do not have
Compression or Resolution, change the same file
Saved as 00021.jpg with Windows Paint
It already has Compression "JPEG, quality: 95 and a Resolution
96x96 PPP

In my Sample all files are Printed less
The 00002.jpg that is giving Error

I think the problem is "camera.swf" not programming
Harbour-HMG

Regards
Mustafa
Attachments
DBF_JPG_Sample.zip
(641.1 KiB) Downloaded 12 times
Screenshot.jpg
Screenshot.jpg (26.76 KiB) Viewed 66 times

franco
Posts: 369
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Been thanked: 11 times

Post by franco » Fri Nov 29, 2019 5:06 pm

Hi Mustafa, Did you try my last sample ?.
I am going to try and change all sizes to see what happens, like camera.swf 900,900 and capture 900 700.
I do not understand how all this works but I see in html at bottom exactfit and width=100% height=100%.
All the best,
Franco
Franco Bushie
Canada

Post Reply