Page 1 of 1

Burning annotations to docx fails

Posted: Tue Dec 12, 2017 4:17 pm
by mgolland
Hi,

In GDPicture 14, I am able to add and save annotations to a .docx file, but when I try to burn the annotations to a .docx for exporting I always seem to end up with a blank document.

I think this is because I am trying to create a gdpictureimage object from the .docx stream (before calling BurnAnnotationsToPage) which returns 0 and creates a status of 'UnknownImageFormat'.

Code looks like:

Code: Select all

var gdImageId = gdImaging.CreateGdPictureImageFromStream(originalDocumentStream, GdPicture14.DocumentFormat.DocumentFormatOpenXMLWord);

oAnnotationManager.LoadAnnotationsFromXMP(annotationsStream);
for (var i = 1; i <= gdImaging.GetPageCount(gdImageId); i++)
{
	oAnnotationManager.SelectPage(i);
	oAnnotationManager.BurnAnnotationsToPage(true, false);
}

Thanks,

Mark

Re: Burning annotations to docx fails

Posted: Mon Jan 21, 2019 10:54 am
by Gabriela
Hello,

You can't open a DOCX document using the GdPictureImaging class and it is the same for PDF documents as well. Those documents are not images, they need to be properly open first and then converted to an actual image which is the missing step here. The best way to proceed is to convert to TIFF since it does support multipage so I would do something like this:

Code: Select all

using (GdPictureDocumentConverter converter = new GdPictureDocumentConverter())
{
	GdPictureStatus status = converter.LoadFromStream(originalDocumentStream, GdPicture14.DocumentFormat.DocumentFormatOpenXMLWord);
	if (status == GdPictureStatus.OK)
	{
		Stream convertedDocumentStream = new MemoryStream();
		status = converter.SaveAsTIFF(convertedDocumentStream, TiffCompression.TiffCompressionAUTO);
		if (status == GdPictureStatus.OK)
		{
			var gdImageId = gdImaging.CreateGdPictureImageFromStream(convertedDocumentStream, GdPicture14.DocumentFormat.DocumentFormatTIFF);
			// your annotation code part
		}
	}
}