Convert Multipage Tiff to PDF/A-1A

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));
            }
        }
    }

@jhartl

Thanks for contacting support.

We have tested the scenario in our environment by converting one of our sample TIFF images into PDF/A-1a compliant document and observed that the output document contained compliance error. Hence we have logged an issue as PDFNET-43639 in our issue tracking system. We will further investigate the issue and keep you posted with the status of its rectification. Please be patient and spare us little time.

Please check following code snippet, which we have used to test the scenario:

Document pdf1 = new Document();
MemoryStream ms = new MemoryStream();
new FileStream(dataDir + @"TestTif4.tif", FileMode.Open).CopyTo(ms);
Bitmap myimage = new Bitmap(ms);

FrameDimension dimension = new FrameDimension(myimage.FrameDimensionsList[0]);
int frameCount = myimage.GetFrameCount(dimension);

for (int frameIdx = 0; frameIdx <= frameCount - 1; frameIdx++)
{
  Page sec = pdf1.Pages.Add();

  myimage.SelectActiveFrame(dimension, frameIdx);

  MemoryStream currentImage = new MemoryStream();
  myimage.Save(currentImage, ImageFormat.Tiff);

  if (myimage.Width > myimage.Height)
  {
     sec.PageInfo.IsLandscape = true;
  }
  else
  {
     sec.PageInfo.IsLandscape = false;
  }

Aspose.Pdf.Image imageht = new Aspose.Pdf.Image();
imageht.ImageStream = currentImage;
imageht.IsBlackWhite = true;
sec.Paragraphs.Add(imageht);
}
//pdf1.Save(dataDir + "TifftoPDF_PDFA.pdf");
//pdf1 = new Document(dataDir + "TifftoPDF_PDFA.pdf");
pdf1.Convert(new MemoryStream(), PdfFormat.PDF_A_1A, ConvertErrorAction.Delete);
pdf1.Save(dataDir + "TifftoPDF_PDFA.pdf");

We are sorry for the inconvenience.

Just checking to see if there was an update on this.

@aultmike

Thanks for contacting support.

I regret to share that earlier logged issue could not get resolved due to large number of pending issues in the queue. We will definitely provide updates as soon as we have some regarding issue resolution. We greatly appreciate your patience and comprehension in this regard. Please spare us little time.

We are sorry for the inconvenience.