Problem with watermark and pdf/A

Hello our customers raise a problem applying watermark on some pdf files (see sample attachments) Screenshot_070618_051639_PM.zip (423.8 KB)

using “2018.pdf” and apllying watermark it results as a black band on it while opening the pdf file with adobe acrobat and saving without PDF/A standard (2018 prova.pdf) the watermark is applied correctly (see the two screeenshots)

This is the code we are using (the same with all files):

                Aspose.Pdf.Document oNewDoc = new Aspose.Pdf.Document(_oPDFIOStream);
                Aspose.Pdf.DocumentInfo docInfo = new Aspose.Pdf.DocumentInfo(oNewDoc);
                docInfo.Author = "BooleBox";
                docInfo.CreationDate = DateTime.Now;
                docInfo.Keywords = "";
                docInfo.ModDate = DateTime.Now;
                docInfo.Subject = "";
                docInfo.Title = "BooleBox";

                //recupera le informazioni di grandezza dalla prima pagina
                Aspose.Pdf.PageCollection pageCollection = oNewDoc.Pages;
                Aspose.Pdf.Page pdfPage = pageCollection[1];

                Aspose.Pdf.ImageStamp imageStamp = new Aspose.Pdf.ImageStamp(_oWatermarkImage);
                imageStamp.Background = false;
                //imageStamp.XIndent =10;
                //imageStamp.YIndent = 10;
                imageStamp.BottomMargin = pdfPage.PageInfo.Margin.Bottom;
                imageStamp.TopMargin = pdfPage.PageInfo.Margin.Top;
                imageStamp.LeftMargin = pdfPage.PageInfo.Margin.Left;
                imageStamp.RightMargin = pdfPage.PageInfo.Margin.Right;
                imageStamp.Height = pdfPage.MediaBox.Height;
                imageStamp.Width = pdfPage.MediaBox.Width;
                if (pdfPage.PageInfo.Height < pdfPage.PageInfo.Width)
                {
                    imageStamp.Rotate = Aspose.Pdf.Rotation.on270;
                }
                imageStamp.Opacity = 1;
                //Add stamp
                for (int j = 1; j <= oNewDoc.Pages.Count; j++)
                {
                    oNewDoc.Pages[j].AddStamp(imageStamp);
                }

                oNewDoc.Save(_oPDFIOStream);

thanks

@BooleServer

Thank you for contacting support.

Please share if you are adding a transparent image as an image stamp. Also upload the image you are working with and please describe the PDF files as which file is created with which process or application; so that we may try to reproduce it in our environment.

Moreover, it appears like the issue occurs while converting generated PDF file to PDF/A-1B but your code snippet does not include any such clue. Kindly elaborate the problem a little more for our reference.

Tha image is created runtime by customers: is some text layer (e.g. username and client IP) repeated “covering” the pdf… obvuiously a transparent background for not covering the pdf entirely… as the term watermark.
Where can we find some documentation or examples how to return by aspose dll if a pdf is PDF/A or 1-B and applying watermark accordingly?
thank you

@BooleServer

Please rephrase the problem while describing attached files for our reference.

  • Is the PDF file in Screenshot_070618_051501_PM.jpg displayed by Adobe Acrobat, or any other application?
  • Screenshot_070618_051639_PM.jpg is displayed by which application?
  • Also share the PDF file which is displayed in both screenshots.
  • The PDF file does not contain any problem if saved without PDF/A standard and displays black band when converted to a PDF/A. Is that the case?

Kindly describe attached PDF files and the steps involved to create these files:

1. 2018 prova.pdf exportWM.pdf
2. 2018.pdf
3. 2018.pdf exportWM.pdf

And upload the image with transparent background that has been used to generate 2018 prova.pdf exportWM.pdf file so that we may investigate and analyze the scenario to help you out.

Furthermore, format of a PDF file can be checked with Document.PdfFormat property as in the lines of code below:

Document document = new Document(dataDir + "2018.pdf exportWM.pdf");
Console.WriteLine(document.PdfFormat);
  • both screeshots are from pdf files viewed with adobe acrobat reader.
  • bot of the pdf files alsa shared with you (2018.pdf and 2018 prova.pdf).
  • as said the problem is ONLY trying to apply watermark on PDF/A documents (2018.pdf), that black area you can see… so yes pdf saved without pdf/a has no problems applying watermark (the tow screeshots mentioned above)

-2018.pdf passed as stream in the code we just passed to you before (with some image with any kind to use as watermark) returns 2018.pdf exportWM.pdf (with bad watermark appiyed)
-2018 prova.pdf passed as stream in the code we just passed to you before (with some image with any kind to use as watermark) returns 2018 prova.pdf exportWM.pdf with correct watermark applied.
As i told before the right image used for watermark is a runtime generated image containing a backgroud transfarent + some text layer: we don’t have but this - we can ask if you need to obtain but this is not the point because the error it’s obtained with any kind of sample image you can find on internet… by the way we attach here the sample file we used for our proof transbugs.gif (7.3 KB)

by the way: document.PdfFormat returns “PDF_A_1_B” either with 2018.pdf and 2018 prova.pdf… there is some other properties to use as example document.ispdfacompliant or so…

@BooleServer

Thank you for elaborating it further.

We are investigating the scenario in our environment and will get back to you with our findings soon.

@BooleServer

We have further investigated the scenario and have noticed that transparent image is not added fine even on a simple PDF. Transparency is lost when we stamp transparent GIF on 2018 prova.pdf file which is not PDF/A compliant file. Whereas, this transparency problem does not occur with your application as in 2018 prova.pdf exportWM.pdf.

Below PDF file illustrates the issue we are currently facing in our environment.
2018 prova_18.7.pdf

Please share a sample application that stamps a transparent image without any problem so that we may proceed to further address your concerns.

You already have it, really we need to create a sample application containing the code we passed you in the very first post of this thread? now we’re using this sample code to call that method we’ve passed you in first post

MemoryStream oMstream5 = new MemoryStream();
FileStream file = new FileStream(“watermark_sample_some_file.png”, FileMode.Open, FileAccess.Read);
file.CopyTo(oMstream5);

sample.eOperationReturn retp2 = obj.SetPDFWatermark(oMstream5, ref oMstream3, ref szErrorText);
//oMstream3 is the starting pdf file.
var fileStreamWM = File.Create( “exportWM.pdf”);
oMstream3.Seek(0, SeekOrigin.Begin);
oMstream3.CopyTo(fileStreamWM);
fileStream.Close();

With our code the pdf file “2018 prova.pdf” receive correctly watermark with transparency but the pdf file PDF/A “2018.pdf” does not receive the transparency as you experienced too… so you effectively replicate the problem nonetheless with another file.

@BooleServer

Thank you for elaborating it further.

A ticket with ID PDFNET-45056 has been logged in our issue management system for further investigation and resolution. The ticket ID has been linked with this thread so that you will receive notification as soon as the ticket is resolved.

We are sorry for the inconvenience.