First, create a separate page specifically for PDF generation. This page will only be used to generate the PDF and won’t be opened directly by users. You can name it something like MyEntity_PDF.
On this page, wrap everything inside an outer container and give it a class name, for example pdf-export. Any PDF-specific CSS will be written under this class.
Place the content you want to show in the PDF on this page. You can use the same data as the UI page, but in most cases a simpler layout (fewer widgets, less nesting) works much better for PDFs.
Then, in the microflow that generates the PDF, select this PDF page as the “page to render” instead of the normal UI page. If needed, pass the same context object as a page parameter.
On the CSS side, add overrides that target only the PDF, using the pdf-export class. Since this class exists only on the PDF page, the normal UI will not be affected.
This behavior is expected in Mendix: Data Grid 2 applies print/PDF default styles that add gray borders during PDF rendering, even if no borders are visible on the page. Data Grid 2 is not recommended for PDF generation. The best practice is to generate PDFs using a Document Template with tables or List Views for full styling control; alternatively, you can remove the borders using PDF-specific (@media print) CSS, but this approach is less reliable.
or
Override PDF-specific CSS
If you must keep using Data Grid 2:
Add custom CSS that only applies during print/PDF rendering.
Example:
@media print {
.mx-datagrid,
.mx-datagrid table,
.mx-datagrid th,
.mx-datagrid td {
border: none !important;
}
}