mirror of
https://github.com/Nioux/AideDeJeu.git
synced 2025-10-30 15:06:06 +00:00
Embed font in pdf ;)
This commit is contained in:
parent
fdf4601cc5
commit
a5e0f52265
12 changed files with 63 additions and 14 deletions
|
|
@ -23,6 +23,12 @@
|
||||||
<None Remove="Pdf\178_hd_01_feuille_de_perso_v1.pdf" />
|
<None Remove="Pdf\178_hd_01_feuille_de_perso_v1.pdf" />
|
||||||
<None Remove="Pdf\AlverataIrregularPEMedium.ttf" />
|
<None Remove="Pdf\AlverataIrregularPEMedium.ttf" />
|
||||||
<None Remove="Pdf\BLKCHCRY.TTF" />
|
<None Remove="Pdf\BLKCHCRY.TTF" />
|
||||||
|
<None Remove="Pdf\Cinzel-Black.otf" />
|
||||||
|
<None Remove="Pdf\Cinzel-Bold.otf" />
|
||||||
|
<None Remove="Pdf\Cinzel-Regular.otf" />
|
||||||
|
<None Remove="Pdf\CinzelDecorative-Black.otf" />
|
||||||
|
<None Remove="Pdf\CinzelDecorative-Bold.otf" />
|
||||||
|
<None Remove="Pdf\CinzelDecorative-Regular.otf" />
|
||||||
<None Remove="Pdf\feuille_de_personnage_editable.pdf" />
|
<None Remove="Pdf\feuille_de_personnage_editable.pdf" />
|
||||||
<None Remove="Pdf\LinLibertine_aBL.ttf" />
|
<None Remove="Pdf\LinLibertine_aBL.ttf" />
|
||||||
<None Remove="Pdf\LinLibertine_aBS.ttf" />
|
<None Remove="Pdf\LinLibertine_aBS.ttf" />
|
||||||
|
|
@ -40,6 +46,7 @@
|
||||||
<None Remove="Pdf\LinLibertine_RI.ttf" />
|
<None Remove="Pdf\LinLibertine_RI.ttf" />
|
||||||
<None Remove="Pdf\LinLibertine_RZ.ttf" />
|
<None Remove="Pdf\LinLibertine_RZ.ttf" />
|
||||||
<None Remove="Pdf\LinLibertine_RZI.ttf" />
|
<None Remove="Pdf\LinLibertine_RZI.ttf" />
|
||||||
|
<None Remove="Pdf\MarcellusSC-Regular.ttf" />
|
||||||
<None Remove="Pdf\MinionPro_It.ttf" />
|
<None Remove="Pdf\MinionPro_It.ttf" />
|
||||||
<None Remove="Pdf\poker_size.pdf" />
|
<None Remove="Pdf\poker_size.pdf" />
|
||||||
<None Remove="test.svg" />
|
<None Remove="test.svg" />
|
||||||
|
|
@ -50,6 +57,12 @@
|
||||||
<EmbeddedResource Include="Pdf\178_hd_01_feuille_de_perso_v1.pdf" />
|
<EmbeddedResource Include="Pdf\178_hd_01_feuille_de_perso_v1.pdf" />
|
||||||
<EmbeddedResource Include="Pdf\AlverataIrregularPEMedium.ttf" />
|
<EmbeddedResource Include="Pdf\AlverataIrregularPEMedium.ttf" />
|
||||||
<EmbeddedResource Include="Pdf\BLKCHCRY.TTF" />
|
<EmbeddedResource Include="Pdf\BLKCHCRY.TTF" />
|
||||||
|
<EmbeddedResource Include="Pdf\Cinzel-Black.otf" />
|
||||||
|
<EmbeddedResource Include="Pdf\Cinzel-Bold.otf" />
|
||||||
|
<EmbeddedResource Include="Pdf\Cinzel-Regular.otf" />
|
||||||
|
<EmbeddedResource Include="Pdf\CinzelDecorative-Black.otf" />
|
||||||
|
<EmbeddedResource Include="Pdf\CinzelDecorative-Bold.otf" />
|
||||||
|
<EmbeddedResource Include="Pdf\CinzelDecorative-Regular.otf" />
|
||||||
<EmbeddedResource Include="Pdf\feuille_de_personnage_editable.pdf" />
|
<EmbeddedResource Include="Pdf\feuille_de_personnage_editable.pdf" />
|
||||||
<EmbeddedResource Include="Pdf\LinLibertine_aBL.ttf" />
|
<EmbeddedResource Include="Pdf\LinLibertine_aBL.ttf" />
|
||||||
<EmbeddedResource Include="Pdf\LinLibertine_aBS.ttf" />
|
<EmbeddedResource Include="Pdf\LinLibertine_aBS.ttf" />
|
||||||
|
|
@ -67,6 +80,7 @@
|
||||||
<EmbeddedResource Include="Pdf\LinLibertine_RI.ttf" />
|
<EmbeddedResource Include="Pdf\LinLibertine_RI.ttf" />
|
||||||
<EmbeddedResource Include="Pdf\LinLibertine_RZ.ttf" />
|
<EmbeddedResource Include="Pdf\LinLibertine_RZ.ttf" />
|
||||||
<EmbeddedResource Include="Pdf\LinLibertine_RZI.ttf" />
|
<EmbeddedResource Include="Pdf\LinLibertine_RZI.ttf" />
|
||||||
|
<EmbeddedResource Include="Pdf\MarcellusSC-Regular.ttf" />
|
||||||
<EmbeddedResource Include="Pdf\MinionPro_It.ttf" />
|
<EmbeddedResource Include="Pdf\MinionPro_It.ttf" />
|
||||||
<EmbeddedResource Include="Pdf\poker_size.pdf" />
|
<EmbeddedResource Include="Pdf\poker_size.pdf" />
|
||||||
<EmbeddedResource Include="test.svg" />
|
<EmbeddedResource Include="test.svg" />
|
||||||
|
|
|
||||||
BIN
AideDeJeu/AideDeJeu/Pdf/Cinzel-Black.otf
Normal file
BIN
AideDeJeu/AideDeJeu/Pdf/Cinzel-Black.otf
Normal file
Binary file not shown.
BIN
AideDeJeu/AideDeJeu/Pdf/Cinzel-Bold.otf
Normal file
BIN
AideDeJeu/AideDeJeu/Pdf/Cinzel-Bold.otf
Normal file
Binary file not shown.
BIN
AideDeJeu/AideDeJeu/Pdf/Cinzel-Regular.otf
Normal file
BIN
AideDeJeu/AideDeJeu/Pdf/Cinzel-Regular.otf
Normal file
Binary file not shown.
BIN
AideDeJeu/AideDeJeu/Pdf/CinzelDecorative-Black.otf
Normal file
BIN
AideDeJeu/AideDeJeu/Pdf/CinzelDecorative-Black.otf
Normal file
Binary file not shown.
BIN
AideDeJeu/AideDeJeu/Pdf/CinzelDecorative-Bold.otf
Normal file
BIN
AideDeJeu/AideDeJeu/Pdf/CinzelDecorative-Bold.otf
Normal file
Binary file not shown.
BIN
AideDeJeu/AideDeJeu/Pdf/CinzelDecorative-Regular.otf
Normal file
BIN
AideDeJeu/AideDeJeu/Pdf/CinzelDecorative-Regular.otf
Normal file
Binary file not shown.
BIN
AideDeJeu/AideDeJeu/Pdf/MarcellusSC-Regular.ttf
Normal file
BIN
AideDeJeu/AideDeJeu/Pdf/MarcellusSC-Regular.ttf
Normal file
Binary file not shown.
|
|
@ -54,10 +54,37 @@ namespace AideDeJeu.Pdf
|
||||||
//stamper.Close();
|
//stamper.Close();
|
||||||
//reader.Close();
|
//reader.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Font ParagraphFont = null;
|
||||||
private void Render(IEnumerable<Block> blocks, Document document)
|
private void Render(IEnumerable<Block> blocks, Document document)
|
||||||
{
|
{
|
||||||
|
if(ParagraphFont == null)
|
||||||
|
{
|
||||||
|
//var fontPath = Path.Combine(Xamarin.Essentials.FileSystem.CacheDirectory, "Cinzel-Regular.otf");
|
||||||
|
var fontPath = @"C:\Users\yanma\Documents\Visual Studio 2017\Projects\AideDeJeu\AideDeJeu\AideDeJeuCmd\bin\Debug\netcoreapp2.1\Cinzel-Regular.otf";
|
||||||
|
using (var inFont = AideDeJeu.Tools.Helpers.GetResourceStream("AideDeJeu.Pdf.Cinzel-Regular.otf"))
|
||||||
|
{
|
||||||
|
using (var outFont = new FileStream(fontPath, FileMode.Create, FileAccess.ReadWrite))
|
||||||
|
{
|
||||||
|
inFont.CopyTo(outFont);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FontFactory.Register(fontPath);
|
||||||
|
|
||||||
|
//var mafont = FontFactory.GetFont("cinzel", 20, iTextSharp.text.Font.NORMAL);
|
||||||
|
var mafont = iTextSharp.text.pdf.BaseFont.CreateFont(fontPath, iTextSharp.text.pdf.BaseFont.IDENTITY_H, iTextSharp.text.pdf.BaseFont.EMBEDDED);
|
||||||
|
//var font = mafont.BaseFont;
|
||||||
|
var bigFont = new iTextSharp.text.Font(mafont, 20);
|
||||||
|
|
||||||
|
var fonts = FontFactory.RegisteredFonts;
|
||||||
|
|
||||||
|
ParagraphFont = bigFont;
|
||||||
|
}
|
||||||
var phrases = Render(blocks);
|
var phrases = Render(blocks);
|
||||||
|
|
||||||
|
|
||||||
ColumnText ct = new ColumnText(_Writer.DirectContent);
|
ColumnText ct = new ColumnText(_Writer.DirectContent);
|
||||||
|
|
||||||
int column = 0;
|
int column = 0;
|
||||||
ct.SetSimpleColumn(10, 10 + 200 * column, 200, 200 + 200 * column);
|
ct.SetSimpleColumn(10, 10 + 200 * column, 200, 200 + 200 * column);
|
||||||
int status = 0;
|
int status = 0;
|
||||||
|
|
@ -65,21 +92,26 @@ namespace AideDeJeu.Pdf
|
||||||
float y = 0;
|
float y = 0;
|
||||||
foreach (var phrase in phrases)
|
foreach (var phrase in phrases)
|
||||||
{
|
{
|
||||||
|
//var pphrase = new Phrase("test", bigFont);
|
||||||
|
phrase.Font = ParagraphFont;
|
||||||
y = ct.YLine;
|
y = ct.YLine;
|
||||||
|
|
||||||
//document.Add(phrase);
|
document.Add(phrase);
|
||||||
ct.AddText(phrase);
|
//ct.AddText(phrase);
|
||||||
status = ct.Go(true);
|
//status = ct.Go(true);
|
||||||
if(ColumnText.HasMoreText(status))
|
//if(ColumnText.HasMoreText(status))
|
||||||
{
|
//{
|
||||||
|
|
||||||
|
// column++;
|
||||||
|
// ct.SetSimpleColumn(10, 10 + 200 * column, 200, 200 + 200 * column);
|
||||||
|
// y += 200;
|
||||||
|
//}
|
||||||
|
//ct.YLine = y;
|
||||||
|
//ct.SetText(phrase);
|
||||||
|
//status = ct.Go(false);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
column++;
|
|
||||||
ct.SetSimpleColumn(10, 10 + 200 * column, 200, 200 + 200 * column);
|
|
||||||
y += 200;
|
|
||||||
}
|
|
||||||
ct.YLine = y;
|
|
||||||
ct.SetText(phrase);
|
|
||||||
status = ct.Go(false);
|
|
||||||
//ColumnText ct = new ColumnText(_Writer.DirectContent);
|
//ColumnText ct = new ColumnText(_Writer.DirectContent);
|
||||||
//ct.AddText(CreateFormatted(block.Inline, Font.HELVETICA, 0, new Color(0, 0, 0), 12));
|
//ct.AddText(CreateFormatted(block.Inline, Font.HELVETICA, 0, new Color(0, 0, 0), 12));
|
||||||
//ct.Alignment = Element.ALIGN_JUSTIFIED;
|
//ct.Alignment = Element.ALIGN_JUSTIFIED;
|
||||||
|
|
@ -190,7 +222,7 @@ namespace AideDeJeu.Pdf
|
||||||
new Chunk()
|
new Chunk()
|
||||||
{
|
{
|
||||||
Content = literal.Content.Text.Substring(literal.Content.Start, literal.Content.Length),
|
Content = literal.Content.Text.Substring(literal.Content.Start, literal.Content.Length),
|
||||||
Font = new Font(fontFamily, fontSize, fontStyle, fontColor)
|
Font = ParagraphFont, //new Font(fontFamily, fontSize, fontStyle, fontColor)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
case EmphasisInline emphasis:
|
case EmphasisInline emphasis:
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.4" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.4" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.4" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.4" />
|
||||||
<PackageReference Include="sqlite-net-pcl" Version="1.6.258-beta" />
|
<PackageReference Include="sqlite-net-pcl" Version="1.6.258-beta" />
|
||||||
|
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.5.1" />
|
||||||
<PackageReference Include="Xamarin.Essentials" Version="1.1.0" />
|
<PackageReference Include="Xamarin.Essentials" Version="1.1.0" />
|
||||||
<PackageReference Include="Xamarin.Forms" Version="4.0.0.497661" />
|
<PackageReference Include="Xamarin.Forms" Version="4.0.0.497661" />
|
||||||
<PackageReference Include="XamiTextSharpLGPLv2" Version="1.0.0" />
|
<PackageReference Include="XamiTextSharpLGPLv2" Version="1.0.0" />
|
||||||
|
|
|
||||||
|
|
@ -753,6 +753,7 @@ namespace AideDeJeuCmd
|
||||||
Tests.Xamarin.Forms.Mocks.MockForms.Init();
|
Tests.Xamarin.Forms.Mocks.MockForms.Init();
|
||||||
SQLitePCL.raw.SetProvider(new SQLitePCL.SQLite3Provider_e_sqlite3());
|
SQLitePCL.raw.SetProvider(new SQLitePCL.SQLite3Provider_e_sqlite3());
|
||||||
DependencyService.Register<INativeAPI, AideDeJeu.Cmd.Version_CMD>();
|
DependencyService.Register<INativeAPI, AideDeJeu.Cmd.Version_CMD>();
|
||||||
|
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||||
//Xamarin.Essentials.Platform.Init(this, bundle);
|
//Xamarin.Essentials.Platform.Init(this, bundle);
|
||||||
//Xamarin.Essentials.ExperimentalFeatures.Enable(Xamarin.Essentials.ExperimentalFeatures.ShareFileRequest);
|
//Xamarin.Essentials.ExperimentalFeatures.Enable(Xamarin.Essentials.ExperimentalFeatures.ShareFileRequest);
|
||||||
|
|
||||||
|
|
@ -770,7 +771,7 @@ namespace AideDeJeuCmd
|
||||||
using (var stream = new FileStream("test.pdf", FileMode.Create))
|
using (var stream = new FileStream("test.pdf", FileMode.Create))
|
||||||
{
|
{
|
||||||
//pdfService.MarkdownToPdf("# mon titre\n\nhop", stream);
|
//pdfService.MarkdownToPdf("# mon titre\n\nhop", stream);
|
||||||
pdfService.MarkdownToPdf(spells.Select(s => s.Markdown).ToList(), stream);
|
pdfService.MarkdownToPdf(spells.Select(s => s.Markdown).Take(3).ToList(), stream);
|
||||||
//pdfService.MarkdownToPdf(new List<string>() { item.Markdown }, stream);
|
//pdfService.MarkdownToPdf(new List<string>() { item.Markdown }, stream);
|
||||||
//var stream = new MemoryStream();
|
//var stream = new MemoryStream();
|
||||||
//pce.GeneratePdfToStream(pc, stream);
|
//pce.GeneratePdfToStream(pc, stream);
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.4" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.4" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.4" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.4" />
|
||||||
<PackageReference Include="sqlite-net-pcl" Version="1.6.258-beta" />
|
<PackageReference Include="sqlite-net-pcl" Version="1.6.258-beta" />
|
||||||
|
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.5.1" />
|
||||||
<PackageReference Include="Xamarin.Essentials" Version="1.1.0" />
|
<PackageReference Include="Xamarin.Essentials" Version="1.1.0" />
|
||||||
<PackageReference Include="Xamarin.Forms" Version="4.0.0.497661" />
|
<PackageReference Include="Xamarin.Forms" Version="4.0.0.497661" />
|
||||||
<PackageReference Include="XamiTextSharpLGPLv2" Version="1.0.0" />
|
<PackageReference Include="XamiTextSharpLGPLv2" Version="1.0.0" />
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue