Burning annotations to docx fails

Discussions about Office OpenXML & Open Document formats support.
Post Reply
mgolland
Posts: 7
Joined: Tue May 10, 2016 10:48 am

Burning annotations to docx fails

Post by mgolland » Tue Dec 12, 2017 4:17 pm

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

Gabriela
Posts: 436
Joined: Wed Nov 22, 2017 9:52 am

Re: Burning annotations to docx fails

Post by Gabriela » Mon Jan 21, 2019 10:54 am

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
		}
	}
}

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests