How to place barcode above table?
Im use this code for create pdf document from sfdatargid.
//begin
PdfPage page = document.Pages.Add();
PdfLayer layer = document.Layers.Add("Layer");
PdfGraphics graphics = layer.CreateGraphics(page);
RectangleF bounds = new RectangleF(0, 0, document.Pages[0].GetClientSize().Width, 40);
PdfPageTemplateElement header = new PdfPageTemplateElement(bounds);
PdfImage image = new PdfBitmap(@"logo.png");
header.Graphics.DrawImage(image, new PointF(0, 0), new SizeF(150, 30));
document.Template.Top = header;
//Barcode
PdfCode128BBarcode barcode = new PdfCode128BBarcode();
barcode.Text = "VVPU DPO";
barcode.TextDisplayLocation = TextLocation.Top;
barcode.BarHeight = 30;
barcode.Draw(page, new PointF(600, 0));
PdfLayer layer = document.Layers.Add("Layer");
PdfGraphics graphics = layer.CreateGraphics(page);
RectangleF bounds = new RectangleF(0, 0, document.Pages[0].GetClientSize().Width, 40);
PdfPageTemplateElement header = new PdfPageTemplateElement(bounds);
PdfImage image = new PdfBitmap(@"logo.png");
header.Graphics.DrawImage(image, new PointF(0, 0), new SizeF(150, 30));
document.Template.Top = header;
//Barcode
PdfCode128BBarcode barcode = new PdfCode128BBarcode();
barcode.Text = "VVPU DPO";
barcode.TextDisplayLocation = TextLocation.Top;
barcode.BarHeight = 30;
barcode.Draw(page, new PointF(600, 0));
//end
How it works can be seen in the screenshot. The logo is placed in the upper left corner of the page, and the barcode should be on the right. But it's not like that...

SIGN IN To post a reply.
5 Replies
1 reply marked as answer
MA
Mohanram Anbukkarasu
Syncfusion Team
March 22, 2021 12:44 PM UTC
Hi ruslik,
Thanks for contacting Syncfusion support.
You can achieve this requirement by using ExportToPdfGrid method as shown in the following code example.
Code example :
|
//Create a new PDF document
PdfDocument pdfDocument = new PdfDocument();
var options = new PdfExportingOptions();
var pdfPage = pdfDocument.Pages.Add();
var PDFGrid = sfDataGrid.ExportToPdfGrid(sfDataGrid.View, options);
var format = new PdfGridLayoutFormat()
{
Layout = PdfLayoutType.Paginate,
Break = PdfLayoutBreakType.FitPage
};
PDFGrid.Draw(pdfPage, new PointF(0, 100), format);
//Create a header and draw the image
RectangleF bounds = new RectangleF(0, 0, pdfDocument.Pages[0].GetClientSize().Width, 50);
PdfPageTemplateElement header = new PdfPageTemplateElement(bounds);
PdfImage image = new PdfBitmap(@"../../Data/Logo.png");
//Draw the image in the header
header.Graphics.DrawImage(image, new PointF(0, 0), new SizeF(100, 50));
//Add the header at the top
pdfDocument.Template.Top = header;
//Barcode
PdfCode128BBarcode barcode = new PdfCode128BBarcode();
barcode.Text = "VVPU DPO";
barcode.TextDisplayLocation = TextLocation.Bottom;
barcode.BarHeight = 30;
barcode.Draw(pdfPage, new PointF(400, 0));
//Save and close the document
pdfDocument.Save("Output.pdf");
pdfDocument.Close(true);
Process.Start("Output.pdf"); |
Please let us know if you require further assistance from us.
Regards,
Mohanram A.
RU
ruslik
March 23, 2021 09:22 AM UTC
That's all well and good, but the logo is printed on every page. How to display it only on the first.
And there is no Cyrillic in your fonts for headings.
I attach an example of a finished file.
Attachment: list_of_students_a88efcd2.rar
RU
ruslik
March 23, 2021 10:11 AM UTC
I tried using the repeat headers option, but it doesn't work. And why does my connected font not have the same style as it should be.

MA
Mohanram Anbukkarasu
Syncfusion Team
March 24, 2021 02:11 PM UTC
Hi ruslik,
Thanks for the update.
We are currently validating this. We will check and update with further details on March 26, 2021. We appreciate your patience until then.
Regards,
Mohanram A.
MA
Mohanram Anbukkarasu
Syncfusion Team
March 26, 2021 10:24 AM UTC
Hi ruslik,
Thanks for your patience.
We have prepared a sample to print the logo only on the first page of the pdf and it available in the following link for your reference.
Sample link : https://www.syncfusion.com/downloads/support/forum/163740/ze/ExportToPdf_Modified723614000
Please let us know if you require further assistance from us.
Regards,
Mohanram A.
Marked as answer
SIGN IN To post a reply.
- 5 Replies
- 2 Participants
- Marked answer
-
RU ruslik
- Mar 20, 2021 12:38 PM UTC
- Mar 26, 2021 10:24 AM UTC