Dear how do I make the first page without header and footer? because the first page would be a cover..
I placed the header and footer as described below... but it stays on all pages, the first one I want it not to have a header and footer...
could someone help me with this?
We suggest adding a section and adding only the cover page to the pdf document and adding the other pages to the individual section of the pdf document and adding header and footer to this section of this PDF document.
//Create a PDF document PdfDocument document = PdfDocument(); //Set the font PdfFont font = PdfStandardFont(PdfFontFamily.helvetica, 14); //Section - 1 //Add section to the document PdfSection section = document.sections!.add(); //Create page settings to the section section.pageSettings.rotate = PdfPageRotateAngle.rotateAngle0; section.pageSettings.size = const Size(300, 400); //Draw simple text on the page section.pages.add().graphics.drawString('Rotated by 0 degrees', font, brush: PdfBrushes.black, bounds: const Rect.fromLTWH(20, 20, 0, 0)); //Create the header with specific bounds PdfPageTemplateElement header = PdfPageTemplateElement( Rect.fromLTWH(0, 0, document.pageSettings.size.width, 100)); //Create the date and time field PdfDateTimeField dateAndTimeField = PdfDateTimeField( font: PdfStandardFont(PdfFontFamily.timesRoman, 19), brush: PdfSolidBrush(PdfColor(0, 0, 0))); dateAndTimeField.date = DateTime(2020, 2, 10, 13, 13, 13, 13, 13); dateAndTimeField.dateFormatString = 'E, MM.dd.yyyy'; //Create the composite field with date field PdfCompositeField compositefields = PdfCompositeField( font: PdfStandardFont(PdfFontFamily.timesRoman, 19), brush: PdfSolidBrush(PdfColor(0, 0, 0)), text: '{0} Header', fields: <PdfAutomaticField>[dateAndTimeField]); //Add composite field in header compositefields.draw(header.graphics, Offset(0, 50 - PdfStandardFont(PdfFontFamily.timesRoman, 11).height)); //Add the header at top of the document section.template.top = header; //Create the footer with specific bounds PdfPageTemplateElement footer = PdfPageTemplateElement( Rect.fromLTWH(0, 0, document.pageSettings.size.width, 50)); //Create the page number field PdfPageNumberField pageNumber = PdfPageNumberField( font: PdfStandardFont(PdfFontFamily.timesRoman, 19), brush: PdfSolidBrush(PdfColor(0, 0, 0))); //Sets the number style for page number pageNumber.numberStyle = PdfNumberStyle.upperRoman; //Create the page count field PdfPageCountField count = PdfPageCountField( font: PdfStandardFont(PdfFontFamily.timesRoman, 19), brush: PdfSolidBrush(PdfColor(0, 0, 0))); //set the number style for page count count.numberStyle = PdfNumberStyle.upperRoman; //Create the date and time field PdfDateTimeField dateTimeField = PdfDateTimeField( font: PdfStandardFont(PdfFontFamily.timesRoman, 19), brush: PdfSolidBrush(PdfColor(0, 0, 0))); //Sets the date and time dateTimeField.date = DateTime(2020, 2, 10, 13, 13, 13, 13, 13); //Sets the date and time format dateTimeField.dateFormatString = 'hh\':\'mm\':\'ss'; //Create the composite field with page number page count PdfCompositeField compositeField = PdfCompositeField( font: PdfStandardFont(PdfFontFamily.timesRoman, 19), brush: PdfSolidBrush(PdfColor(0, 0, 0)), text: 'Page {0} of {1}, Time:{2}', fields: <PdfAutomaticField>[pageNumber, count, dateTimeField]); compositeField.bounds = footer.bounds; //Add the composite field in footer compositeField.draw(footer.graphics, Offset(290, 50 - PdfStandardFont(PdfFontFamily.timesRoman, 19).height)); //Add the footer at the bottom of the document section.template.bottom = footer; //Section - 2 //Add section to the document section = document.sections!.add(); //Create page settings to the section section.pageSettings.rotate = PdfPageRotateAngle.rotateAngle90; section.pageSettings.size = const Size(300, 400); //Draw simple text on the page section.pages.add().graphics.drawString('Rotated by 90 degrees', font, brush: PdfBrushes.black, bounds: const Rect.fromLTWH(20, 20, 0, 0)); //Section - 3 //Add section to the document section = document.sections!.add(); //Create page settings to the section section.pageSettings.rotate = PdfPageRotateAngle.rotateAngle180; section.pageSettings.size = const Size(500, 200); //Draw simple text on the page section.pages.add().graphics.drawString('Rotated by 180 degrees', font, brush: PdfBrushes.black, bounds: const Rect.fromLTWH(20, 20, 0, 0)); //Section - 4 //Add section to the document section = document.sections!.add(); //Create page settings to the section section.pageSettings.rotate = PdfPageRotateAngle.rotateAngle270; section.pageSettings.size = const Size(300, 200); //Draw simple text on the page section.pages.add().graphics.drawString('Rotated by 270 degrees', font, brush: PdfBrushes.black, bounds: const Rect.fromLTWH(20, 20, 0, 0)); |
Follow the below links for more information,
https://help.syncfusion.com/flutter/pdf/working-with-headers-and-footers
thanks for the answer... your support is excellent...
I will try what you proposed here