Set page margins generated in PDF export

Good afternoon.

I could not find in the documentation any parameters that allow me to configure the margin of the page generated in the PDF export. I found the margin of the header and the footer, and the sides very large and I would like to reduce.

5 Replies

PS Pavithra Subramaniyam Syncfusion Team March 12, 2019 10:01 AM UTC

Hi Fabiano, 
 
Greetings from Syncfusion. 
 
Query : I found the margin of the header and the footer, and the sides very large and I would like to reduce 
 
We have analyzed your query and we suggest to use the beforePdfExport event to achieve your requirement. In the below sample, we have set the margin of the exported pdf document by overriding the default processSectionExportProperties method. Please refer to the below sample and documentation for your reference, 
 
import {PdfPageSettings, PdfPageOrientation} from '@syncfusion/ej2-pdf-export' 
... 
beforeExport(args){ 
      args.gridObject.pdfExportModule.processSectionExportProperties = function (section, pdfExportProperties){ 
            let pdfPageSettings: PdfPageSettings = new PdfPageSettings(); 
            ... 
            pdfPageSettings.margins.setMargins(10); 
            section.setPageSettings(pdfPageSettings); 
         
        return section; 
 
      } 
    }... 
 
 
 
Please get back to us for further assistance. 
 
Regards, 
Pavithra S. 



FM Fabiano Melo March 12, 2019 02:53 PM UTC

Perfect. Tanks!


TS Thavasianand Sankaranarayanan Syncfusion Team March 13, 2019 04:00 AM UTC

Hi Fabiano, 
 
We are happy that the problem has been solved. 
 
Please get back to us if you need any further assistance.  
                          
Regards, 
Thavasianand S.                         



SR Shalini Rawat July 1, 2025 09:26 AM UTC

What about Images? I am getting default margins around image while using graphics.drawImage(image,0,0,width,height), even after setting x as 0 and y as 0 here, im getting margins around my image.




DM Dineshnarasimman Muthu Syncfusion Team July 3, 2025 12:01 PM UTC

Hi,


By reviewing your query, it appears you're using the graphics.drawImage() method to draw images in a PDF document, and you're observing default margins around the image despite setting the x and y coordinates to 0. To assist you effectively, could you please provide the following details?


               • PDF Export Method: Are you using default grid pdf export to perform the pdf export?

               • Library Usage: Please ensure us whether you use PDF library classes for customization during the export?

               • Code Snippet: Could you share the code snippet illustrating how you're exporting the pdfDocument?

               • Visual: Provide the image of the issue you are facing with image margins in the pdfDocument.


We highly appreciate your co-operation in providing these details.


Regards,

Dineshnarasimman M


Loader.
Up arrow icon