Hi,
Is it possible to convert document(doc/docx) byte[] array to .pdf byte array directly.
Currently, i have coded something like this…
Stream s = new MemoryStream(content);
Document doc = new Document(s);
doc.Save(@"C:\Test\Out.pdf", SaveFormat.Pdf);
But, i do not want to it be saved to a locally. I just want to get the byte[] array of the pdf content.
Thanks and Regards,
Manjunath
Hi Andrey,
I have a byte array of .docx document and I need to convert this byte array of .docx to pdf byte array.
I need a function like which accepts byte array of .docx document and return byte array of pdf document.
Is that possible?
And How?
Hi John,
Thanks for your inquiry. Sure, you can achieve this by using the following code:
// Open the stream. Read only access is
enough for Aspose.Words to load a document.
Stream stream = File.OpenRead("C:\\Temp\\Document.docx");
// Load the entire document into memory.
Document doc = new Document(stream);
// You can close the stream now, it is no longer needed because the document is in memory.
stream.Close();
MemoryStream dstStream = new MemoryStream();
doc.Save(dstStream, SaveFormat.Pdf);
// Rewind the stream position back to zero so it is ready for next reader.
dstStream.Position = 0;
I hope, this helps.
Best regards,
Thanks a lot Awais,
I’m using aspose for Online Microsoft Dynamics CRM 2013 which has sandboxed(cant access local machine’s drive/file) functionality.
The above code works fine for Onpremise(can access local machine drives/files) Microsoft Dynamics CRM 2013.But It gives exception for Online Microsoft Dynamics CRM 2013.
The Exception details are as follows:
Exception: Microsoft.Crm.CrmException: Unexpected exception from plug-in (Execute): Request for the permission of type ‘System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’ failed.
at Microsoft.Crm.Sandbox.SandboxCodeUnit.Execute(IExecutionContext context)
at Microsoft.Crm.Workflow.Services.ProxyCustomActivity.Execute(CodeActivityContext executionContext)
Any Suggestion???
Thanks Awais,
Yes,the problem is due to sandbox registration(partial trusted) of Online Microsoft Dynamics CRM 2013.But We can register Custom Workflow in sandbox mode only for Online.
Is there any different version of Aspose which works in Sandbox mode of Online Microsoft Dynamics CRM 2013 to convert .docx byte array to .pdf byte array.
Hi John,
Thanks for your inquiry. I am afraid, there is no separate version for Microsoft Dynamics CRM. Please note that Aspose.Words is a CLS compliant .NET assembly, written entirely in C# and it will work under the Partial Trust in case you use it to generate, modify or convert documents in any format except PDF or XPS. However, if you need to use Aspose.Words to convert documents to PDF, XPS or render images of pages, you need to run your application under Full Trust because Aspose.Words needs to enumerate and read TrueType fonts installed on the computer. For more information about TrueType fonts see How Aspose.Words Uses TrueType Fonts. Alternatively, if you are unable to run your application at full trust, may be you should specify your own folders where Aspose.Words will look for fonts and place your fonts in there. For details on how to achieve this, see the How-to: Specify True Type Font Location article. I hope, this helps.
Best regards,