Print .jpg in pdf print

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

franco
Posts: 818
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Print .jpg in pdf print

Post by franco »

Can anyone help
I have a folder with a jpg file called A1234.jpg.
This file prints to printer but not to pdf.
The code as follows

Code: Select all

#include <hmg.ch>

Function Main
local pl := 0, lsuccess := .F., pd := .F., PDP := '', PAGE := 0


pimage:= 'P1234.jpg'


	IF MSGYESNO('Do you Want To PDF (Y/N) ? ')
		*PD := .T.
		PDP := 'A1234'                     //SUBSTR(CUSTOMER->NAME,1,AT(SPACE(1),CUSTOMER->NAME)-1)
		PDP :=  PDP+'.PDF'                        //GETCURRENTFOLDER()+'\SEND\'+PDP+'.PDF'
		IF FILE(PDP)
			DELETE  FILE(PDP)
		ENDIF
		SELECT PRINTER PDF PDP TO LSUCCESS     
				IF ! lSuccess .OR. LEN(ALLTRIM(PDP)) < 1
					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 12
		PL:= PL+20
		IF FILE(PIMAGE)
			@ PL,10 PRINT IMAGE PIMAGE WIDTH 80 HEIGHT 60 STRETCH
		ENDIF 
		@ 100,90 PRINT 'End of Report:'

	END PRINTPAGE
	END PRINTDOC

Return
Thanks in advance,
Franco
Last edited by franco on Fri Jan 10, 2020 9:01 pm, edited 1 time in total.
All The Best,
Franco
Canada
User avatar
jairpinho
Posts: 420
Joined: Mon Jul 18, 2011 5:36 pm
Location: Rio Grande do Sul - Brasil
Contact:

Re: Print .jpg in pdf print

Post by jairpinho »

franco wrote: Thu Nov 07, 2019 5:38 pm Can anyone help
I have a folder with a jpg file called A1234.jpg.
This file prints to printer but not to pdf.
The code as follows

Code: Select all

#include <hmg.ch>

Function Main
local pl := 0, lsuccess := .F., pd := .F., PDP := '', PAGE := 0


pimage:= 'P1234.jpg'


	IF MSGYESNO('Do you Want To PDF (Y/N) ? ')
		*PD := .T.
		PDP := 'A1234'                     //SUBSTR(CUSTOMER->NAME,1,AT(SPACE(1),CUSTOMER->NAME)-1)
		PDP :=  PDP+'.PDF'                        //GETCURRENTFOLDER()+'\SEND\'+PDP+'.PDF'
		IF FILE(PDP)
			DELETE  FILE(PDP)
		ENDIF
		SELECT PRINTER PDF PDP TO LSUCCESS     
				IF ! lSuccess .OR. LEN(ALLTRIM(PDP)) < 1
					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 12
		PL:= PL+20
		IF FILE(PIMAGE)
			@ PL,10 PRINT IMAGE PIMAGE WIDTH 80 HEIGHT 60 STRETCH
		ENDIF 
		@ 100,90 PRINT 'End of Report:'

	END PRINTPAGE
	END PRINTDOC

Return
Thanks in advance,
Franco
hello

Code: Select all


pimage: "P1234.jpg"
@ PL,10 PRINT IMAGE PIMAGE WIDTH 80 HEIGHT 60 STRETCH

or 

@ PL,10 PRINT IMAGE PIMAGE WIDTH 80 HEIGHT 60 TYPE JPG STRETCH

or

@ PL,10 PRINT IMAGE PIMAGE WIDTH 80 HEIGHT 60


Jair Pinho
HMG ALTA REVOLUÇÃO xBASE
HMG xBASE REVOLUTION HIGH
http://www.hmgforum.com.br
franco
Posts: 818
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: Print .jpg in pdf print

Post by franco »

Thank you , Jair
TYPE JPG makes it work for me.
Franco
All The Best,
Franco
Canada
User avatar
HASA
Posts: 44
Joined: Sat Feb 23, 2013 3:00 pm
Location: SÃO PAULO - BRAZIL

Re: Print .jpg in pdf print

Post by HASA »

Friends, you can set an image as a watermark?

HASA
franco
Posts: 818
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: Print .jpg in pdf print

Post by franco »

How would you do this ?.
Now I still can not print a file created by my programmed camera inside hmg to a pdf.
If I use a image from an outside camera or a picture off the internet it will work, but if I use a picture created in hmg from my lap top camera
I still get the message Can not load image
I think it is something to do with webcam.html. Is there a stand alone webcam.html as everyone is moving away from flash. I can not get flash to work more then one time and it has to ask me if I want to use it.
Any help appreciated.
Franco
All The Best,
Franco
Canada
franco
Posts: 818
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: Print .jpg in pdf print

Post by franco »

I am trying to use the windows camera and it is working with run command.
local cCMD := "start microsoft.windows.camera:"
RUN (cCMD)
I can not save this jpeg file where I want and name what I want. It saves in user ........ folder, which is fine.
Each time before I take a picture I go to folder and rename all the pictures in it, I found a way.
The names of the files are Win_ plus time stamp numbers .jpg
I can rename these with rename "w*.jpg" to "Q*.jpg" and they are all renamed.
Now when I take a picture the only picture in the folder starts with a W and I would like to rename it but I do not know the complete name.
rename W*.jpg to 1234.jpg does not work. I need to know the complete name of the file then it will work.
Does anyone know how to find the complete name of the file starting with W and ending with .jpg, or take away all characters before .jpg.
If it became w.jpg it would be easy to work with like copy file w.jpg to 1234_1.jpg or rename 'w.jpg' to '1234.jpg'.
Thanks in advance
Franco
All The Best,
Franco
Canada
Red2
Posts: 273
Joined: Sat May 18, 2019 2:11 pm
DBs Used: Visual FoxPro, FoxPro
Location: United States of America

Re: Print .jpg in pdf print

Post by Red2 »

Hi Franco,

May I share an idea from something similar that I did in case it might be useful to you?

I copied the original directory to an array using ADIR(), took my programmatic action, then finally another post-action directory ADIR().

When compared the two arrays I was able to isolate the file change(s) and take the necessary action.

I hope that this might be of some use.

Regards,

Red2
franco
Posts: 818
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: Print .jpg in pdf print

Post by franco »

Hello red2,
I have not used adir before but makes sense. I could bring in after taking picture. If I can sort by date stamp, the
last file will be the last picture. I will try and let you know.
Thanks a lot,
Franco
All The Best,
Franco
Canada
franco
Posts: 818
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

Re: Print .jpg in pdf print

Post by franco »

I have adir working to find file name but now I have another problem.
in visual foxpro I can enter command rename w*.jpg to q*.jpg and any files in folder starting with w and ending with .jpg will be renamed
from the complete w name to the complete q name
file w123.jpg will know be q123.jpg'
I can not do this in hmg rename with a * i just does not work.
could I somehow use adir for this also
Thanks in Advance
Franco
All The Best,
Franco
Canada
Red2
Posts: 273
Joined: Sat May 18, 2019 2:11 pm
DBs Used: Visual FoxPro, FoxPro
Location: United States of America

Re: Print .jpg in pdf print

Post by Red2 »

Hi Franco,

I too come from a VFP background and am learning the differences between it and HMG. I see in the HMG help file that HMG has a command, "RENAME": Syntax: RENAME <cOldFile> TO <cNewFile>

The help file warns: "This command (sic) if not affected by the SET PATH TO or SET DEFAULT TO commands; drive and (sic) directoy designaters must be specified if either file is in a directory other then the default drive and directory."

I have not yet used RENAME in HMG but I suspect that you could, in a loop, rename each file, one at a time, using information from your ADIR array.

I hope that this is of some use.

Kind regards,
Red2
Post Reply