#1 PDF Engine » Fonts » 2011-08-09 22:55:21

hovecricketer
Replies: 1

I'm creating a pdf from a word document by: copying it to the clipboard, assigning the clipboard to a MetaFile, then using Canvas.RenderMetaFile, and finally SaveToFile.

with TPdfDocument.Create do
try
   MF := TMetaFile.Create;
   MF.Assign(Clipboard);
   Canvas.RenderMetaFile(MF);
   SaveToFile(filename);
finally
       MF.Free;
end;

It's fine except the fonts seem to go all over the place (doubling in width, and height, overwriting subsequent words, etc) in some parts of the document. The document uses tables and Arial 9pt, so nothing weird.

I've tried using RenderMetaFile with the full parameter set, adjusting the 2 kerning parameters, but I don't seem to be able to improve it reliably. My guess is that it is the kerning, some sort of level being exceeded causing the font to be changed. 

Can anyone explain how to use the parameters of RenderMetaFile in more detail? (Or some other approach, that doesn't have this problem?)

thanks very much

Steve

#2 Re: PDF Engine » Newbie having a problem scaling » 2011-07-11 18:58:59

Thanks ab

I've tried quite a range of values for sScale, none of which had any effect. 

In what way does the "scaling depend on the metafile size"?

I'll take a longer look at the TMetaFile object and see if anything stands out.  What's happening at the moment is that the data is actually being shrunk, for some reason, and the only reason I can think of at the moment is that there's a lot of white space defined in the data being assigned to the meta file. The question here is should the adjustments be made to the MetaFile, or during the rendering process (with changes to the parameters, e.g. scale), or perhaps to the Canvas itself?

Any help would be much appreciated!

steve

#3 PDF Engine » Newbie having a problem scaling » 2011-07-11 16:07:33

hovecricketer
Replies: 2

Hi

Just starting using pdf engine.

I'm using pdf engine as part of a routine to convert a MS Word doc into a pdf.

I copy the word doc to the clipboard, and then (using some code from this forum!)....

With TPdfDocument.Create do
try
PDFA1 := True;
DefaultPaperSize := psA4;

AddPage;

MS := TMetaFile.Create;
MF.Enhanced := True;
try
    MF.Assign(Clipboard);
    sScale   := 1;
    sXoff     := 25;
    sYoff     := -120;
    Canvas.RenderMetaFile(MF, sScale, sXoff, sYoff, False, 99, 101);
finally
   MF.Free;
end

finally
    Free;
End;


It works OK except that the image/text is too small, i.e. rather than taking up half a page, it's more like just the top left corner.

I've tried using the 'scale' parameter in RenderMetaFile, but it doesn't seem to do anything.

Can anyone point me in the right direction with what I'm doing wrong?

thanks

steve

Board footer

Powered by FluxBB