The folowing code generates two pdf files, one with Draw("file") (y.pdf) method and other with byte[] = Draw() method (x.pdf).
The y.pdf can open with PDF readear but the x.pdf can open but the file is empty.
When try to close x.pdf (from adbobe pdf) system ask to me if I want to save cahnges.
I need the byte[] method to save the pdf in a sql table.
Any idea?
/*--------------------------------*/
Document document = new Document();
Page page = new Page();
page.Elements.Add(new ceTe.DynamicPDF.PageElements.Label("Informe PDF 890", 0, 0, 100, 12, ceTe.DynamicPDF.Font.Helvetica, 12));
document.Pages.Add(page);
byte[] fpdf = document.Draw();
document.Draw("C:\\y.pdf");
StreamWriter fichero = new StreamWriter("C:\\x.pdf", false);
fichero.Write(Encoding.Default.GetString(fpdf));
fichero.Close();
draw method options
Re: draw method options
Support · Jun 17, 2008Hello,
You will have to use the Unicode encoding when writing the file to disk using the StreamWriter. Following is the sample for this.
StreamWriter fichero = new StreamWriter("C:\\Temp\\x.pdf", false, Encoding.Unicode);
fichero.Write(Encoding.Unicode.GetString(fpdf));
fichero.Close();
You can also use the FileStream to write the file.
FileStream fs = new FileStream("C:\\Temp\\x.pdf", FileMode.CreateNew);
fs.Write(fpdf, 0, fpdf.Length);
fs.Close();
You can save the PDF data in a database table without any problem.
Thanks,
ceTe Software Support Team.