mirror of
				https://github.com/Nioux/AideDeJeu.git
				synced 2025-10-31 15:36:07 +00:00 
			
		
		
		
	Rollback problème génération pdf : first chance exception interne à itext sur stream, pas besoin de modifier
This commit is contained in:
		
							parent
							
								
									ba5a9de26d
								
							
						
					
					
						commit
						037ca0ae0e
					
				
					 3 changed files with 41 additions and 18 deletions
				
			
		|  | @ -137,8 +137,8 @@ namespace AideDeJeu.Pdf | ||||||
|             string fontPath = fontName; |             string fontPath = fontName; | ||||||
|             if(Xamarin.Essentials.DeviceInfo.Platform != Xamarin.Essentials.DevicePlatform.Unknown) |             if(Xamarin.Essentials.DeviceInfo.Platform != Xamarin.Essentials.DevicePlatform.Unknown) | ||||||
|             { |             { | ||||||
|                 fontPath = Path.Combine(Xamarin.Essentials.FileSystem.AppDataDirectory, fontPath); |                 //fontPath = Path.Combine(Xamarin.Essentials.FileSystem.AppDataDirectory, fontPath); | ||||||
|                 //fontPath = Path.Combine(Xamarin.Essentials.FileSystem.CacheDirectory, fontPath); |                 fontPath = Path.Combine(Xamarin.Essentials.FileSystem.CacheDirectory, fontPath); | ||||||
|             } |             } | ||||||
|             using (var inFont = AideDeJeu.Tools.Helpers.GetResourceStream($"AideDeJeu.Pdf.{fontName}")) |             using (var inFont = AideDeJeu.Tools.Helpers.GetResourceStream($"AideDeJeu.Pdf.{fontName}")) | ||||||
|             { |             { | ||||||
|  | @ -149,8 +149,8 @@ namespace AideDeJeu.Pdf | ||||||
|             } |             } | ||||||
|             FontFactory.Register(fontPath); |             FontFactory.Register(fontPath); | ||||||
| 
 | 
 | ||||||
|             //return iTextSharp.text.pdf.BaseFont.CreateFont(fontPath, iTextSharp.text.pdf.BaseFont.IDENTITY_H, iTextSharp.text.pdf.BaseFont.EMBEDDED, true, null, null, true, true); |             return iTextSharp.text.pdf.BaseFont.CreateFont(fontPath, iTextSharp.text.pdf.BaseFont.IDENTITY_H, iTextSharp.text.pdf.BaseFont.EMBEDDED); | ||||||
|             return iTextSharp.text.pdf.BaseFont.CreateFont(); |             //return iTextSharp.text.pdf.BaseFont.CreateFont(); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         BaseFont _CinzelRegular = null; |         BaseFont _CinzelRegular = null; | ||||||
|  |  | ||||||
|  | @ -1268,16 +1268,16 @@ namespace AideDeJeu.ViewModels.PlayerCharacter | ||||||
|                     var form = stamper.AcroFields; |                     var form = stamper.AcroFields; | ||||||
|                     var fields = form.Fields; |                     var fields = form.Fields; | ||||||
| #if DEBUG | #if DEBUG | ||||||
|                     foreach (DictionaryEntry field in fields) |                     //foreach (DictionaryEntry field in fields) | ||||||
|                     { |                     //{ | ||||||
|                         var item = field.Value as AcroFields.Item; |                     //    var item = field.Value as AcroFields.Item; | ||||||
|                         Debug.WriteLine(field.Key); |                     //    Debug.WriteLine(field.Key); | ||||||
|                         if (field.Key.ToString().Equals("Portrait")) |                     //    if (field.Key.ToString().Equals("Portrait")) | ||||||
|                         { |                     //    { | ||||||
|                             Debug.WriteLine("Portrait"); |                     //        Debug.WriteLine("Portrait"); | ||||||
|                         } |                     //    } | ||||||
|                         form.SetField(field.Key.ToString(), field.Key.ToString()); |                     //    form.SetField(field.Key.ToString(), field.Key.ToString()); | ||||||
|                     } |                     //} | ||||||
| #endif // DEBUG | #endif // DEBUG | ||||||
| 
 | 
 | ||||||
|                     form.SetField("Nom", SelectedPlayerCharacter?.Name ?? string.Empty); |                     form.SetField("Nom", SelectedPlayerCharacter?.Name ?? string.Empty); | ||||||
|  | @ -1379,6 +1379,27 @@ namespace AideDeJeu.ViewModels.PlayerCharacter | ||||||
|         }; |         }; | ||||||
|         #endregion Level |         #endregion Level | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |         public Command PdfViewCommand | ||||||
|  |         { | ||||||
|  |             get | ||||||
|  |             { | ||||||
|  |                 return new Command<PlayerCharacterViewModel>(async (pc) => await ExecutePdfViewCommandAsync(pc)); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         public async Task ExecutePdfViewCommandAsync(PlayerCharacterViewModel pc) | ||||||
|  |         { | ||||||
|  |             //var vm = BindingContext as PlayerCharacterEditorViewModel; | ||||||
|  |             var page = new Views.PlayerCharacter.PdfViewPage(); | ||||||
|  |             page.PdfFile = new Tools.NotifyTaskCompletion<string>(Task.Run(async () => await GeneratePdfAsync(pc))); | ||||||
|  |             page.BindingContext = page; | ||||||
|  |             //Navigation.PushModalAsync(page, true); | ||||||
|  |             await Shell.Current.Navigation.PushAsync(page, true); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -4,8 +4,10 @@ | ||||||
|              xmlns:tools="clr-namespace:AideDeJeu.Tools" |              xmlns:tools="clr-namespace:AideDeJeu.Tools" | ||||||
|              xmlns:mdview="clr-namespace:Xam.Forms.Markdown" |              xmlns:mdview="clr-namespace:Xam.Forms.Markdown" | ||||||
|              xmlns:pickers="clr-namespace:AideDeJeu.Views.Pickers" |              xmlns:pickers="clr-namespace:AideDeJeu.Views.Pickers" | ||||||
|  |              xmlns:pcvm="clr-namespace:AideDeJeu.ViewModels.PlayerCharacter" | ||||||
|              x:Class="AideDeJeu.Views.PlayerCharacter.RacePage" |              x:Class="AideDeJeu.Views.PlayerCharacter.RacePage" | ||||||
|              x:Name="This"> |              x:Name="This" | ||||||
|  |              x:DataType="pcvm:PlayerCharacterEditorViewModel"> | ||||||
|     <ContentPage.Resources> |     <ContentPage.Resources> | ||||||
|         <ResourceDictionary> |         <ResourceDictionary> | ||||||
|             <tools:MonsterMarkdownTheme x:Key="MonsterMarkdownTheme" /> |             <tools:MonsterMarkdownTheme x:Key="MonsterMarkdownTheme" /> | ||||||
|  | @ -13,7 +15,7 @@ | ||||||
|         </ResourceDictionary> |         </ResourceDictionary> | ||||||
|     </ContentPage.Resources> |     </ContentPage.Resources> | ||||||
|     <ContentPage.ToolbarItems> |     <ContentPage.ToolbarItems> | ||||||
|         <ToolbarItem Name="Print" Text="Générer un PDF" Order="Primary" Icon="scroll_unfurled.png" Command="{Binding PdfViewCommand, Source={x:Reference This}}" CommandParameter="{Binding SelectedPlayerCharacter}" /> |         <ToolbarItem Name="Print" Text="Générer un PDF" Order="Primary" Icon="scroll_unfurled.png" Command="{Binding PdfViewCommand}" CommandParameter="{Binding SelectedPlayerCharacter}" /> | ||||||
|     </ContentPage.ToolbarItems> |     </ContentPage.ToolbarItems> | ||||||
|     <ContentPage.Content> |     <ContentPage.Content> | ||||||
|         <ScrollView Grid.ColumnSpan="2" Orientation="Vertical"> |         <ScrollView Grid.ColumnSpan="2" Orientation="Vertical"> | ||||||
|  | @ -46,8 +48,8 @@ | ||||||
|                             <BindableLayout.ItemTemplate> |                             <BindableLayout.ItemTemplate> | ||||||
|                                 <DataTemplate> |                                 <DataTemplate> | ||||||
|                                     <StackLayout> |                                     <StackLayout> | ||||||
|                                         <mdview:MarkdownView Theme="{StaticResource MonsterMarkdownTheme}" Markdown="{Binding Value.Key, StringFormat='#### {0}'}" /> |                                         <!--<mdview:MarkdownView Theme="{StaticResource MonsterMarkdownTheme}" Markdown="{Binding Value.Key, StringFormat='#### {0}'}" /> | ||||||
|                                         <mdview:MarkdownView Theme="{StaticResource MonsterMarkdownTheme}" Markdown="{Binding Value.Value}" /> |                                         <mdview:MarkdownView Theme="{StaticResource MonsterMarkdownTheme}" Markdown="{Binding Value.Value}" />--> | ||||||
|                                     </StackLayout> |                                     </StackLayout> | ||||||
|                                 </DataTemplate> |                                 </DataTemplate> | ||||||
|                             </BindableLayout.ItemTemplate> |                             </BindableLayout.ItemTemplate> | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Yan Maniez
						Yan Maniez