Free Support Forum - groupdocs.com

Render to PDF from stream


#1

Hi,

is it possible to render pdf-file from stream?

This is my example how it can to work.
But i can`t get GUID as string and FileContainer expect a guid as string.
public static Stream RenderDocumentAsPDF(Stream DocumentName)
{
Utilities.ApplyLicense();
ViewerImageHandler imageHandler = new ViewerImageHandler(Utilities.GetConfigurations());

PdfFileOptions options = new PdfFileOptions();
Stream guid = DocumentName;
FileContainer container = imageHandler.GetPdfFile(DocumentName, guid, options);
String filename = Path.GetFileNameWithoutExtension(DocumentName.ToString()) + “.pdf”;
Utilities.SaveFile(filename, container.Stream);
return container.Stream;
}



#2

Hi there,


Thanks for posting your issue.

Yes, GroupDocs.Viewer for .NET also provides overloaded GetPdfFile() methods which accept File Stream without using string guid. You can use any of the following methods.

imageHandler.GetPdfFile(Stream s, PdfFileOptions options)
imageHandler.GetPdfFile(Stream s)

Please try and share your feedback.

Warm Regards

#3

Hi,


without guid its works.
But I get more than one file from server and without guid I dont hava a document that is unique. The result without guid is that alle the file will be overwritten.

#4

Hi there,


To accomplish this, you can use unique guid generated by GroupDocs.Viewer API. You can get this guid using following method.

DocumentInfoContainer info = htmlHandler.GetDocumentInfo(stream);
string guid = info.Guid;

Try this and share you feedback.

Have a nice weekend ahead.