Skip to content

Commit ef144ca

Browse files
committed
Updated readme
1 parent 76d0ca4 commit ef144ca

File tree

1 file changed

+27
-16
lines changed

1 file changed

+27
-16
lines changed

README.md

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[nuget-badge]: https://img.shields.io/nuget/v/Synercoding.FileFormats.Pdf.svg?label=Synercoding.FileFormats.Pdf
66

77

8-
This project was created to enable PDF creation on .NETStandard. This because multiple libraries did not suit my purpose of working on .NET Core & .NET Framework the same way. Some alternatives supported settings the different boxes (Media, Crop, Bleed & Trim) but did not fully supported images on all platforms. Others supported images but not the different boxes, and again others did not work at all on .NET Core.
8+
This project was created to enable PDF creation on .NETStandard 2.1, .NET 6 & .NET 7. This because multiple libraries did not suit my purpose of working on .NET Core & .NET Framework the same way. Some alternatives supported settings the different boxes (Media, Crop, Bleed & Trim) but did not fully supported images on all platforms. Others supported images but not the different boxes, and again others did not work at all on .NET Core.
99

1010
Because of those reasons this libary was created.
1111

@@ -15,16 +15,30 @@ This project is licensed under MIT license.
1515
## Specifications used
1616
This library was created using the specifications lay out in ["PDF 32000-1:2008, Document management – Portable document format – Part 1: PDF 1.7"](https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/PDF32000_2008.pdf).
1717

18-
The full specifications are not implemented. This library currently only supports placements of images, drawing of vector shapes (CMYK, RGB & gray scale), and setting the different boxes.
18+
The full specifications are not implemented.
19+
This library currently only supports:
20+
- Images
21+
- *No transparency support at the moment*
22+
- Text
23+
- *Only the 14 standard fonts are available*
24+
- *See "9.6.2.2 Standard Type 1 Fonts (Standard 14 Fonts)" in the specifications.*
25+
- Shapes
26+
- Setting page boxes (Media, Crop, Bleed, Trim & Art)
27+
- Color model limited to:
28+
- DeviceGray
29+
- DeviceRGB
30+
- DeviceCMYK
31+
- Separations/Spotcolor (with a linearized type 2 method to portay the tint)
1932

2033
## Remarks
2134
Unlike most PDF libraries this library does not create the entire PDF model in memory before writing the PDF to a (file)stream. Most libaries support editing capabilities, because this libary only supports creating files, it was not necessary to keep the PDF model in memory. This results in less memory usage.
2235

2336
To place the images this library makes use of [SixLabors/ImageSharp](https://github.com/SixLabors/ImageSharp). All images that are placed in the PDF will be saved internally as a JPG file. This means that this library currently does **NOT** support transparency.
2437

2538
### Output pdfs
26-
The PDF files created in this library are PDF 1.7 compliant.
39+
The PDF files created in this library are not fully PDF 1.7 compliant, because the standard 14 fonts are partially written to the Font Dictionary, The **FirstChar**, **LastChar**. **Widths** and **FontDescriptor** values are omitted, which is was acceptable prior to PDF 1.5. This special treatment of the 14 standard fonts was deprecated in PDF 1.5. The PDF's that are generated will work in conforming readers because as the specification states: *"For backwards capability, conforming readers shall still provide the special treatment identified for the standard 14 fonts."*.
2740

41+
This shortcoming shall be remedied when broader font support is implemented.
2842

2943
### Sample program images
3044
The sample project called *Synercoding.FileFormats.Pdf.ConsoleTester* uses multiple images. Those images were taken from [Pexels.com](https://www.pexels.com/royalty-free-images/) and are licensed under the [Pexels License](https://www.pexels.com/photo-license/).
@@ -35,21 +49,18 @@ The sample project called *Synercoding.FileFormats.Pdf.ConsoleTester* uses multi
3549
using (var writer = new PdfWriter(fs))
3650
{
3751
writer
38-
.AddPage(page =>
52+
.AddPage(page =>
3953
{
40-
var bleed = new Spacing(3, Unit.Millimeters);
41-
page.MediaBox = Sizes.A4Portrait.Expand(bleed).AsRectangle();
54+
var bleed = Mm(3);
55+
page.MediaBox = Sizes.A4.Expand(bleed).AsRectangle();
4256
page.TrimBox = page.MediaBox.Contract(bleed);
43-
44-
using (var eyeStream = File.OpenRead("Pexels_com/adult-blue-blue-eyes-865711.jpg"))
57+
58+
using (var barrenStream = File.OpenRead("Pexels_com/arid-barren-desert-1975514.jpg"))
59+
using (var barrenImage = SixLabors.ImageSharp.Image.Load(barrenStream))
4560
{
46-
var scale = 3456d / 5184;
47-
48-
var width = 100;
49-
var height = 100 * scale;
61+
var scale = (double)barrenImage.Width / barrenImage.Height;
5062

51-
var offSet = 6;
52-
page.AddImage(eyeStream, new Rectangle(offSet, offSet, width + offSet, height + offSet, Unit.Millimeters));
63+
page.Content.AddImage(barrenImage, new Rectangle(0, 0, scale * 303, 303, Unit.Millimeters));
5364
}
54-
});
55-
}</code></pre>
65+
})
66+
}</code></pre>

0 commit comments

Comments
 (0)