Marking TextStamp as Artifact

Hi,

I’m using the Aspose.Pdf.Page.AddStamp method to add a TextStamp to a document, but want to mark the TextStamp as an artifact for accessibility reasons.

How do I do this please?

Thank you,

Stan

@modern.gov

You can use WatermarkArtifact class to add watermark inside PDF document as following:

Artifact watermark = new WatermarkArtifact();
watermark.SetImage(imageStream);
watermark.IsBackground = true;
watermark.ArtifactHorizontalAlignment = HorizontalAlignment.Center;
watermark.ArtifactVerticalAlignment = VerticalAlignment.Center;
watermark.RightMargin = 0;
watermark.TopMargin = 0;
watermark.LeftMargin = 0;
watermark.BottomMargin = 0;
Page.Artifacts.Add(watermark);

However, in case your requirements are related to Tagged PDFs, please share a bit more details and share an expected output with us. We will further test the scenario in our environment and address it accordingly.

Hi Asad,

Thank you for that; Reviewing my requirements more closely I realise that an artifact doesn’t actually meet the needs I have, which is why we have been using a text stamp. As such, I’ve created a small project showing the issue I am having and a document that supports my investigation and will hopefully explain my issue.

I should emphasise, we need to use TextStamps and we need to use them in the two situations detailed in the document as there is a lot of supporting code that we are not in a position to re-write, so a solution around what is in the example project would be appreciated.

Thank you,
Stan

Investigation.pdf (192.4 KB)
AccessibilityTest.zip (42.1 KB)

@modern.gov

Thanks for elaborating your requirements further.

We have logged an issue as PDFNET-46797 in our issue tracking system for the sake of detailed investigation against your issue. We will further look into details of the ticket and keep you posted with the status of its correction. Please be patient and spare us little time.

We are sorry for the inconvenience.

Good morning,
Regarding:

How is the issue progressing, do we have an ETA for it to be resolved?

Thank you,

Stan

@modern.gov

We have investigated earlier logged ticket. The cause of error “Basic Requirements” > “ISO32000” from second example has been eliminated in Aspose.PDF for .NET 19.9. However, API does not provide for conversion with a missing logical structure of the document; therefore, inserting a TextStamp in the way you specified in the examples will not work. Even after the conversion, we will have a document that is not valid for the PDF/UA Standards.

In the first case, we will receive an error: “Text object not tagged” and in second case: “Path object not tagged”. We suggest using an Artifact object instead of TextStamp to keep PDF/UA compliance. In below given code snippet, you need to call convert method in order to keep PDF/UA compatibility. It will make fonts embedded:

string inFile = DataDir + "AccessibilityTest.pdf";
string outFile = DataDir + "out.pdf";
string logConvert = DataDir + "out_convert.xml";
string logValidate = DataDir + "out_validete.xml";

Document document = new Document(inFile);
Artifact artifact = new Artifact(Artifact.ArtifactType.Page, Artifact.ArtifactSubtype.Footer);

FormattedText ft = new FormattedText("This is some test text", System.Drawing.Color.Black, System.Drawing.Color.White);
//ft.AddNewLineText("Second line (if need)");
artifact.SetText(ft);
artifact.Position = new Point(400, 600);

Page page = document.Pages[1];
page.Artifacts.Add(artifact);

document.Convert(logConvert, PdfFormat.PDF_UA_1, ConvertErrorAction.None);
bool isPdfUa = document.Validate(logValidate, PdfFormat.PDF_UA_1);

document.Save(outFile);

Hi Asad,

Thanks for looking at this; but as per my comment on the 6th of August our usage of TextStamp means changing the code to use Artifact is not a trivial thing for us.

Please could you elaborate as to why it is not possible to ‘tag’ TextStamps to preserve logical structure? We are working to meet the The Public Sector Bodies (Websites and Mobile Applications) (No. 2) Accessibility Regulations 2018; which is a legal requirement for many of our customers and many organisation in the EU generally.

It does not seem very good that a company is prepared to have a feature in their product that actively decreases the accessibility of documents that it processes; so unless there is no technical way to correctly tag a TextStamp (for which a suitable source would be good) I still think this is something that needs resolving (regardless of the ‘Artifact’ option).

I await your advice,

Thank you,

Stan

Hi,

Further to the last post I wish to confirm some of the features we use on TextStamps; I note that Artifacts do not seem to support some of these; which again leans me toward insisting that we need to use TextStamps:

  • Font
  • Font Sizing
  • Background colour (including transparency)
  • Rotation around a point
  • Position
  • Opacity
  • Foreground colour
  • Draw (i.e. stamp as image)
  • Outline Width, Outline Opacity (used in conjunction with the Draw flag).

Again I emphasise that I would like to understand why it is not possible to correct the accessibility issue with TextStamps, rather than the alternative of using an Artifact.

Thank you,

Stan

@modern.gov

Thanks for sharing your further concerns.

We have generated a separate ticket as PDFNET-47066 in our issue tracking system to address your concerns. We will further look into this and provide our feedback as soon as ticket is resolved. Please spare us little time.

We are sorry for the inconvenience.

Please can I have an update on PDFNET-47066, it’s been almost a year.

Thank you,

Stan

1 Like

@modern.gov

We regret that investigation against the mentioned ticket is not yet completed. It is more like a new feature in the API and needs more time to get fully investigated. We will surely inform you as soon as we have some certain updates regarding ticket resolution. We greatly appreciate your patience and cooperation in this matter. Please give us some time.

We apologize for your inconvenience.

Hi Asad,

It has been a year since PDFNET-47066 was raised, please can I have details of the investigations carried out to date on the matter as well as an actual timeframe for resolution?

On my post in October 19 I also asked why it was not possible to ‘tag’ TextStamps in such as way as to preserve document structure (which I understand to be the solution to this problem) but I realise I did not receive an answer, please can you address that question (I am fine with it being technical in nature)?

Thank you,

Stan

@modern.gov

We really apologize for the delay and inconvenience faced.

We would like to share with you that your above inquiry was also logged under the ticket (PDFNET-47066) along with your other requirements. However, the ticket could not get resolved sadly due to other issues in the queue.

We do realize the ticket significance for you and have raised its priority in order to escalate things. We will surely gather required information and share it with you as soon as the investigation of the ticket is completed. We highly appreciate your patience and comprehension in this regard.

We again apologize for the inconvenience.

We also look forward to solving this problem.

1 Like

@kr75

We have recorded your concerns and will surely update you once the earlier logged ticket is resolved.

Please can we have an update on the progress on ticket PDFNET-47066 ?

1 Like

@modern.gov

We really regret to inform you that the earlier logged ticket could not get resolved due to previously logged issues and enhancements tickets in the queue. We have already recorded your concerns and will surely inform you as soon as we have certain updates regarding ticket resolution. Please be patient and spare us some time.

We are sorry for the inconvenience.

Hi,

can you, please, share the status of this one? And if nothing changed, do you have any plans for the nearest future?

@yuzaitsev

The ticket is currently under the phase of the investigation and we are afraid that we still do not have any promising ETA for its resolution. Nevertheless, the information of the ticket has been updated after recording your concerns and we will surely inform you as soon as we have some updates in this regard. We apologize for your inconvenience.

@yuzaitsev

Our TextStamps (and other kinds of stamps) are implemented using XObject functionality - and unfortunately, XObjects aren’t very PDF/UA friendly. We investigated a possibility to manually tag TextStamps according to their content, but for the time being there is no satisfactory solution for this.

So, we chose another approach: beginning with Aspose.PDF v.23.6 all TextStamps will be automatically marked as artifacts when they are added to the page (the same way as it’s done for the Artifact class and its inheritors), they will not break PDF/UA compatibility anymore.