How to edit a EMF file

Post Reply
User avatar
vilian
Posts: 987
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil
Contact:

How to edit a EMF file

Post by vilian »

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 ?
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
User avatar
cnavarro
Posts: 6558
Joined: Wed Feb 15, 2012 8:25 pm
Location: España
Been thanked: 3 times

Re: How to edit a EMF file

Post by cnavarro »

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
User avatar
vilian
Posts: 987
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil
Contact:

Re: How to edit a EMF file

Post by vilian »

Thanks,

But I already have the total number of pages, what I need is to change this pages to insert this total in them.
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
User avatar
cnavarro
Posts: 6558
Joined: Wed Feb 15, 2012 8:25 pm
Location: España
Been thanked: 3 times

Re: How to edit a EMF file

Post by cnavarro »

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
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
User avatar
vilian
Posts: 987
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil
Contact:

Re: How to edit a EMF file

Post by vilian »

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
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
AntoninoP
Posts: 375
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy
Contact:

Re: How to edit a EMF file

Post by AntoninoP »

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.
Marcelo Via Giglio
Posts: 1078
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia
Has thanked: 1 time

Re: How to edit a EMF file

Post by Marcelo Via Giglio »

Hello,

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
User avatar
cnavarro
Posts: 6558
Joined: Wed Feb 15, 2012 8:25 pm
Location: España
Been thanked: 3 times

Re: How to edit a EMF file

Post by cnavarro »

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

Image
Image
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
User avatar
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

Post by nageswaragunupudi »

Marcelo Via Giglio's solution is Good
Regards

G. N. Rao.
Hyderabad, India
User avatar
vilian
Posts: 987
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil
Contact:

Re: How to edit a EMF file

Post by vilian »

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

Image
Image
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
AntoninoP
Posts: 375
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy
Contact:

Re: How to edit a EMF file

Post by AntoninoP »

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

Image
Image
User avatar
cnavarro
Posts: 6558
Joined: Wed Feb 15, 2012 8:25 pm
Location: España
Been thanked: 3 times

Re: How to edit a EMF file

Post by cnavarro »

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
User avatar
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

Post by nageswaragunupudi »

Mr Cristobal's approach must be something like this:

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:

Image

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
User avatar
vilian
Posts: 987
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil
Contact:

Re: How to edit a EMF file

Post by vilian »

Thank you,
It's exactly I need ;)
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
Post Reply