DocuSign Error Using AchorString With Tiff Files (C# SDK) - c#

I am using the DocuSign C# SDK to send documents. I am using the AnchorString feature to help DocuSign determine where the signature and date should go on the document. This works fine for PDF files, but I get the below error when using Tiff files (LZW and CCITT4 formats). Is there a more preferred method to anchor the signature to the document? I can't seem to find much online regarding this error.
The following error occurs when I call CreateEnvelop using the AnchorStrings feature (code included below):
Error calling CreateEnvelope: {
"errorCode": "ANCHOR_TAB_STRING_NOT_FOUND",
"message": "The specified Anchor Tab string was not found in the document. Anchor Tab String \"Signature:\" not found.Anchor Tab String \"Signed:\" not found."
}
Code:
Signer signer = new Signer();
DateSigned dateSigned = new DateSigned() { AnchorString = "Signed:", Name = "Signed:", AnchorXOffset = "35" };
signer.Tabs.DateSignedTabs.Add(dateSigned);
signer.Tabs.SignHereTabs = new List<SignHere>();
SignHere signHere = new SignHere() { AnchorString = "Signature:", Name = "Signature:", AnchorXOffset = "65" };
signer.Tabs.SignHereTabs.Add(signHere);
Update:
The ANCHOR_TAG_PROCESSING_FAILURE error that I was getting was because I didn't have the FileExtension property set to TIFF. I updated the above error to what I receive with that property set.
Note: I do not receive that error message when I create the envelope without the anchor string.
Cross posted: https://support.docusign.com/s/question/0D51W00006JzLHgSAN/error-using-achorstring-with-tiff-files-c-sdk

TL;DR: Anchor string positioning won't work when the source document uses an image format such as tiff, jpg, png, gif, etc. You'll need to use exact positioning.
Details
The anchor string system works by looking for the literal characters of the anchor string. In your case, "Signed:" So those characters need to be in the pdf document. (DocuSign converts all incoming document formats to PDF.)
In the case of original docs that use image formats such as tiff, the original document does not include the characters "Sign:" (or any other characters). Instead, image formats contain an image of the words in the document.
Since the document is an image, the words can't be located. You'll need to use absolute positioning for your tags. (Or switch to a different source doc format such as .docx, .html, .pdf, etc.)

It seems your document can't get processed, it is not about way you use anchor, it is document not valid

Related

DocuSign - NO_DOCUMENT_RECEIVED

When I try to send a document, an error will be generated.
Error calling CreateEnvelope: {"errorCode":"NO_DOCUMENT_RECEIVED","message":"The document element did not contain the encoded document, or there is a problem with the encoding. No documents were found in the request."}
I have already searched the internet but I can't find anything, can anyone help me.
You can find examples of how to use Base64 encoding to pass the document bytes to the eSignature REST API using the C# eSignature SDK
https://github.com/docusign/code-examples-csharp/blob/master/launcher-csharp/eSignature/Examples/SigningViaEmail.cs
Here is the relevant C# Code:
// Create document objects, one per document
Document doc1 = new Document();
string b64 = Convert.ToBase64String(Document1(signerEmail, signerName, ccEmail, ccName));
doc1.DocumentBase64 = b64;
doc1.Name = "Order acknowledgement"; // can be different from actual file name
doc1.FileExtension = "html"; // Source data format. Signed docs are always pdf.
doc1.DocumentId = "1"; // a label used to reference the doc

How can I edit the string contents of a rich text item in the clipboard in C#?

I am working on automating a process within my business, part of which is sending an email through SalesForce. We don't have access to the SF API and the email has to be sent through salesforce in order to keep the communication searchable for the coworkers.
I need to use a template which can be selected in SalesForce, however this function does not work in IE (which our RPA solution uses) so I need to build this email from scratch.
I see two options for this:
Use the HTML to recreate the format with the right variables. This entails inserting/injecting/manipulating HTML.
Copy the format into memory/the clipboard, edit it programatically and paste it into the SF interface
This question will be about option 2. I have posted an additional question with regards to the first option separately. It can be found here.
Now on to the question: I found that I can copy the text in the template from the SalesForce webpage to the clipboard (using CTRL+C) and then paste it into word, doing so will preserve the formatting and layout of the text as well as included images. I can then copy and paste this back from word to the SF webpage as well preserving the images, format and layout. This means that the formatting and image data is retained in the clipboard.
Now I need to edit the template text before I paste it into the webpage in order to use this as a solution for automation. I have been experimenting with this for the past week but I can't find a way to edit the text while preserving the formatting and layout.
I use C# and know how to GetText and SetText as wel as images (separately) from the clipboard. However the text is then a plain string without any layout and formatting. I want to replace certain keywords in the template with the required variables.
At this point I have the following code to investigate the contents of the clipboard:
// Initialise a DataObject
DataObject t = null;
try
{
// Get Data from clipboard
t = (DataObject)Clipboard.GetDataObject(); // GetData(DataFormats.Html);
// Get formats in the DataObject
string[] tFormats = t.GetFormats();
// For each format that was found create a separate object (I did this manually, I
// inspected the formats earlier by eye.
object objectDescriptor = t.GetData("Object Descriptor", true);
object rtf = t.GetData("Rich Text Format", true);
object HTMLFormat = t.GetData("HTML Format", true);
object sysString = t.GetData("System.String", true);
object unicodeText = t.GetData("UnicodeText", true);
object text = t.GetData("Text", true);
object enhancedMetafile = t.GetData("EnhancedMetafile", true);
object metaFilePict = t.GetData("MetaFilePict", true);
object embedSource = t.GetData("Embed Source", true);
object linkSource = t.GetData("Link Source", true);
object linkSourceDescriptor = t.GetData("Link Source Descriptor", true);
object objectLink = t.GetData("ObjectLink", true);
// Try replacing the text
HTMLFormat = (object)HTMLFormat.ToString().Replace("|KeyWord_A|", "Value_A");
t.SetData("HTML Format", HTMLFormat);
sysString = (object)sysString.ToString().Replace("|KeyWord_A|", "Value_A");
t.SetData("System.String", sysString);
unicodeText = (object)unicodeText.ToString().Replace("|KeyWord_A|", "Value_A");
t.SetData("UnicodeText", unicodeText);
text = (object)text.ToString().Replace("|KeyWord_A|", "Value_A");
t.SetData("Text", text);
Clipboard.SetDataObject(t);
}
catch (exception ex)
{
// Do exception handling
}
Inspecting all these objects I see that, even though they are apparently included in the DataObject, they are all null, except for HTML Format, System.String, UnicodeText and Text. Within these options the HTML Format data is the only one that appears to have some formatting data in there (I don't know where the included image is stored though). I am able to replace the keyword in that HTML Format succesfully, however if I set it back into the DataObject and then extract the HTML format again nothing has changed. The same goes for the other text items.
I also tried changing the text in the same way for all the text items. This however has the same results. If I then try to paste the clipboard contents into Word it freezes for a little while and then nothing happens.
How can I edit this DataObject? And will that actually translate into a properly formatted and layout-ed text including the image and hyperlinks, or is this approach a dead end?
Cheers!

Poor image quality when converting word docs with evo pdf

I use the WordToPdfConverter from evo to convert a Word document to a PDF. The Word document, which is in RTF format, contains images such as a QR code.
Unfortunately, the image quality in the resulting PDF is very poor (hence the QR code won't be readable). Even if I disable image compression or set it to the lowest level (=> best quality), the resulting image has a very poor quality.
Is there any other way to control the image quality? Or is there a way to tell evo's WordToPdfConverter not to use JPG as the resulting image format but to stuck with the source format (e.g. PNG)?
var pdfConverter = new WordToPdfConverter();
// Set Pdf image options
pdfConverter.PdfDocumentOptions.JpegCompressionEnabled = false;
pdfConverter.PdfDocumentOptions.JpegCompressionLevel = 0;
var filename = #"C:\temp\evo\TestWordDoc.rtf";
pdfConverter.ConvertWordFileToFile(filename, Path.Combine(Path.GetDirectoryName(filename), $"{Path.GetFileNameWithoutExtension(filename)}_{DateTime.Now:yyyyMMddHHmmss}.pdf"));
Since RTF is a text format, you should convert it to PDF without having to do any image compression as that will take longer to process and will result in a larger output file + you might have issues with the image quality from embedded images.
I created a sample RTF file (test.rtf) that contains a QR code as you described:
I then took the RTF and ran it through the Document Converter from the Leadtools.Document.sdk Nuget. Just as a disclaimer: I am associated with this library.
This document converter preserves the text and parses the images as-is from the source document, then outputs it to PDF.
You can download the output PDF from here: test.pdf
Here is some sample code:
using (var documentConverter = new DocumentConverter())
{
var filename = #"C:\temp\evo\TestWordDoc.rtf";
var document = DocumentFactory.LoadFromStream(filename, new LoadDocumentOptions());
var jobData = DocumentConverterJobs.CreateJobData(filename, Path.Combine(Path.GetDirectoryName(filename), $"{Path.GetFileNameWithoutExtension(filename)}_{DateTime.Now:yyyyMMddHHmmss}.pdf"), DocumentFormat.Pdf);
var job = documentConverter.Jobs.CreateJob(jobData);
documentConverter.Jobs.RunJob(job);
}
I am failing to see why people have issues with QR codes such as this one which is just a template (I could not download any of the older samples above for comparison.)
 
 
It is a PNG demo template file designed to be scanned from up to 4 feet away (e.g. a poster) but it could be for production, much smaller i.e. lower scale for page scanning.
I drop the RTF on the WordPad print to pdf shortcut and get the pdf shown in the viewer almost instantly.
There is some natural degradation using RTF PNG and an aliased viewer, but the key is maintaining natural scales. Every thing you need is native as supplied with windows.
MSPaint, WordPad, CMD printing I could have sent preview to the PDFium viewer in Edge.

iText 7 add header and footer in HTML to PDF

I want to add a header and a footer, which becomes repeated, to my PDF which becomes created by iText7 by converting the HTML.
However, all examples I found so far on the internet describes how to create a blank PDF by code with header and footer.
Does anybody know how I can achive this? I already tried to use the CSS print media queries to specify some areas but it seems those are ignored by iText7.
The conversion is really simple:
string input = "Bestellung.html";
string output = "Bestellung.pdf";
HtmlConverter.ConvertToPdf(new FileInfo(input), new FileInfo(output));
bestellung.html is just a plain HTML file with some demo content.
See mediaDeviceDescription under ConverterProperties.
If your input file uses this feature, then you can simply tell pdfHTML
to interpret the relevant set of rules:
ConverterProperties props = new ConverterProperties();
props.setMediaDeviceDescription(new
MediaDeviceDescription(MediaType.PRINT));
Then you call the method with this signature:
static void convertToPdf(InputStream htmlStream, PdfDocument pdfDocument, ConverterProperties converterProperties)

iText GetTextFromPage exception with inline image

I have the same problem as was discussed here, which was not solved. My objective is to extract the text from an existing pdf file. I get the error message Could not find image data or EI for a certain pdf, which I cannot share as a sample. It works for other pdfs, with the following code
string fileURI = "C:\\Test\\Sample.pdf";
PdfReader reader = new PdfReader(fileURI);
ITextExtractionStrategy strategy = new LocationTextExtractionStrategy();
string s = PdfTextExtractor.GetTextFromPage(reader, 1, strategy);
Debug.WriteLine(s);
I am using iTextSharp 5.5.0 and tried changing found == 1 to found <= 1 as suggested in other posts. It does not help.
Would it help to remove all images in the pdf? I really just need the text. Which commands from iText could help me with this?
I downloaded the trial version of Acrobat to create a version of the pdf file, that I could share. After opening the file and saving it again as "Optimized PDF" over the Acrobat, the code was working and I could extract the text.
So the solution to the problem is probably opening each file in Acrobat and saving it again with the right settings using the Acrobat reference and then extracting the text.

Categories