1-) C# WebForm DevExpress - gridview i yazdırmak print etmek pdf olarak
açıklama = ASPxGridViewExporter1 ekle. -> GRİDVİEWİN ÜSTÜNE AT OTOMATİK OLUYOR TAM ANLAMADIM AMA.
kaynak = https://github.com/DevExpress-Examples/aspxgridviewexporter-how-to-fit-exported-document-to-page-e3994/blob/13.1.4%2B/CS/WebApplication1/Default.aspx.cs
protected void btnYazdir_Click(object sender, EventArgs e)
{
using (MemoryStream ms = new MemoryStream())
{
PrintableComponentLink pcl = new PrintableComponentLink(new PrintingSystem());
pcl.Component = ASPxGridViewExporter1;
pcl.Margins.Left = pcl.Margins.Right = 50;
pcl.Landscape = true;
pcl.CreateDocument(false);
pcl.PrintingSystem.Document.AutoFitToPagesWidth = 1;
pcl.ExportToPdf(ms);// ÇOK ÇOK ÖNEMLİ buraya göre çıktı alırsın
WriteResponse(this.Response, ms.ToArray(), System.Net.Mime.DispositionTypeNames.Inline.ToString());
}
}
public static void WriteResponse(HttpResponse response, byte[] filearray, string type)
{
response.ClearContent();
response.Buffer = true;
response.Cache.SetCacheability(HttpCacheability.Private);
response.ContentType = "application/pdf";// ÇOK ÇOK ÖNEMLİ buraya göre çıktı alırsın
ContentDisposition contentDisposition = new ContentDisposition();
contentDisposition.FileName = "test.pdf";// ÇOK ÇOK ÖNEMLİ buraya göre çıktı alırsın
contentDisposition.DispositionType = type;
response.AddHeader("Content-Disposition", contentDisposition.ToString());
response.BinaryWrite(filearray);
HttpContext.Current.ApplicationInstance.CompleteRequest();
try
{
response.End();
}
catch (System.Threading.ThreadAbortException)
{
}
}