Browse Source

Merge branch 'main' into in-code-documentation

Marcin Ziąbek 2 years ago
parent
commit
a17493fd74

+ 1 - 1
License.md → LICENSE.md

@@ -87,4 +87,4 @@ Title, ownership rights, and intellectual property rights in and to the Software
 
 
 ### Limitation Of Liability
 ### Limitation Of Liability
 
 
-THIS SOFTWARE IS PROVIDED "AS IS," WITHOUT A WARRANTY OF ANY KIND. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. QUESTPDF AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL QUESTPDF OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE SOFTWARE, EVEN IF QUESTPDF HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+THIS SOFTWARE IS PROVIDED "AS IS," WITHOUT A WARRANTY OF ANY KIND. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. QUESTPDF AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL QUESTPDF OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE SOFTWARE, EVEN IF QUESTPDF HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

+ 2 - 1
README.md

@@ -56,7 +56,8 @@ Choosing a project dependency could be difficult. We need to ensure stability an
 
 
 ⭐ Please give this repository a star. It takes seconds and help thousands of developers! ⭐
 ⭐ Please give this repository a star. It takes seconds and help thousands of developers! ⭐
 
 
-<img src="https://github.com/QuestPDF/QuestPDF/assets/9263853/fd16701c-d74c-41ba-a549-fb731c492fe4" width="800" />
+<img src="https://github.com/QuestPDF/QuestPDF/assets/9263853/af05fecd-f6c1-46cf-b646-2b5524e036cf" width="800" />
+
 
 
 ## Please share with the community
 ## Please share with the community
 
 

+ 7 - 2
Source/QuestPDF.Examples/Engine/RenderingTest.cs

@@ -113,11 +113,16 @@ namespace QuestPDF.Examples.Engine
         {
         {
             if (ResultType == RenderingTestResult.Images)
             if (ResultType == RenderingTestResult.Images)
             {
             {
+                var generationSettings = new ImageGenerationSettings { RasterDpi = 144 };
+                
                 Func<int, string> fileNameSchema = i => $"{FileNamePrefix}-${i}.png";
                 Func<int, string> fileNameSchema = i => $"{FileNamePrefix}-${i}.png";
-                document.GenerateImages(x => fileNameSchema(x));
+                document.GenerateImages(fileNameSchema, generationSettings);
 
 
                 if (ShowResult && ShowingResultsEnabled)
                 if (ShowResult && ShowingResultsEnabled)
-                    GenerateExtensions.OpenFileUsingDefaultProgram(fileNameSchema(0));
+                {
+                    var firstImagePath = fileNameSchema(0);
+                    GenerateExtensions.OpenFileUsingDefaultProgram(firstImagePath);
+                }
             }
             }
 
 
             if (ResultType == RenderingTestResult.Pdf)
             if (ResultType == RenderingTestResult.Pdf)

+ 1 - 15
Source/QuestPDF.Examples/Engine/SimpleDocument.cs

@@ -1,16 +1,10 @@
 using System;
 using System;
-using QuestPDF.Drawing;
-using QuestPDF.Elements;
-using QuestPDF.Fluent;
-using QuestPDF.Helpers;
 using QuestPDF.Infrastructure;
 using QuestPDF.Infrastructure;
 
 
 namespace QuestPDF.Examples.Engine
 namespace QuestPDF.Examples.Engine
 {
 {
     public class SimpleDocument : IDocument
     public class SimpleDocument : IDocument
     {
     {
-        public const int ImageScalingFactor = 2;
-        
         private Action<IDocumentContainer> Content { get; }
         private Action<IDocumentContainer> Content { get; }
         private int MaxPages { get; }
         private int MaxPages { get; }
 
 
@@ -23,15 +17,7 @@ namespace QuestPDF.Examples.Engine
             QuestPDF.Settings.EnableDebugging = applyDebugging;
             QuestPDF.Settings.EnableDebugging = applyDebugging;
             QuestPDF.Settings.DocumentLayoutExceptionThreshold = MaxPages;
             QuestPDF.Settings.DocumentLayoutExceptionThreshold = MaxPages;
         }
         }
-        
-        public DocumentSettings GetSettings()
-        {
-            return new DocumentSettings()
-            {
-                ImageRasterDpi = PageSizes.PointsPerInch * ImageScalingFactor
-            };
-        }
-        
+
         public void Compose(IDocumentContainer container)
         public void Compose(IDocumentContainer container)
         {
         {
             Content(container);
             Content(container);

+ 18 - 0
Source/QuestPDF.Examples/ImageExamples.cs

@@ -139,6 +139,24 @@ namespace QuestPDF.Examples
                 });
                 });
         }
         }
         
         
+        [Test]
+        public void FitUnproportionally()
+        {
+            RenderingTest
+                .Create()
+                .PageSize(400, 600)
+                .ProduceImages()
+                .ShowResults()
+                .Render(page =>
+                {
+                    page.Padding(15).MinimalBox().Background(Colors.Grey.Lighten3).Row(row =>
+                    {
+                        row.RelativeItem().Padding(5).Text(Placeholders.LoremIpsum());
+                        row.RelativeItem().Image("photo.jpg").FitUnproportionally();
+                    });
+                });
+        }
+        
         [Test]
         [Test]
         public void Exception()
         public void Exception()
         {
         {

+ 53 - 0
Source/QuestPDF.Examples/PageBackgroundForegroundExample.cs

@@ -53,5 +53,58 @@ namespace QuestPDF.Examples
                     });
                     });
                 });
                 });
         }
         }
+
+        [Test]
+        public void CustomContentOnPageSides()
+        {
+            RenderingTest
+                .Create()
+                .ProduceImages()
+                .MaxPages(100)
+                .ShowResults()
+                .RenderDocument(document =>
+                {
+                    document.Page(page =>
+                    {
+                        const float horizontalMargin = 1.5f;
+                        const float verticalMargin = 1f;
+                        
+                        page.Size(PageSizes.A4);
+                        page.MarginVertical(verticalMargin, Unit.Inch);
+                        page.MarginHorizontal(horizontalMargin, Unit.Inch);
+                        page.PageColor(Colors.White);
+
+                        page.Background()
+                            .PaddingVertical(verticalMargin, Unit.Inch)
+                            .RotateRight()
+                            .Decoration(decoration =>
+                            {
+                                decoration.Before().RotateRight().RotateRight().Element(DrawSide);
+                                decoration.Content().Extend();
+                                decoration.After().Element(DrawSide);
+
+                                void DrawSide(IContainer container)
+                                {
+                                    container
+                                        .Height(horizontalMargin, Unit.Inch)
+                                        .AlignMiddle()
+                                        .Row(row =>
+                                        {   
+                                            row.AutoItem().PaddingRight(16).Text("COMPANY NAME").FontSize(16).FontColor(Colors.Red.Medium);
+                                            row.RelativeItem().PaddingTop(12).ExtendHorizontal().LineHorizontal(2).LineColor(Colors.Red.Medium);
+                                        });
+                                }
+                            });
+                        
+                        page.Content().Column(column =>
+                        {
+                            column.Spacing(25);
+
+                            foreach (var i in Enumerable.Range(1, 100))
+                                column.Item().Background(Colors.Grey.Lighten2).Height(75).AlignCenter().AlignMiddle().Text(i.ToString()).FontSize(16);
+                        });
+                    });
+                });
+        }
     }
     }
 }
 }

+ 1 - 0
Source/QuestPDF/Fluent/GenerateExtensions.cs

@@ -151,6 +151,7 @@ namespace QuestPDF.Fluent
             };
             };
 
 
             process.Start();
             process.Start();
+            process.WaitForExit();
         }
         }
         
         
         #endregion
         #endregion

+ 1 - 0
Source/QuestPDF/Infrastructure/DocumentSettings.cs

@@ -17,6 +17,7 @@
         /// When the image contains an alpha channel, it is always encoded using the PNG format and this option is ignored.
         /// When the image contains an alpha channel, it is always encoded using the PNG format and this option is ignored.
         /// The default value is "high quality".
         /// The default value is "high quality".
         /// </summary>
         /// </summary>
+
         /// <remarks>
         /// <remarks>
         /// This setting is taken into account only when the image is in the JPG format, otherwise it is ignored.
         /// This setting is taken into account only when the image is in the JPG format, otherwise it is ignored.
         /// </remarks>
         /// </remarks>

+ 1 - 1
Source/QuestPDF/QuestPDF.csproj

@@ -3,7 +3,7 @@
         <Authors>MarcinZiabek</Authors>
         <Authors>MarcinZiabek</Authors>
         <Company>CodeFlint</Company>
         <Company>CodeFlint</Company>
         <PackageId>QuestPDF</PackageId>
         <PackageId>QuestPDF</PackageId>
-        <Version>2023.6.1</Version>
+        <Version>2023.6.3</Version>
         <PackageDescription>QuestPDF is an open-source, modern and battle-tested library that can help you with generating PDF documents by offering friendly, discoverable and predictable C# fluent API. Easily generate PDF reports, invoices, exports, etc.</PackageDescription>
         <PackageDescription>QuestPDF is an open-source, modern and battle-tested library that can help you with generating PDF documents by offering friendly, discoverable and predictable C# fluent API. Easily generate PDF reports, invoices, exports, etc.</PackageDescription>
         <PackageReleaseNotes>$([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/Resources/ReleaseNotes.txt"))</PackageReleaseNotes>
         <PackageReleaseNotes>$([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/Resources/ReleaseNotes.txt"))</PackageReleaseNotes>
         <LangVersion>9</LangVersion>
         <LangVersion>9</LangVersion>

+ 7 - 0
Source/QuestPDF/Resources/ReleaseNotes.txt

@@ -7,3 +7,10 @@ Version 2023.6.1
 - Fix: incorrect layout exception when debugging is disabled
 - Fix: incorrect layout exception when debugging is disabled
 - Fix: the page number functionality for sections do not work (#609)
 - Fix: the page number functionality for sections do not work (#609)
 - Improvement: enhanced the message about the QuestPDF Previewer application version incompatibility
 - Improvement: enhanced the message about the QuestPDF Previewer application version incompatibility
+
+Version 2023.6.2
+- Fix: improved `Image.FitUnproportionally` behavior to ensure it now respects minimal size constraints and doesn't just expand to use all the available space.
+- Adjustment: increased the default DPI setting from 144 to 288 to better match industry standards and provide visuals of expected quality. To counterbalance for potential output size increase, the image quality has been decreased from "very high" to "high" (JPEG 90 to 75).
+
+Version 2023.6.3
+- Fix: the `GeneratePdfAndShow` method does not always properly open the generated PDF file in a default application due to a timing issue.