You are not logged in.
Pages: 1
Thank you for answering. I'm sorry, but I don't know how to increase the resolution of the target pdf content. If I increase the original size of the metafile there is no change in how the text is displayed... If I increase the page size of the pdf the content of the metafile is displayed to it's original size, not resized to the entire page of the pdf.
Here is my code :
Pdf := TPdfDocument.Create;
Pdf.DefaultPageWidth := MulDiv(Image1.Picture.Metafile.Width,72,Pdf.ScreenLogPixels); // Image1 is a TImage component
Pdf.DefaultPageHeight := MulDiv(Image1.Picture.Metafile.Height,72,Pdf.ScreenLogPixels);
Pdf.AddPage;
Pdf.Canvas.RenderMetaFile(Image1.Picture.Metafile);
Pdf.SaveToFile(NameOfThePDF);
Pdf.Free;
The metafiles are created drawing on a MetafileCanvas of a TImage Metafile. The drawing is done by parameters. So the user is able to draw text, lines or insert images with the parameters that he provides.
The user sometimes creates textrects with the width of 0. So it's obvious that the text field should not appear. In the metafile everthing works how it should, but in the PDF the text field appears. Again, I don't know if my modification was right, but it worked for me.
Here is an example of a metafile with a textfield (r2) with the width of 0. And here is the pdf generated with the original synpdf. As you can see, the r2 textfield is displayed.
I generated this EMF file.
When I convert it to pdf it displays like this.
If you notice, there is a difference between them: especially in third (R5,R6) and fifth (R9,R10) row. The row move down and there is no space between the text and the bottom line. If the text size is smaller the problem is not visible. But when it increases the problem becomes visible.
If you help me with this I will appreciate it. Thanks in advance.
Also, I had another problem with the 0 lenght TextRect (it currently displays even if it is 0), but I solved it changing the synpdf source. I'm not an expert, I don't know if this is right, but it saved me a lot:
From:
// detect clipping
with R.emrtext.rcl do
WithClip := (Right>Left) and (Bottom>Top);
To:
// detect clipping
with R.emrtext.rcl do
WithClip := (Right>=Left) and (Bottom>=Top);
From synpdf source line 9247 (leaf f782f5d5e8, artifact 23cf49002b0ca9e14ad3286570b55b235e4dff29).
I've downloaded the latest source from the repository, and now it works great!
Hello!
I have an sample generated emf file wich I need to convert into a PDF document. The generated emf file is displayed correctly by the Windows Default Picture Viewer and by the EMFExplorer.
The problem is that after i convert the emf, and open the generated PDF with Acrobat Reader, only the first word is visible. I know that the rest of the text is there, and positioned correctly, because after I select the text from my PDF viewer, I can see the highlighted background block where the text should be. And after I copy and paste it into an simple text editor, the entire text is there. But when I paste it into an document editor, the text is displayed as in the PDF and the font color of the "invisible" text is white.
Here is a sample code, how I use the RenderMetaFile procedure and save the PDF file:
procedure SaveMyEMF;
var
MTF : TMetafile;
Pdf: TPdfDocument;
begin
MTF := TMetafile.Create;
MTF.LoadFromFile('sample.emf');
Pdf := TPdfDocument.Create;
Pdf.DefaultPageWidth := MulDiv(MTF.Width,72,Pdf.ScreenLogPixels);
Pdf.DefaultPageHeight := MulDiv(MTF.Height,72,Pdf.ScreenLogPixels);
Pdf.AddPage;
Pdf.Canvas.RenderMetaFile(MTF);
Pdf.SaveToFile('test.pdf');
FreeAndNil(MTF);
FreeAndNil(Pdf);
end;
The question is: what am I doing wrong? Is something wrong with the font color in the EMF file? If it is, then why in my EMF viewers the EMF file is displayed correctly and how should I change the default font color for the MetaFile renderer?
Pages: 1