How to edit a EMF file
How to edit a EMF file
Hi Guys,
I have a program where I print something like this Page: 1/NNN, after generated all pages I wanted edit them and change NNN for the total of pages(Ex: 40), so the EMF files will have Page: 1/40, Page: 2/40, etc
Do you know if It´s possible ?
I have a program where I print something like this Page: 1/NNN, after generated all pages I wanted edit them and change NNN for the total of pages(Ex: 40), so the EMF files will have Page: 1/40, Page: 2/40, etc
Do you know if It´s possible ?
Re: How to edit a EMF file
Look Len( ::oDevice:aMeta )
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Re: How to edit a EMF file
Thanks,
But I already have the total number of pages, what I need is to change this pages to insert this total in them.
But I already have the total number of pages, what I need is to change this pages to insert this total in them.
Re: How to edit a EMF file
Do you want to change NNN by the total number of pages after generating the EMF?
I think not possible, you have to regenerate the EMF
Well, you can try to read the emf and with a strtran change the contents of the file and re-record it, but I have not tried it
I think not possible, you have to regenerate the EMF
Well, you can try to read the emf and with a strtran change the contents of the file and re-record it, but I have not tried it
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Re: How to edit a EMF file
I have already tried it. But, after to change the file, its turns invalid.
IF I try open the modified file, it's showing the message bellow:
Can't read file reader!
Unknow file format, empty/damaged file
IF I try open the modified file, it's showing the message bellow:
Can't read file reader!
Unknow file format, empty/damaged file
Re: How to edit a EMF file
The EMF file are binary so I think the strTran can not work... Besides the text inside them is saved as WideChar...
The correct solution is difficult but not impossible: https://msdn.microsoft.com/en-us/library/dd162509(v=vs.85).aspx..-.
you need to add a lot of support for harbour or write your procedure in C...
I think the simpler solution is do 2 prints, the first to see how much pages it will create, and the second with the correct page total number.
The correct solution is difficult but not impossible: https://msdn.microsoft.com/en-us/library/dd162509(v=vs.85).aspx..-.
you need to add a lot of support for harbour or write your procedure in C...
I think the simpler solution is do 2 prints, the first to see how much pages it will create, and the second with the correct page total number.
-
- Posts: 1078
- Joined: Fri Oct 07, 2005 3:33 pm
- Location: Cochabamba - Bolivia
- Has thanked: 1 time
Re: How to edit a EMF file
Hello,
many years ago, I made changes to the report class, one of them was the page total number
You can call this function from the Report END() method NumeraPag(::oDevice,1,1) or define in external event ON END, etc
many years ago, I made changes to the report class, one of them was the page total number
Code: Select all | Expand
Function NumeraPag(oPrn,nRowStep,nColStep)
Local x
Local nPaginas := Len( oPrn:aMeta )
Local aFicheros := oPrn:aMeta
Local nCol := 70*nColStep //colocalo donde prefieras
Local nLin := 64*nRowStep // ""
if nPaginas <= 1 // Solamente una pagina
Return Nil
endif
oPrn:aMeta := {}
FOR x := 1 TO nPaginas
//PAGE
oPrn:startpage()
oPrn:ImportWMF( aFicheros[ x ], .F. )
oPrn:Say( nLin,nCol, +Alltrim( Str( x ) ) +"/" + Alltrim( Str( nPaginas ) ) ,,,,,1 )
oPrn:endPage()
//ENDPAGE
NEXT
Return NIl
You can call this function from the Report END() method NumeraPag(::oDevice,1,1) or define in external event ON END, etc
Re: How to edit a EMF file
AntoninoP wrote:The EMF file are binary so I think the strTran can not work... Besides the text inside them is saved as WideChar...
No, with StrTran not, that is obvious
But it is possible change text


Last edited by cnavarro on Wed Apr 18, 2018 12:20 am, edited 1 time in total.
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
- nageswaragunupudi
- Posts: 10729
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 10 times
- Contact:
Re: How to edit a EMF file
Marcelo Via Giglio's solution is Good
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
Re: How to edit a EMF file
How did you do this change ?
cnavarro wrote:AntoninoP wrote:The EMF file are binary so I think the strTran can not work... Besides the text inside them is saved as WideChar...
No, with StrTran not, that is obvious
But it is possible change text
Re: How to edit a EMF file
Did you use a binary editor?
cnavarro wrote:AntoninoP wrote:The EMF file are binary so I think the strTran can not work... Besides the text inside them is saved as WideChar...
No, with StrTran not, that is obvious
But it is possible change text
Re: How to edit a EMF file
No, through programming
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
- nageswaragunupudi
- Posts: 10729
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 10 times
- Contact:
Re: How to edit a EMF file
Mr Cristobal's approach must be something like this:
This could work in some simple cases that Mr Vilian requires, but not in all cases.
Explanation why "not in all cases".
emf file stores a lot more information than text and font info. In some cases alignment, kerning etc of characters may get disturbed.
Example:
This substitution looks quite reasonable:
But let us see the result:

We can use this approach if we keep in mind its limitations.
In any case, this should work well for page numbers as required by Mr Vilian
Code: Select all | Expand
cBuf := MEMOREAD( "test.emf"
cBuf := StrTran( cBuf, AnsiToWide( "/99" ), AnsiToWide( "/40" ) )
MEMOWRIT( "test.emf", cBuf )
This could work in some simple cases that Mr Vilian requires, but not in all cases.
Explanation why "not in all cases".
emf file stores a lot more information than text and font info. In some cases alignment, kerning etc of characters may get disturbed.
Example:
This substitution looks quite reasonable:
Code: Select all | Expand
cBuf := StrTran( cBuf, AnsiToWide( "City" ), AnsiToWide( "CITY" ) )
But let us see the result:

We can use this approach if we keep in mind its limitations.
In any case, this should work well for page numbers as required by Mr Vilian
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India