Hello,
I’m searching for a PDF-processing library for C# for my company. It is mandatory that I can convert any PDF-File and Multipage-Tiff-Files to PDF/A-1A. To remove any complex non PDF/A-1A standard structure from the PDF-files I can prior convert the PDF-Files to Multipage-Tiff, but I fail to convert the Multipage-Tiff to PDF/A-1A. It is mandatory that the resulting PDF/A-1A file validates to the validation tool: PDF Tools Online - Validate PDF.
Could You please help me? Thank You!
I’m using the following code:
private static void ConvertTiffToPdfA(string tiffFile)
{
using (Aspose.Pdf.Document document = new Aspose.Pdf.Document())
using (var image = System.Drawing.Bitmap.FromFile(tiffFile))
{
for (int i = 0; i < image.GetFrameCount(System.Drawing.Imaging.FrameDimension.Page); i++)
{
image.SelectActiveFrame(System.Drawing.Imaging.FrameDimension.Page, i);
var page = document.Pages.Add();
page.PageInfo.Margin.Bottom = 0;
page.PageInfo.Margin.Left = 0;
page.PageInfo.Margin.Top = 0;
page.PageInfo.Margin.Right = 0;
page.CropBox = new Aspose.Pdf.Rectangle(0, 0, image.Width, image.Height);
Aspose.Pdf.Image img = new Aspose.Pdf.Image();
page.Paragraphs.Add(img);
var stream = new System.IO.MemoryStream();
image.Save(stream, System.Drawing.Imaging.ImageFormat.Tiff);
if (stream.CanSeek)
{
stream.Seek(0, System.IO.SeekOrigin.Begin);
}
img.ImageStream = stream;
}
document.Convert(new Aspose.Pdf.PdfFormatConversionOptions(Aspose.Pdf.PdfFormat.PDF_A_1A));
if (document.Validate(new Aspose.Pdf.PdfFormatConversionOptions(Aspose.Pdf.PdfFormat.PDF_A_1A)))
{
document.Save(Program.GetValidPdfPath(Path.GetFileNameWithoutExtension(tiffFile) + ".pdf", true));
}
else
{
document.Save(Program.GetValidPdfPath(Path.GetFileNameWithoutExtension(tiffFile) + ".pdf", false));
}
}
}