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
Related
I'm creating WordprocessingDocuments in C# with the Open XML SDK and then converting them to pdf. Initially, I was using Interop to save the document in PDF format, but now that is not an option. I found that LibreOffice can convert documents calling soffice.exe from cmd, and I had wonderful results with normal documents. Still, then, when I tested LibreOffice converter with my dynamic documents, the converter crashed.
I copied one of these documents and opened it with LibreOffice Writer, its structure was wrong, then I opened the same document with Microsoft Word and its structure was fine. Finally, I saved it with Microsoft Word and opened both documents as ZIP files as below:
This is the good one:
And this is the bad one:
I noticed that when I save the document in Microsoft Word, these Open XML parts (which I called "files" in an earlier version of this question) are appearing. When I open the document previously saved with Microsoft Word in LibreOffice, the document is fine again.
Thus, is there a way to generate these Open XML parts (inside the Word document) without opening Microsoft Word?
I use the following code (to check if it is creating all the files):
using (MemoryStream mem = new MemoryStream())
{
// Create Document
using (WordprocessingDocument wordDocument =
WordprocessingDocument.Create(mem, WordprocessingDocumentType.Document, true))
{
// Add a main document part.
MainDocumentPart mainPart = wordDocument.AddMainDocumentPart();
// Create the document structure and add some text.
mainPart.Document = new Document();
Body docBody = new Body();
// Add your docx content here
CreateParagraph(docBody);
CreateStyledParagraph(docBody);
CreateTable(docBody);
CreateList(docBody);
Paragraph pImg = new Paragraph();
ImagePart imagePart = mainPart.AddImagePart(ImagePartType.Jpeg);
string imgPath = "https://cdn.pixabay.com/photo/2019/11/15/05/23/dog-4627679_960_720.png";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(imgPath);
req.UseDefaultCredentials = true;
req.PreAuthenticate = true;
req.Credentials = CredentialCache.DefaultCredentials;
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
imagePart.FeedData(resp.GetResponseStream());
// 1500000 and 1092000 are img width and height
Run rImg = new Run(DrawingManager(mainPart.GetIdOfPart(imagePart), "PictureName", 1500000, 1092000, string.Empty));
pImg.Append(rImg);
docBody.Append(pImg);
Paragraph pLink = new Paragraph();
// For the mainpart see above
pLink.Append(HyperLinkManager("http://YourLink", "My awesome link", mainPart));
docBody.Append(pLink);
mainPart.Document.Append(docBody);
mainPart.Document.Save();
wordDocument.Close();
}
result = Convert.ToBase64String(mem.ToArray());
}
The code above creates a Word document named Result.docx with the following structure:
But there aren't any other Open XML parts (like app.xml or styles.xml)
You need to make a difference between:
the Open XML standard and its minimum requirements on a WordprocessingDocument and
the "minimum" document created by Microsoft Word or other applications.
As per the standard, the minimum WordprocessingDocument only needs a main document part (MainDocumentPart, document.xml) with the following content:
<w:document xmlns:w="...">
<w:body>
<w:p />
</w:body>
</w:document>
Further parts such as the StyleDefinitionsPart (styles.xml) or the NumberingDefintionsPart (numbering.xml) are only required if you have styles or numbering, in which case you must explicitly create them in your code.
Next, looking at your sample code, it seems you are creating:
paragraphs that reference styles (see CreateStyledParagraph(docBody)), which would have to be defined in the StyleDefinitionsPart (styles.xml); and
numbered lists (e.g., CreateList(docBody)), which would have to be defined in the NumberingDefinitionsPart (numbering.xml).
However, your code neither creates a StyleDefinitionsPart nor a NumberingDefintionsPart, which means your document is likely not a valid Open XML document.
Now, Word is very forgiving and fixes various issues silently, ignoring parts of your Open XML markup (e.g., the styles you might have assigned to your paragraphs).
By contrast, depending on how fault-tolerant LibreOffice is, invalid Open XML markup might lead to a crash. For example, if LibreOffice simply assumes that a StyleDefinitionsPart exists when it finds an element like <w:pStyle w:val="MyStyleName" /> in your w:document and then does not check whether it gets a null reference when asking for the StyleDefinitionsPart, it could crash.
Finally, to add parts to your Word document, you would use the Open XML SDK as follows:
[Fact]
public void CanAddParts()
{
const string path = "Document.docx";
const WordprocessingDocumentType type = WordprocessingDocumentType.Document;
using WordprocessingDocument wordDocument = WordprocessingDocument.Create(path, type);
// Create minimum main document part.
MainDocumentPart mainDocumentPart = wordDocument.AddMainDocumentPart();
mainDocumentPart.Document = new Document(new Body(new Paragraph()));
// Create empty style definitions part.
var styleDefinitionsPart = mainDocumentPart.AddNewPart<StyleDefinitionsPart>();
styleDefinitionsPart.Styles = new Styles();
// Create empty numbering definitions part.
var numberingDefinitionsPart = mainDocumentPart.AddNewPart<NumberingDefinitionsPart>();
numberingDefinitionsPart.Numbering = new Numbering();
}
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
I am using AsposePDF for .Net version 17.3 for bulk conversion of lot of html files to PDF. I have an existing html file with hyperlinks to content in same file. Below is a sample of the html in the file.
Link:
Section 5
Content:
<a name="#bg880016"><p>section 5 content is here</p></a>
When this is converted to PDF the local links are not working anymore. Below is the conversion code:
public Stream ConvertHtmlToPDF(Stream inputStream, string docTitle)
{
Stream pdfStream = new MemoryStream();
inputStream.Position = 0;
var options = new HtmlLoadOptions();
var pdfDocument = new Aspose.Pdf.Document(inputStream, options);
pdfDocument.Info.Title = docTitle;
pdfDocument.Save(pdfStream);
}
Any help is much appreciated. I have also posted a question in their support forum.
I've found you need to convert it first to a Word document and then convert that to a PDF to get it to work as desired. Do you have Aspose.Words also?
I am working on a project in visual studio that imports a CSV, and exports an XML file. I'd like to be able be able to get the code to work as XML and HTML, and view it in a browser. I am getting this error when I load the XML file into a browser:
Firefox
XML Parsing Error: not well-formed
Location: file:///C:/Users/fenwky/XmlDoc.xml
Line Number 2, Column 6:<?xsl:stylesheet <abc:stylesheet xmlns="http://www.w3.org/1999/XSL/Transform" version="1.0">?>
Chrome
This page contains the following errors: error on line 2 at column 16: colon are forbidden from PI names 'xsl:transform'
This is what my c# code looks like in visual studio 2013:
// Create a procesing instruction.
XmlProcessingInstruction newPI;
// Stylesheet
String PItext = "<abc:stylesheet xmlns:abc=\"http://www.w3.org/1999/XSL/Transform\" version=\"1.0\">";
newPI = doc.CreateProcessingInstruction("abc:stylesheet", PItext);
doc.InsertAfter(newPI, doc.FirstChild);
// Save document
doc.Save(xmlfilename);
If you are trying to insert an processing instruction into the XML, the data parameter of the CreateProcessingInstruction method does not need to contain the name of the processing instruction in this case. In other words you just need to do this...
var PItext = "xmlns:abc=\"http://www.w3.org/1999/XSL/Transform\" version=\"1.0\"";
var newPI = doc.CreateProcessingInstruction("abc:stylesheet", PItext);
doc.InsertAfter(newPI, doc.FirstChild);
However, I am wondering why you are trying to add this particular processing instruction to an XML document. Perhaps you mean to link an XML document to a separate XSLT document, so it will be transformed if read by a browser?
If so, you probably need to be doing this...
var piText = "type=\"text/xsl\" href=\"style1.xsl\"";
var newPI = doc.CreateProcessingInstruction("xml-stylesheet", piText);
doc.InsertAfter(newPI, doc.FirstChild);
This will write the following processing instruction to the XML, which can then be read by the browser:
<?xml-stylesheet type="text/xsl" href="style1.xsl"?>
I am retrieving a .docx file as a byte array. I am then trying to call the Doc’s read() function with said byte array as the data parameter but I am getting an unrecognized file extension error.
I retrieve the byte array with the following (c#) code:
WebClient testWc = new WebClient();
testWc.Credentials = CredentialCache.DefaultCredentials;
byte[] data = testWc.DownloadData("http://localhost/Lists/incidents/Attachments/1/Testdocnospaces.docx");
IF at this point I output the byte array as a .docx file, my program will correctly allow me to open or save the file. For this reason, I believe the byte array has been retrieved correctly. Here is a sample of what I mean by outputting a .docx file:
Response.ClearHeaders();
Response.Clear();
Response.AppendHeader("Content-Disposition", "attachment;Filename=test.docx");
Response.BinaryWrite(data);
Response.Flush();
Response.End();
However, if I try to read the byte array into a Doc like so:
Doc doc = new Doc();
XReadOptions xr = new XReadOptions();
xr.ReadModule = ReadModuleType.MSOffice;
doc.Read(data, xr);
My program will error out at the last line of said code, throwing the following: “FileExtension '' was invalid for ReadModuleType.MSOffice.”
The Doc.Read() function seems to be finding an empty string where it would typically be finding the file type.
Also, I do have Office 2007 installed on this machine.
If you know the file extension of your file bytes (which you should) you can solve your problem by:
Doc doc = new Doc();
string extension = Path.GetExtension("your file name/path").Substring(1).ToUpper();
XReadOptions opts = new XReadOptions();
opts.FileExtension = extension;
doc.Read(fileBytes, opts);
This approach worked for me. When you provide correct file extension you won't need to set ReadModule property of your XReadOptions object. ToUpper() is not mandatory.