mirror of
https://github.com/Nioux/AideDeJeu.git
synced 2025-12-16 15:19:56 +00:00
Tests pdf
This commit is contained in:
parent
a76918acf1
commit
ed09e30b6e
4 changed files with 1114 additions and 9 deletions
|
|
@ -41,6 +41,7 @@
|
||||||
<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\MinionPro_It.ttf" />
|
<None Remove="Pdf\MinionPro_It.ttf" />
|
||||||
|
<None Remove="Pdf\poker_size.pdf" />
|
||||||
<None Remove="test.svg" />
|
<None Remove="test.svg" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
@ -67,6 +68,7 @@
|
||||||
<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\MinionPro_It.ttf" />
|
<EmbeddedResource Include="Pdf\MinionPro_It.ttf" />
|
||||||
|
<EmbeddedResource Include="Pdf\poker_size.pdf" />
|
||||||
<EmbeddedResource Include="test.svg" />
|
<EmbeddedResource Include="test.svg" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using iTextSharp.text;
|
using AideDeJeu.Tools;
|
||||||
|
using iTextSharp.text;
|
||||||
using iTextSharp.text.pdf;
|
using iTextSharp.text.pdf;
|
||||||
using Markdig;
|
using Markdig;
|
||||||
using Markdig.Syntax;
|
using Markdig.Syntax;
|
||||||
|
|
@ -20,7 +21,7 @@ namespace AideDeJeu.Pdf
|
||||||
//cb.Stroke();
|
//cb.Stroke();
|
||||||
ColumnText ct = new ColumnText(cb);
|
ColumnText ct = new ColumnText(cb);
|
||||||
ct.SetSimpleColumn(x, y, x + width, y + height);
|
ct.SetSimpleColumn(x, y, x + width, y + height);
|
||||||
var p = new Paragraph(text, font);
|
var p = new Paragraph(text); //, font);
|
||||||
p.Alignment = alignment;
|
p.Alignment = alignment;
|
||||||
ct.AddElement(p);
|
ct.AddElement(p);
|
||||||
ct.Go();
|
ct.Go();
|
||||||
|
|
@ -33,11 +34,14 @@ namespace AideDeJeu.Pdf
|
||||||
var parsed = Markdig.Markdown.Parse(md, pipeline);
|
var parsed = Markdig.Markdown.Parse(md, pipeline);
|
||||||
|
|
||||||
PdfReader reader = null;
|
PdfReader reader = null;
|
||||||
reader = new PdfReader(AideDeJeu.Tools.Helpers.GetResourceStream("AideDeJeu.Pdf.feuille_de_personnage_editable.pdf"));
|
reader = new PdfReader(AideDeJeu.Tools.Helpers.GetResourceStream("AideDeJeu.Pdf.poker_size.pdf"));
|
||||||
PdfStamper stamper = null;
|
PdfStamper stamper = null;
|
||||||
stamper = new PdfStamper(reader, stream);
|
stamper = new PdfStamper(reader, stream);
|
||||||
|
|
||||||
Render(parsed.AsEnumerable(), stamper);
|
Render(parsed.AsEnumerable(), stamper);
|
||||||
|
|
||||||
|
stamper.Close();
|
||||||
|
reader.Close();
|
||||||
}
|
}
|
||||||
private void Render(IEnumerable<Block> blocks, PdfStamper stamper)
|
private void Render(IEnumerable<Block> blocks, PdfStamper stamper)
|
||||||
{
|
{
|
||||||
|
|
@ -99,7 +103,54 @@ namespace AideDeJeu.Pdf
|
||||||
|
|
||||||
private void Render(ParagraphBlock block, PdfStamper stamper)
|
private void Render(ParagraphBlock block, PdfStamper stamper)
|
||||||
{
|
{
|
||||||
//DrawText(stamper.GetOverContent(0), )
|
var cb = stamper.GetOverContent(1);
|
||||||
|
//ColumnText.ShowTextAligned(cb, iTextSharp.text.Element.ALIGN_LEFT, new Phrase("Galefrin"), 40, 40, 0);
|
||||||
|
|
||||||
|
|
||||||
|
ColumnText ct = new ColumnText(cb);
|
||||||
|
ct.SetSimpleColumn(10f, 48f, 200f, 600f);
|
||||||
|
Font f = new Font();
|
||||||
|
Paragraph pz = new Paragraph(new Phrase(20, "Hello World!", f));
|
||||||
|
ct.AddElement(pz);
|
||||||
|
ct.Go();
|
||||||
|
BaseFont bf = BaseFont.CreateFont(BaseFont.HELVETICA_BOLD, "Cp1252", BaseFont.EMBEDDED);
|
||||||
|
f = new Font(bf, 13);
|
||||||
|
ct = new ColumnText(cb);
|
||||||
|
ct.SetSimpleColumn(10f, 48f, 200f, 700f);
|
||||||
|
pz = new Paragraph("Hello World!", f);
|
||||||
|
ct.AddElement(pz);
|
||||||
|
ct.Go();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return;
|
||||||
|
/*
|
||||||
|
var text = block.ToMarkdownString();
|
||||||
|
//DrawText(content, md, null, 100, 100, 300, 300, 0);
|
||||||
|
|
||||||
|
float x = 10;
|
||||||
|
float y = 10;
|
||||||
|
float width = 300;
|
||||||
|
float height = 300;
|
||||||
|
cb.SetRGBColorFill(127, 127, 127);
|
||||||
|
//cb.Rectangle(x, y, width, height);
|
||||||
|
//cb.Stroke();
|
||||||
|
ColumnText ct = new ColumnText(cb);
|
||||||
|
ct.SetSimpleColumn(x, y, x + width, y + height);
|
||||||
|
|
||||||
|
Font font = new Font(BaseFont.CreateFont());
|
||||||
|
//int rectWidth = 80;
|
||||||
|
//float maxFontSize = getMaxFontSize(BaseFont.CreateFont(), "text", rectWidth);
|
||||||
|
font.Size = 20;
|
||||||
|
|
||||||
|
|
||||||
|
var p = new Paragraph(text, font);
|
||||||
|
//p.Alignment = alignment;
|
||||||
|
ct.AddElement(p);
|
||||||
|
ct.Go();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//var style = this.Theme.Paragraph;
|
//var style = this.Theme.Paragraph;
|
||||||
//var foregroundColor = isQuoted ? this.Theme.Quote.ForegroundColor : style.ForegroundColor;
|
//var foregroundColor = isQuoted ? this.Theme.Quote.ForegroundColor : style.ForegroundColor;
|
||||||
//var label = new Label
|
//var label = new Label
|
||||||
|
|
@ -108,6 +159,7 @@ namespace AideDeJeu.Pdf
|
||||||
//};
|
//};
|
||||||
//AttachLinks(label);
|
//AttachLinks(label);
|
||||||
//this.stack.Children.Add(label);
|
//this.stack.Children.Add(label);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
1045
AideDeJeu/AideDeJeu/Pdf/poker_size.pdf
Normal file
1045
AideDeJeu/AideDeJeu/Pdf/poker_size.pdf
Normal file
File diff suppressed because one or more lines are too long
|
|
@ -1,4 +1,5 @@
|
||||||
using AideDeJeu.Tools;
|
using AideDeJeu.Pdf;
|
||||||
|
using AideDeJeu.Tools;
|
||||||
using AideDeJeu.ViewModels;
|
using AideDeJeu.ViewModels;
|
||||||
using AideDeJeuLib;
|
using AideDeJeuLib;
|
||||||
using Markdig;
|
using Markdig;
|
||||||
|
|
@ -382,10 +383,15 @@ namespace AideDeJeuCmd
|
||||||
//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);
|
||||||
|
|
||||||
var pc = new AideDeJeu.ViewModels.PlayerCharacter.PlayerCharacterViewModel();
|
var pdfService = new PdfService();
|
||||||
var pce = new AideDeJeu.ViewModels.PlayerCharacter.PlayerCharacterEditorViewModel();
|
//var pc = new AideDeJeu.ViewModels.PlayerCharacter.PlayerCharacterViewModel();
|
||||||
var stream = new MemoryStream();
|
//var pce = new AideDeJeu.ViewModels.PlayerCharacter.PlayerCharacterEditorViewModel();
|
||||||
pce.GeneratePdfToStream(pc, stream);
|
using (var stream = new FileStream("test.pdf", FileMode.Create))
|
||||||
|
{
|
||||||
|
pdfService.MarkdownToPdf("# mon titre\n\nhop", stream);
|
||||||
|
//var stream = new MemoryStream();
|
||||||
|
//pce.GeneratePdfToStream(pc, stream);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static async Task BuildLibraryAsync()
|
static async Task BuildLibraryAsync()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue