Index: /controller/wpsg_SystemController.class.php
===================================================================
--- /controller/wpsg_SystemController.class.php	(revision 8452)
+++ /controller/wpsg_SystemController.class.php	(revision 8453)
@@ -66,13 +66,12 @@
 		 * Erst mal nur Tunnel fÃŒr die Wordpress Funktion
 		 */
-		public function &get_option($key, $force_global = false)
-		{
+		public function &get_option($key, $force_global = false, ?string $default = null) {
 			
 			$return = false;
 			
-			if ($force_global)
-				$return = get_site_option($key);
-			else
-				$return = get_option($key);
+			if ($force_global) $return = get_site_option($key);
+			else $return = get_option($key);
+			
+			if ($return === false && $default !== null) $return = $default;
 
 			return $return;
Index: /mods/mod_rechnungen/eInvoice.php
===================================================================
--- /mods/mod_rechnungen/eInvoice.php	(revision 8452)
+++ /mods/mod_rechnungen/eInvoice.php	(revision 8453)
@@ -20,12 +20,25 @@
 	abstract class eInvoice {
 	
-		public static function writeEInvoice(int $order_id, int $invoice_id): void {
+		public static function buildUrl(int $invoice_id, int $profil_id): string {
+			
+			$oInvoice = wpsg_invoice::getInstance($invoice_id);
+			$oOrder = $oInvoice->getOrder();
+			
+			return html_entity_decode(wp_nonce_url(
+				WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Order&action=ajax&noheader=1&mod=wpsg_mod_rechnungen&do=getRechnung&edit_id='.$oOrder->getId().'&r_id='.$oInvoice->getId().'&profil_id='.$profil_id, 'wpsg-mod_invoice-order_ajax-getRechnung-'.$oInvoice->getId()
+			));
+			
+		}
+		
+		public static function writeEInvoice(int $order_id, int $invoice_id, int $profil_id = 0): string {
+			
+			$oInvoice = wpsg_invoice::getInstance($invoice_id);
 			
 			$shop = \wpsg_ShopController::getShop();
-			$profil_id = intval($shop->get_option('wpsg_mod_rechnungen_einvoice')) - 100;
+			
+			if ($profil_id === 0) $profil_id = intval($shop->get_option('wpsg_mod_rechnungen_einvoice')) - 100;
 			
 			if ($profil_id >= 0) {
 			
-				$oInvoice = wpsg_invoice::getInstance($invoice_id);
 				$oOrder = wpsg_order::getInstance($order_id);
 				
@@ -39,28 +52,28 @@
 					->addDocumentNote(wpsg_translate(__('Rechnung #1# zu Bestellung #2#', 'wpsg'), $oInvoice->getNr(), $oOrder->getNr()))
 					// ->setDocumentSupplyChainEvent(\DateTime::createFromFormat('Ymd', '20180305')) Lieferinformation
-					->setDocumentSeller($shop->get_option('wpsg_shopdata_name'))
+					->setDocumentSeller($shop->get_option('wpsg_shopdata_name', default: ''))
 					->addDocumentSellerContact(
-						$shop->get_option('wpsg_shopdata_owner'),
+						$shop->get_option('wpsg_shopdata_owner', default: ''),
 						null,
 						null,
 						null,
-						$shop->get_option('wpsg_shopdata_email')
+						$shop->get_option('wpsg_shopdata_email', default: '')
 					)
 					->setDocumentSellerContact(
-						$shop->get_option('wpsg_shopdata_owner'),
+						$shop->get_option('wpsg_shopdata_owner', default: ''),
 						null,
 						null,
 						null,
-						$shop->get_option('wpsg_shopdata_email')
+						$shop->get_option('wpsg_shopdata_email', default: '')
 					)
 					//->addDocumentSellerGlobalId("4000001123452", "0088")
-					->addDocumentSellerTaxRegistration("FC", $shop->get_option('wpsg_shopdata_taxnr'))
-					->addDocumentSellerTaxRegistration("VA", $shop->get_option('wpsg_shopdata_ustidnr'))
+					->addDocumentSellerTaxRegistration("FC", $shop->get_option('wpsg_shopdata_taxnr', default: ''))
+					->addDocumentSellerTaxRegistration("VA", $shop->get_option('wpsg_shopdata_ustidnr', default: ''))
 					->setDocumentSellerAddress(
-						$shop->get_option('wpsg_shopdata_street'),
+						$shop->get_option('wpsg_shopdata_street', default: ''),
 						"",
 						"",
-						$shop->get_option('wpsg_shopdata_zip'),
-						$shop->get_option('wpsg_shopdata_city'),
+						$shop->get_option('wpsg_shopdata_zip', default: ''),
+						$shop->get_option('wpsg_shopdata_city', default: ''),
 						\wpsg_country::getInstance(intval($shop->get_option('wpsg_shopdata_country')))->getShorttext()
 					)
@@ -118,11 +131,18 @@
 				
 				$pdfBuilder = new ZugferdDocumentPdfBuilder($document, $pdf_file);
-  				$pdfBuilder->generateDocument()->saveDocument($pdf_path.'e'.$oInvoice->getId().'_'.$profil_id.'.pdf');
+				
+				$pdf_path .= 'e'.$oInvoice->getId().'_'.$profil_id.'.pdf';
+				
+  				$pdfBuilder->generateDocument()->saveDocument($pdf_path);
 				 
-				\wpsg_header::PDFPlugin($pdf_path);
+				return $pdf_path;
+				
+				//\wpsg_header::PDFPlugin($pdf_path);
 				//die("OK".$pdf_path);
 				
 			}
 			
+			return $oInvoice->getFilePath();
+			
 		}
 	
Index: /mods/wpsg_mod_rechnungen.class.php
===================================================================
--- /mods/wpsg_mod_rechnungen.class.php	(revision 8452)
+++ /mods/wpsg_mod_rechnungen.class.php	(revision 8453)
@@ -609,5 +609,5 @@
 				\check_admin_referer('wpsg-mod_invoice-order_ajax-getRechnung-'.wpsg_getInt($_REQUEST['r_id']));
 				
-			 	$this->doDownload($_REQUEST['r_id']);
+			 	$this->doDownload($_REQUEST['r_id'], intval($_REQUEST['profil_id']??0));
 
 			} else if (isset($_REQUEST['do']) && $_REQUEST['do'] == 'getMultiRechnung') {
@@ -2215,28 +2215,26 @@
 		} // private function copyTemp($file, $r_id)
         
-        public function getDownloadFile($r_id) {
-
-            $oInvoice = \wpsg\wpsg_invoice::getInstance($r_id);
-            $file_path = $oInvoice->getFilePath();
-
-            header('Content-Disposition: attachment; filename="'.$file_path.'"');
-
-            return $file_path;
-
-        }
-
         /**
-         * Startet den Download einer Rechnung wird im Frontend wie im Backend verwendet
+         * Startet den Download einer Rechnung. Wird im Frontend wie im Backend verwendet
          */
-        private function doDownload($r_id) {
-
-            $file = $this->getDownloadFile($r_id);
-
-            header("Cache-Control: no-cache, must-revalidate");
-            header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
-            header('Content-type: application/pdf');
-            header('Content-Disposition: inline');
-
-            die(file_get_contents($file));
+        private function doDownload(int $r_id, int $profil_id = 0): void {
+ 
+			$oInvoice = \wpsg\wpsg_invoice::getInstance($r_id);
+			$file_path = $oInvoice->getFilePath();
+			
+			if (!file_exists($file_path)) throw new \Exception(
+				wpsg_translate(
+					__('Rechnung #1# existiert nicht im Dateisystem.', 'wpsg'), $oInvoice->getNr()
+				)
+			);
+			
+			$file_path = \wpsg\mod_invoice\eInvoice::writeEInvoice($oInvoice->getOrder()->getId(), $oInvoice->getId(), $profil_id);
+			
+			header('Content-Disposition: inline; filename="'.basename($file_path).'"');
+			header("Cache-Control: no-cache, must-revalidate");
+			header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
+			header('Content-type: application/pdf');
+			
+			readfile($file_path); exit;
 
         } // private function doDownload($r_id)
Index: /views/mods/mod_rechnungen/html/e_invoice_app.html
===================================================================
--- /views/mods/mod_rechnungen/html/e_invoice_app.html	(revision 8453)
+++ /views/mods/mod_rechnungen/html/e_invoice_app.html	(revision 8453)
@@ -0,0 +1,20 @@
+<div class="e_invoice_app" :class="{'open': open === true}" @mouseout="open = false">
+	<div class="handler" @click.prevent.stop="open = !open">
+		{{trans('E-Rechnungsdaten anhÃ€ngen')}}
+	</div>
+	<div class="layer" @mouseover="open = true" @mouseout="open = false">
+		<div class="inner">
+			<template v-for="(profile, key) of data.arProfile">
+				<a
+					:class="{
+						'default': data.default_profile === intVal(key)
+					}"
+					target="_blank"
+					:href="profile.url"
+				>
+					{{profile.label}}
+				</a>
+			</template>
+		</div>
+	</div>
+</div>
Index: /views/mods/mod_rechnungen/js/e_invoice_app.module.js
===================================================================
--- /views/mods/mod_rechnungen/js/e_invoice_app.module.js	(revision 8453)
+++ /views/mods/mod_rechnungen/js/e_invoice_app.module.js	(revision 8453)
@@ -0,0 +1,25 @@
+import { createApp } from 'https://unpkg.com/vue@3/dist/vue.esm-browser.js';
+
+export async function initEInvoiceApp(element, data) {
+
+	const template = await fetch(data.template_url).then(response => response.text());
+
+	const App = {
+		data() {
+
+			return {
+				data: data,
+				open: false
+			}
+
+		},
+		methods: {
+			intVal: function(value) { console.log(value); return parseInt(value); },
+			trans: function(strDefault)  { return strDefault; }
+		},
+		template: template
+	};
+
+	createApp(App).mount(element);
+
+}
Index: /views/mods/mod_rechnungen/order_view.phtml
===================================================================
--- /views/mods/mod_rechnungen/order_view.phtml	(revision 8452)
+++ /views/mods/mod_rechnungen/order_view.phtml	(revision 8453)
@@ -4,4 +4,6 @@
 	 * Template fÃŒr die Rechnungsmodulansicht innerhalb der Bestellansicht
 	 */
+	use horstoeko\zugferd\ZugferdProfiles;
+	use wpsg\mod_invoice\eInvoice;
 
 ?>
@@ -24,5 +26,5 @@
                     
                     ?>
-                    
+											
                     <div>
                         <?php echo $oInvoice->getDate(true); ?>
@@ -31,4 +33,31 @@
                         <?php echo $oInvoice->getNr(true); ?>
                     </div>
+					<div>
+						<div id="e_invoice_app_<?php echo $oInvoice->getId(); ?>"></div>
+						<script type="module">
+					
+							import { initEInvoiceApp } from '<?php echo wpsg_ShopController::getShop()->getRessourceURL('mods/mod_rechnungen/js/e_invoice_app.module.js'); ?>';
+
+							initEInvoiceApp(document.getElementById('e_invoice_app_<?php echo $oInvoice->getId(); ?>'), {
+								'invoice_id': <?php echo $oInvoice->getId(); ?>,
+								'template_url': '<?php echo wpsg_ShopController::getShop()->getRessourceURL('mods/mod_rechnungen/html/e_invoice_app.html'); ?>',
+								'default_profile': <?php echo intval(wpsg_ShopController::getShop()->get_option('wpsg_mod_rechnungen_einvoice')); ?>,
+								'arProfile': <?php echo json_encode([
+									100 + ZugferdProfiles::PROFILE_MINIMUM => ['label' => __('EN16931 Minimum', 'wpsg'), 'url' => eInvoice::buildUrl($oInvoice->getId(), ZugferdProfiles::PROFILE_MINIMUM)],
+									100 + ZugferdProfiles::PROFILE_BASIC => ['label' => __('EN16931 Basic', 'wpsg'), 'url' => eInvoice::buildUrl($oInvoice->getId(), ZugferdProfiles::PROFILE_BASIC)],
+									100 + ZugferdProfiles::PROFILE_BASICWL => ['label' => __('EN16931 Basic WL', 'wpsg'), 'url' => eInvoice::buildUrl($oInvoice->getId(), ZugferdProfiles::PROFILE_BASICWL)],
+									100 + ZugferdProfiles::PROFILE_EN16931 => ['label' => __('EN16931 Comfort', 'wpsg'), 'url' => eInvoice::buildUrl($oInvoice->getId(), ZugferdProfiles::PROFILE_EN16931)],
+									100 + ZugferdProfiles::PROFILE_EXTENDED => ['label' => __('EN16931 Extended', 'wpsg'), 'url' => eInvoice::buildUrl($oInvoice->getId(), ZugferdProfiles::PROFILE_EXTENDED)],
+									100 + ZugferdProfiles::PROFILE_XRECHNUNG => ['label' => __('EN16931 XRechnung 1', 'wpsg'), 'url' => eInvoice::buildUrl($oInvoice->getId(), ZugferdProfiles::PROFILE_XRECHNUNG)],
+									100 + ZugferdProfiles::PROFILE_XRECHNUNG_2 => ['label' => __('EN16931 XRechnung 2', 'wpsg'), 'url' => eInvoice::buildUrl($oInvoice->getId(), ZugferdProfiles::PROFILE_XRECHNUNG_2)],
+									100 + ZugferdProfiles::PROFILE_XRECHNUNG_2_1 => ['label' => __('EN16931 XRechnung 2.1', 'wpsg'), 'url' => eInvoice::buildUrl($oInvoice->getId(), ZugferdProfiles::PROFILE_XRECHNUNG_2_1)],
+									100 + ZugferdProfiles::PROFILE_XRECHNUNG_2_2 => ['label' => __('EN16931 XRechnung 2.2', 'wpsg'), 'url' => eInvoice::buildUrl($oInvoice->getId(), ZugferdProfiles::PROFILE_XRECHNUNG_2_2)],
+									100 + ZugferdProfiles::PROFILE_XRECHNUNG_2_3 => ['label' => __('EN16931 XRechnung 2.3', 'wpsg'), 'url' => eInvoice::buildUrl($oInvoice->getId(), ZugferdProfiles::PROFILE_XRECHNUNG_2_3)],
+									100 + ZugferdProfiles::PROFILE_XRECHNUNG_3 => ['label' => __('EN16931 XRechnung 3', 'wpsg'), 'url' => eInvoice::buildUrl($oInvoice->getId(), ZugferdProfiles::PROFILE_XRECHNUNG_3)]
+								]); ?>
+							});
+						
+						</script>
+					</div>
                     <div style="text-align:right; white-space:nowrap;">
 
@@ -57,4 +86,6 @@
                     
                 <?php } ?>
+				
+				
                 
             </div>
@@ -68,5 +99,21 @@
 <style>
     
-    #wpsg_mod_rechnungen_order_view .grid { display:grid; width:100%; grid-template-columns:150px 1fr 250px; row-gap:0.25rem; column-gap:1rem; }
+    #wpsg_mod_rechnungen_order_view .grid { display:grid; width:100%; grid-template-columns:150px 1fr 250px 150px; row-gap:0.5rem; column-gap:1rem; align-items:center; }
     
+	.e_invoice_app { position:relative; user-select:none;
+		& > .handler { border:1px solid black; padding:0.25rem 0.5rem; white-space:nowrap; text-overflow:ellipsis; overflow:hidden; width:100%; cursor:pointer; background-color:white; position:relative;
+			&:after { width:0; height:0; border-top:5px solid transparent; border-bottom:5px solid transparent; border-left:5px solid #2c699e; content:' '; position:absolute; right:5px; top:50%; transform:translateY(-50%); transition:all 0.4s; }
+		}
+		& > .layer { position:absolute; max-height:0; overflow:hidden; width:100%; transition:all 0.4s; z-index:1;
+			& > .inner { border:1px solid black; padding:0.25rem 0.5rem; margin-top:-1px; display:flex; flex-direction:column; gap:0.25rem; background-color:white;
+				& > a:not(:last-child) { border-bottom:1px solid black; }
+				& > a.default { font-weight:bold; }
+			}
+		}
+		&.open {
+			& > .layer { max-height:500px; }
+			& > .handler:after { transform:translateY(-50%) rotate(90deg); }
+		}
+	}
+	
 </style>
