mirror of
https://github.com/UglyToad/PdfPig.git
synced 2025-09-21 04:17:57 +08:00
move classes to new projects
to make the project more useful and expose more usable classes we're rearchitecting in the following way. code used to read fonts from external file formats like truetype, adobe font metrics (afm) and adobe type 1 fonts are moving to a new project which doesn't reference most of the pdf logic. the shared logic is moving to a new flat-structured project called core. this is a sort-of onion type architecture, with core being the... core, fonts being the next layer of the onion, pdfpig itself the next. this will then support additional libraries/projects as outer layers of the onion as well as releasing standalone version of the font library as pdfbox does with fontbox.
This commit is contained in:
66
src/UglyToad.PdfPig.Core/WritingExtensions.cs
Normal file
66
src/UglyToad.PdfPig.Core/WritingExtensions.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
namespace UglyToad.PdfPig.Core
|
||||
{
|
||||
using System.IO;
|
||||
|
||||
/// <summary>
|
||||
/// Handles writing specified data types to an output stream in a valid PDF compliant format.
|
||||
/// </summary>
|
||||
public static class WritingExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Write the <see langword="long"/> to the stream as a <see langword="uint"/>.
|
||||
/// </summary>
|
||||
public static void WriteUInt(this Stream stream, long value) => WriteUInt(stream, (uint)value);
|
||||
/// <summary>
|
||||
/// Write the <see langword="uint"/> to the stream as a <see langword="uint"/>.
|
||||
/// </summary>
|
||||
public static void WriteUInt(this Stream stream, uint value)
|
||||
{
|
||||
var buffer = new[]
|
||||
{
|
||||
(byte) (value >> 24),
|
||||
(byte) (value >> 16),
|
||||
(byte) (value >> 8),
|
||||
(byte) value
|
||||
};
|
||||
|
||||
stream.Write(buffer, 0, 4);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write the <see langword="int"/> to the stream as a <see langword="ushort"/>.
|
||||
/// </summary>
|
||||
public static void WriteUShort(this Stream stream, int value) => WriteUShort(stream, (ushort)value);
|
||||
/// <summary>
|
||||
/// Write the <see langword="ushort"/> to the stream as a <see langword="ushort"/>.
|
||||
/// </summary>
|
||||
public static void WriteUShort(this Stream stream, ushort value)
|
||||
{
|
||||
var buffer = new[]
|
||||
{
|
||||
(byte) (value >> 8),
|
||||
(byte) value
|
||||
};
|
||||
|
||||
stream.Write(buffer, 0, 2);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write the <see langword="ushort"/> to the stream as a <see langword="short"/>.
|
||||
/// </summary>
|
||||
public static void WriteShort(this Stream stream, ushort value) => WriteShort(stream, (short)value);
|
||||
/// <summary>
|
||||
/// Write the <see langword="short"/> to the stream as a <see langword="short"/>.
|
||||
/// </summary>
|
||||
public static void WriteShort(this Stream stream, short value)
|
||||
{
|
||||
var buffer = new[]
|
||||
{
|
||||
(byte) (value >> 8),
|
||||
(byte) value
|
||||
};
|
||||
|
||||
stream.Write(buffer, 0, 2);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user