0
I am making a direct print on the printer using the printdocument, now I need to use this document to generate a pdf, and view using the Windows pdf, how to pass my code to pdf.
follow the code I print with printdocumet
private void prt_implaudos_PrintPage(object sender, PrintPageEventArgs e)
{
string cabecalho = "CERTIFICADO DE ANÁLISE";
string referencia = "REFERÊNCIA: ESPECIFICAÇÃO DO FORNECEDOR";
string resultfrase = "RESULTADO: APROVADO DE ACORDO COM ESPECIFCAÇÕES DO FABRICANTE";
string data = DateTime.Now.ToString();
Pen linhaPreta = new Pen(Color.Black, 3);
Point ponto1 = new Point(30, 185);
Point ponto2 = new Point(800, 185);
Point ponto3 = new Point(30, 280);
Point ponto4 = new Point(800, 280);
Point ponto5 = new Point(30, 945);
Point ponto6 = new Point(800, 945);
Image imagem = Image.FromFile(string.Format("{0}{1}", Application.StartupPath, "\\Imagens\\logo PScor1.jpg"));
Image imagem1 = Image.FromFile(string.Format("{0}{1}", Application.StartupPath, "\\Imagens\\AssinaturaLaudo1.jpg"));
e.Graphics.DrawString(data, letra, cor, new Point(710, 950));
e.Graphics.DrawImage(imagem, 50, 0);
e.Graphics.DrawString(cabecalho, letra3, cor, new Point(280, 0));
e.Graphics.DrawLine(linhaPreta, ponto1, ponto2);
e.Graphics.DrawLine(linhaPreta, ponto3, ponto4);
e.Graphics.DrawLine(linhaPreta, ponto5, ponto6);
int f = 60;
foreach (string nota in implaudos1)
{
e.Graphics.DrawString(nota, letra, cor, new Point(600, f));
f += 15;
}
int y = 60;
foreach (string laudops in implaudos)
{
e.Graphics.DrawString(laudops, letra, cor, new Point(50, y));
y += 15;
}
int h = 90;
foreach (string laudos3 in implaudos3)
{
e.Graphics.DrawString(laudos3, letra, cor, new Point(600, h));
h += 15;
}
int g = 160;
foreach (string quimico in implaudos2)
{
e.Graphics.DrawString(quimico, letra, cor, new Point(50, g));
g += 15;
}
int b = 190;
foreach (string manu in manuseio)
{
e.Graphics.DrawString(manu, letra4, cor, new Point(50, b));
b += 15;
}
int c = 220;
foreach (string derra in derramamento)
{
e.Graphics.DrawString(derra, letra4, cor, new Point(50, c));
c += 15;
}
int d = 250;
foreach (string trata in tratamento)
{
e.Graphics.DrawString(trata, letra4, cor, new Point(50, d));
d += 15;
}
int x = 290;
foreach (string caracter in caracteristicas)
{
e.Graphics.DrawString(caracter, letra1, cor, new Point(50, x));
x += 17;
}
foreach (string caracter1 in caracteristicas1)
{
e.Graphics.DrawString(caracter1, letra2, cor, new Point(50, x));
x += 20;
}
int w = 290;
foreach (string especific in especificacoes)
{
e.Graphics.DrawString(especific, letra1, cor, new Point(280, w));
w += 17;
}
foreach (string especific1 in especificacoes1)
{
e.Graphics.DrawString(especific1, letra2, cor, new Point(280, w));
w += 20;
}
int z = 290;
foreach (string result in resultados)
{
e.Graphics.DrawString(result, letra1, cor, new Point(530, z));
z += 17;
}
foreach (string result1 in resultados1)
{
e.Graphics.DrawString(result1, letra2, cor, new Point(530, z));
z += 20;
}
int a = 290;
foreach (string metod in metodos)
{
e.Graphics.DrawString(metod, letra1, cor, new Point(680, a));
a += 17;
}
foreach (string metod1 in metodos1)
{
e.Graphics.DrawString(metod1, letra2, cor, new Point(680, a));
a += 20;
}
if (Convert.ToInt32(txt_produto.Text) == 002828 && Convert.ToInt32(txt_produto.Text) == 001019)
{
int j = 935;
foreach (string insumos1 in insumos)
{
e.Graphics.DrawString(insumos1, letra2, cor, new Point(500, j));
j += 15;
}
}
e.Graphics.DrawString(referencia, letra2, cor, new Point(50, 950));
e.Graphics.DrawString(resultfrase, letra2, cor, new Point(50, 965));
e.Graphics.DrawImage(imagem1, 150, 980);
}
Thank you so much for the attention Cypher, sorry for the mess of the code, I’m a beginner yet, but in your code above I’m wrong in two parts this request to convert to string and float (Bitmap bmp = new Bitmap(e.Graphics.Dpix, e.Graphics.Dpiy); and this other image is not finding (Ximage img = Ximage.Fromimage(bmp);
– Junior Guerreiro
You can’t find Fromimage(bmp).
– Junior Guerreiro