# Hidden Content

You can generate content in Kendo UI for Angular PDF Export, which is otherwise not visible to the user during the PDF export itself. The PDF Export component supports two common approaches for including hidden content in PDF exports.

<Row>
  <Column count={[24,24,12]} style={{marginBottom: "1rem"}}>
    <Component className="tile" href="#dynamic-content-rendering">
      <ComponentTitle>Dynamic Content Rendering</ComponentTitle>
      <ComponentDescription style={{padding: "0 10px 10px 10px"}}>Render content conditionally before export. Useful for logos or watermarks that load asynchronously or should only appear in the PDF.</ComponentDescription>
    </Component>
  </Column>
  <Column count={[24,24,12]} style={{marginBottom: "1rem"}}>
    <Component className="tile" href="#off-screen-positioning">
      <ComponentTitle>Off-Screen Positioning</ComponentTitle>
      <ComponentDescription style={{padding: "0 10px 10px 10px"}}>Position content off-screen using CSS so it is always rendered in the DOM but hidden from view.</ComponentDescription>
    </Component>
  </Column>
</Row>

The following example demonstrates the two approaches for including hidden content in PDF exports.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/pdf-export/off-screen/source.txt)

## Dynamic Content Rendering

You can render content conditionally by toggling its visibility just before the PDF export triggers. This approach is useful when you want to add content (such as company logos or watermarks) that is loaded asynchronously or should only appear in the exported PDF.

To export dynamically rendered hidden content:

1. Use conditional rendering [`@if`](https://angular.dev/api/core/@if#) to control when the content appears in the DOM.

   ```html
   <kendo-pdf-export #pdfExport>
       @if (showBranding) {
           <div class="company-header">
               
           </div>
       }
       <div class="invoice-content">
           
       </div>
   </kendo-pdf-export>
   ```

2. Declare a boolean flag and a [`ViewChild`](https://angular.dev/api/core/ViewChild) reference to the PDF export component.

   ```typescript
   import { ChangeDetectorRef, ViewChild } from '@angular/core';

   export class AppComponent {
       public showBranding = false;

       @ViewChild('pdfExport') public pdfExport!: PDFExportComponent;
       
       constructor(private cdr: ChangeDetectorRef) {}
   }
   ```

3. Create a custom export method that toggles the flag, forces change detection, and triggers the PDF export manually with the [`saveAs()`](https://www.telerik.com/kendo-angular-ui-develop/components/pdf-export/api/pdfexportcomponent#saveas) method.

   ```typescript
   public exportWithDynamicContent(): void {
       this.showBranding = true;
       this.cdr.detectChanges();
       this.pdfExport.saveAs('invoice.pdf');
       this.showBranding = false;
   }
   ```

## Off-Screen Positioning

With this approach, you can position content off-screen using CSS so it is always rendered in the DOM but hidden from view. This method is useful for content that does not require asynchronous loading and can be present in the DOM at all times.

To export content positioned off-screen:

1. Create a container that holds all the information you want to hide from the user.

   ```html
   <div class="off-screen-wrapper">
       <kendo-pdf-export #pdfOffscreen>
           
       </kendo-pdf-export>
   </div>
   ```

2. Position the container off-screen using CSS (for example, with `position: absolute` and `left: -9999px`).

   ```css
   .off-screen-wrapper {
       position: absolute;
       left: -9999px;
       top: 0;
   }
   ```

3. Add a `ViewChild` reference to access the PDF Export component.

   ```typescript
   import { ViewChild } from '@angular/core';

   export class AppComponent {
       @ViewChild('pdfOffscreen') public pdfOffscreen!: PDFExportComponent;
   }
   ```

4. Call the `saveAs()` method to export the PDF. The PDF Export captures all rendered HTML within the `kendo-pdf-export` tag, including both visible and hidden content.

   ```typescript
   public exportWithOffscreenContent(): void {
       this.pdfOffscreen.saveAs('document.pdf');
   }
   ```

## Suggested Links

* [Multi-Page Content in PDF Export](https://www.telerik.com/kendo-angular-ui-develop/components/pdf-export/multi-page-content)
* [Content Styling in PDF Export](https://www.telerik.com/kendo-angular-ui-develop/components/pdf-export/content-styling)
* [Embedded Fonts in PDF Export](https://www.telerik.com/kendo-angular-ui-develop/components/pdf-export/embedded-fonts)
* [API Reference of the PDF Export Component](https://www.telerik.com/kendo-angular-ui-develop/components/pdf-export/api/pdfexportcomponent)
