I am trying to print a vector image (emf file) as a PDF using the default implemented Microsoft Print To PDF printer. Right now I just create the PrintDocument
, change it's PrinterSettings
to the chosen printer Microsoft Print To PDF and change other PrintDocument
's properties.
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
pd.PrinterSettings = /*some custom printerSettings*/;
Now I basically just draw a scaled image of the emf file on a Bitmap
which I draw afterwards on pd
.
private void pd_PrintPage(object sender, PrintPageEventArgs e)
{
Bitmap printDrawing = Draw.PrintVersion(); //custom method that handles the scaled drawing
e.Graphics.DrawImage(printDrawing, new Point(0, 0));
}
In return I get a PDF file, but the issue is that the drawing on the PDf file is pixel based since I draw just a Bitmap
on pd
.
So the question is how can I solve this issue, so that the result is a PDF file which scales the vector image accordingly? So I have to skip the drawing, so I thought about just setting a filePath of the EMF file as an input for the PrintDocument
, but neither Programmatically provide a filepath nor How to programmatically print to PDF , helps me in any way, since they all focus just on drawing the content which will result again in a pixel based PrintDocument
.
So how can I set just a file/filePath as an input to the PrintDocument
to keep the vector information?