Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Solution>
<Project Path="Convert-PDF-to-PDF-A-2b/Convert-PDF-to-PDF-A-2b.csproj" />
</Solution>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Convert_PDF_to_PDF_A_2b</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Syncfusion.Pdf.Imaging.Net.Core" Version="*" />
</ItemGroup>

<ItemGroup>
<None Update="Data\Input.pdf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using SkiaSharp;
using Syncfusion.Pdf;
using Syncfusion.Pdf.Graphics;
using Syncfusion.Pdf.Parsing;

// Load the PDF document
using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument(Path.GetFullPath(@"Data/Input.pdf")))
{
// Handle font substitution during PDF/A conversion
loadedDocument.SubstituteFont += LoadedDocument_SubstituteFont;
// Convert the document to PDF/A-2B format
loadedDocument.ConvertToPDFA(PdfConformanceLevel.Pdf_A2B);
// Save the PDF document
loadedDocument.Save(Path.GetFullPath(@"Output/Output.pdf"));
}

// Event handler to substitute missing fonts during conversion
void LoadedDocument_SubstituteFont(object sender, PdfFontEventArgs args)
{
// Extract the font name (ignoring style suffixes)
string fontName = args.FontName.Split(',')[0];
// Determine the font style
PdfFontStyle fontStyle = args.FontStyle;
SKFontStyle skFontStyle = SKFontStyle.Normal;
// Map PDF font styles to SkiaSharp font styles
if (fontStyle == PdfFontStyle.Bold)
skFontStyle = SKFontStyle.Bold;
else if (fontStyle == PdfFontStyle.Italic)
skFontStyle = SKFontStyle.Italic;
else if (fontStyle == (PdfFontStyle.Bold | PdfFontStyle.Italic))
skFontStyle = SKFontStyle.BoldItalic;
// Load the typeface using SkiaSharp
SKTypeface typeface = SKTypeface.FromFamilyName(fontName, skFontStyle);
SKStreamAsset typeFaceStream = typeface.OpenStream();

// Create a memory stream from the font data
MemoryStream memoryStream = null;
if (typeFaceStream != null && typeFaceStream.Length > 0)
{
byte[] fontData = new byte[typeFaceStream.Length];
typeFaceStream.Read(fontData, fontData.Length);
typeFaceStream.Dispose();
memoryStream = new MemoryStream(fontData);
}
// Assign the font stream to the event arguments
args.FontStream = memoryStream;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Solution>
<Project Path="Convert-PDF-to-PDF-A-3b/Convert-PDF-to-PDF-A-3b.csproj" />
</Solution>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Convert_PDF_to_PDF_A_3b</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Syncfusion.Pdf.Imaging.Net.Core" Version="*" />
</ItemGroup>

<ItemGroup>
<None Update="Data\Input.pdf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Data\ZUGFeRD_invoice.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<dataroot>
<Report>
<ProductID>CA-1098</ProductID>
<Product>AWC Logo Cap</Product>
<Price>8.99</Price>
<Quantity></Quantity>
<TotalPrice></TotalPrice>
</Report>
<Report>
<ProductID>LJ-0192-M</ProductID>
<Product>Long-Sleeve Logo Jersey, M</Product>
<Price>49.99</Price>
<Quantity></Quantity>
<TotalPrice></TotalPrice>
</Report>
<Report>
<ProductID>SO-B909-M</ProductID>
<Product>Mountain Bike Socks, M</Product>
<Price>9.50</Price>
<Quantity></Quantity>
<TotalPrice></TotalPrice>
</Report>
<Report>
<ProductID>LJ-0192-M</ProductID>
<Product>Long-Sleeve Logo Jersey, M</Product>
<Price>49.99</Price>
<Quantity></Quantity>
<TotalPrice></TotalPrice>
</Report>
<Report>
<ProductID>FK-5136</ProductID>
<Product>ML Fork</Product>
<Price>175.49</Price>
<Quantity></Quantity>
<TotalPrice></TotalPrice>
</Report>
<Report>
<ProductID>HL-U509</ProductID>
<Product>Sport-100 Helmet, Black</Product>
<Price>34.99</Price>
<Quantity></Quantity>
<TotalPrice></TotalPrice>
</Report>
</dataroot>
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
using SkiaSharp;
using Syncfusion.Pdf;
using Syncfusion.Pdf.Graphics;
using Syncfusion.Pdf.Interactive;
using Syncfusion.Pdf.Parsing;

// Load the PDF document
using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument(Path.GetFullPath(@"Data/Input.pdf")))
{
// Handle font substitution during PDF/A conversion
loadedDocument.SubstituteFont += LoadedDocument_SubstituteFont;
//Create an attachment
PdfAttachment attachment = new PdfAttachment(Path.GetFullPath("Data/ZUGFeRD_invoice.xml"))
{
//Add the attachment relationship
Relationship = PdfAttachmentRelationship.Alternative,
//Set modification date
ModificationDate = DateTime.Now,
//Set description and mime type
Description = "ZUGFeRD_invoice",
MimeType = "text/xml"
};
// Create the attachments section if it does not exist
if (loadedDocument.Attachments == null)
loadedDocument.CreateAttachment();
//Add the attachment to the existing document.
loadedDocument.Attachments.Add(attachment);
// Convert the document to PDF/A-3B format
loadedDocument.ConvertToPDFA(PdfConformanceLevel.Pdf_A3B);
// Save the PDF document
loadedDocument.Save(Path.GetFullPath(@"Output/Output.pdf"));
}

// Event handler to substitute missing fonts during conversion
void LoadedDocument_SubstituteFont(object sender, PdfFontEventArgs args)
{
// Extract the font name (ignoring style suffixes)
string fontName = args.FontName.Split(',')[0];
// Determine the font style
PdfFontStyle fontStyle = args.FontStyle;
SKFontStyle skFontStyle = SKFontStyle.Normal;
// Map PDF font styles to SkiaSharp font styles
if (fontStyle == PdfFontStyle.Bold)
skFontStyle = SKFontStyle.Bold;
else if (fontStyle == PdfFontStyle.Italic)
skFontStyle = SKFontStyle.Italic;
else if (fontStyle == (PdfFontStyle.Bold | PdfFontStyle.Italic))
skFontStyle = SKFontStyle.BoldItalic;
// Load the typeface using SkiaSharp
SKTypeface typeface = SKTypeface.FromFamilyName(fontName, skFontStyle);
SKStreamAsset typeFaceStream = typeface.OpenStream();

// Create a memory stream from the font data
MemoryStream memoryStream = null;
if (typeFaceStream != null && typeFaceStream.Length > 0)
{
byte[] fontData = new byte[typeFaceStream.Length];
typeFaceStream.Read(fontData, fontData.Length);
typeFaceStream.Dispose();
memoryStream = new MemoryStream(fontData);
}
// Assign the font stream to the event arguments
args.FontStream = memoryStream;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Solution>
<Project Path="Convert-PDF-to-PDF-A-4/Convert-PDF-to-PDF-A-4.csproj" />
</Solution>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>Convert_PDF_to_PDF_A_4</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Syncfusion.Pdf.Imaging.Net.Core" Version="*" />
</ItemGroup>

<ItemGroup>
<None Update="Data\Input.pdf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using SkiaSharp;
using Syncfusion.Pdf;
using Syncfusion.Pdf.Graphics;
using Syncfusion.Pdf.Parsing;

// Load the PDF document
using (PdfLoadedDocument loadedDocument = new PdfLoadedDocument(Path.GetFullPath(@"Data/Input.pdf")))
{
// Handle font substitution during PDF/A conversion
loadedDocument.SubstituteFont += LoadedDocument_SubstituteFont;
// Convert the document to PDF/A-4 format
loadedDocument.ConvertToPDFA(PdfConformanceLevel.Pdf_A4);
// Save the PDF document
loadedDocument.Save(Path.GetFullPath(@"Output/Output.pdf"));
}

// Event handler to substitute missing fonts during conversion
void LoadedDocument_SubstituteFont(object sender, PdfFontEventArgs args)
{
// Extract the font name (ignoring style suffixes)
string fontName = args.FontName.Split(',')[0];
// Determine the font style
PdfFontStyle fontStyle = args.FontStyle;
SKFontStyle skFontStyle = SKFontStyle.Normal;
// Map PDF font styles to SkiaSharp font styles
if (fontStyle == PdfFontStyle.Bold)
skFontStyle = SKFontStyle.Bold;
else if (fontStyle == PdfFontStyle.Italic)
skFontStyle = SKFontStyle.Italic;
else if (fontStyle == (PdfFontStyle.Bold | PdfFontStyle.Italic))
skFontStyle = SKFontStyle.BoldItalic;
// Load the typeface using SkiaSharp
SKTypeface typeface = SKTypeface.FromFamilyName(fontName, skFontStyle);
SKStreamAsset typeFaceStream = typeface.OpenStream();

// Create a memory stream from the font data
MemoryStream memoryStream = null;
if (typeFaceStream != null && typeFaceStream.Length > 0)
{
byte[] fontData = new byte[typeFaceStream.Length];
typeFaceStream.Read(fontData, fontData.Length);
typeFaceStream.Dispose();
memoryStream = new MemoryStream(fontData);
}
// Assign the font stream to the event arguments
args.FontStream = memoryStream;
}
Loading