Skip to content

Commit

Permalink
Fix bitmaps being created transparent and update ReadMe
Browse files Browse the repository at this point in the history
This update fixes the ReadMe TOC (was not updated after the last change) and, additionally, fixes a debug artifact i introduced by accident (canvas.Clear(Transparent)), which resulted in working PDFs but for BitMaps generated to have a transparent background. The Fix should have been up already, but apparently I forgot to push this. Sorry for the inconvenience.
  • Loading branch information
X39 committed Oct 31, 2024
1 parent 80b2bdf commit 3955f88
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ jobs:
- name: Pack
# CHANGE PACKAGE VERSION - The retarded way
# Change the /p:VERSION=X.X.X part to change the actual package version.
run: dotnet pack --configuration Release /p:VERSION=5.1.0.${{ github.run_number }} --version-suffix ${{ github.sha }}
run: dotnet pack --configuration Release /p:VERSION=5.1.1.${{ github.run_number }} --version-suffix ${{ github.sha }}
- name: Upload to NuGet
run: dotnet nuget push ./source/X39.Solutions.PdfTemplate/bin/Release/X39.Solutions.PdfTemplate.*.nupkg -s https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_API_KEY }}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Use [GitHub](https://github.com/X39/X39.Solutions.PdfTemplate) for best reading
* [Semantic Versioning](#semantic-versioning)
* [Getting Started](#getting-started)
* [Template structure](#template-structure)
* [About `areas`](#about-areas)
* [Integration](#integration)
* [Functions](#functions)
* [Variables](#variables)
Expand All @@ -28,7 +29,6 @@ Use [GitHub](https://github.com/X39/X39.Solutions.PdfTemplate) for best reading
* [`th`](#th)
* [`tr`](#tr)
* [`td`](#td)
* [`area`](#area)
* [Transformers](#transformers)
* [Creating your own transformer](#creating-your-own-transformer)
* [Evaluating user data](#evaluating-user-data)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public ImmediateCanvasImpl(SKCanvas canvas, SkPaintCache paintCache)
{
_canvas = canvas;
_paintCache = paintCache;
_canvas.Clear();
}

public void PushState()
Expand Down
16 changes: 15 additions & 1 deletion test/X39.Solutions.PdfTemplate.Test/Samples/ReadMeSample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Xml;
using SkiaSharp;
using X39.Solutions.PdfTemplate.Data;
using X39.Util.Collections;

namespace X39.Solutions.PdfTemplate.Test.Samples;

Expand Down Expand Up @@ -184,6 +185,19 @@ @alternate on value {
// {
// bitmaps.First().Encode(fstream, SKEncodedImageFormat.Png, 100);
// }
await generator.GeneratePdfAsync(pdfStream, xmlReader, CultureInfo.InvariantCulture, docOptions);
// await generator.GeneratePdfAsync(pdfStream, xmlReader, CultureInfo.InvariantCulture, docOptions);
var results = await generator.GenerateBitmapsAsync(xmlReader, CultureInfo.InvariantCulture, docOptions);
foreach (var (skBitmap, index) in results.Indexed())
using (skBitmap)
{
using var image = SKImage.FromBitmap(skBitmap);
using var data = image.Encode(SKEncodedImageFormat.Png, 100);
await using var fstream = new FileStream(
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), $"{index}.png"),
FileMode.Create,
FileAccess.Write
);
data.SaveTo(fstream);
}
}
}

0 comments on commit 3955f88

Please sign in to comment.