Page 1 of 1

Creating pdf from emf is loosing formatting

Posted: Tue Feb 24, 2015 2:43 pm
by wisniewskim
i am creating a pdf from the enhanced meta files. but after the pdf is created i am loosing the formatting from the emf's. if i have a number that is underline the underline is gone after the pdf created. here is my code and i am hoping someone will help me figure this out. Thanks.

Code: Select all

public static string CreatePdfFromIEnhanceMetaFile(List<string> filePath, string outPath)
		{
			if (filePath == null)
				throw new ArgumentNullException();

			if (outPath == null)
				throw new ArgumentNullException();
			try
			{

				int imagePdfObject;
				if (!CreateBlankDocument(out imagePdfObject))
					return string.Empty;

				//loop thru each individual pages and add them to our pdf blank document
				foreach (string filePage in filePath)
				{

					Metafile metafile = new Metafile(filePage);
					// Get the handle of the enhanced metafile.
					IntPtr hEmf = metafile.GetHenhmetafile();

					try
					{
						int iPdfImage;
						int iPdfPage;
						if (IsFailed(PdfXCFunctions.PXC_AddEnhMetafile(imagePdfObject, hEmf, out iPdfImage)))
							return string.Empty;

						
						double imageWidth;
						double imageHeight;
						if (IsFailed(PdfXCFunctions.PXC_GetImageDimension(imagePdfObject, iPdfImage, out imageWidth, out imageHeight)))
							return string.Empty;

						int updatedHeight;
						int updatedWidth;
						MakeProportionalSize(imageWidth, imageHeight, out updatedWidth, out updatedHeight);

						if (IsFailed(PdfXCFunctions.PXC_AddPage(imagePdfObject, updatedWidth, updatedHeight, out iPdfPage)))
							return string.Empty;

						if (IsFailed(PdfXCFunctions.PXC_PlaceImage(iPdfPage, iPdfImage, 0, updatedHeight, updatedWidth, updatedHeight)))
							return string.Empty;
					}
					finally
					{
						//delete the handle
						DeleteEnhMetaFile(hEmf); //free handle  
					}

				}
				//now write to a document if we fail return empty string
				if (!WriteDocumentExA(outPath, imagePdfObject))
					return string.Empty;
			}
			catch (Exception)
			{
				return string.Empty;
			}

			return outPath;
		}

Re: Creating pdf from emf is loosing formatting

Posted: Tue Feb 24, 2015 4:08 pm
by Tracker Supp-Stefan
Hello wisniewskim,

Welcome to our forums and thanks for the code snippet. Can we also get a sample of an .emf and the resulting PDF please so that I can ask our devs to take a look?

Regards,
Stefan

Re: Creating pdf from emf is loosing formatting

Posted: Tue Feb 24, 2015 4:45 pm
by wisniewskim
I have attached an EMF file with formatting as a ZIP. When the above code is run the line underneath the amount is missing from the final PDF.

Re: Creating pdf from emf is loosing formatting

Posted: Tue Feb 24, 2015 6:18 pm
by wisniewskim
sorry did not realize i did not attach all the files. Here is a zip with emfs and the produced pdf file. Thanks for your help.

Re: Creating pdf from emf is loosing formatting

Posted: Wed Feb 25, 2015 12:08 pm
by Tracker Supp-Stefan
Hi wisniewskim,

Thanks for the full sample, but as it's a 9 page document with quite some text in it - can you please point us to a particular area of a particular page where the underline has disappeared so that I can pass this to my colleagues in development to take a look?

Regards,
Stefan

Re: Creating pdf from emf is loosing formatting

Posted: Wed Feb 25, 2015 12:39 pm
by wisniewskim
Hi Stefan,

Thanks for your time and reply. You can look at the emf files FCD8566(2).emf , FCD859B(4).emf, FCD8617(9) and FCD85E2(7).emf. they all have missing underlines.

Thanks

Re: Creating pdf from emf is loosing formatting

Posted: Wed Feb 25, 2015 3:42 pm
by Tracker Supp-Stefan
Thanks wisniewskim,

I've asked one of the Tools SDK devs to take a look at this.

Regards,
Stefan

Re: Creating pdf from emf is loosing formatting

Posted: Wed Feb 25, 2015 4:58 pm
by wisniewskim
thanks.

Re: Creating pdf from emf is loosing formatting

Posted: Thu Feb 26, 2015 4:07 pm
by Tracker Supp-Stefan
You are welcome wisniewskim,

Just an update that I am still awaiting the feedback from my colleague (Ivan) and as soon as I have that - I will post here.

Regards,
Stefan

Re: Creating pdf from emf is loosing formatting

Posted: Fri Feb 27, 2015 9:24 am
by Tracker Supp-Stefan
Hello wisniewskim,

My colleague has confirmed that the issues with your files are now fixed, and the fix will apply to both the PDF Tools (and SDK), as well as the PDF XChange Editor. It will be available for you to download with the next build.

Regards,
Stefan

Re: Creating pdf from emf is loosing formatting

Posted: Fri Feb 27, 2015 12:16 pm
by wisniewskim
Hello Stefan,

Thanks you so much for your reply and fix. we really appreciate your help. Do you know the exact time when the build be be out? Thanks again.

Meera

Re: Creating pdf from emf is loosing formatting

Posted: Fri Feb 27, 2015 12:23 pm
by Tracker Supp-Stefan
Hi Meera,

I don't have any exact date at this moment unfortunately. We will try to make it as soon as possible but there are other things that need to be done before build 313 can be released so it might be a few weeks.

Regards,
Stefan

Re: Creating pdf from emf is loosing formatting

Posted: Fri Feb 27, 2015 12:25 pm
by wisniewskim
sounds good. thanks.

Re: Creating pdf from emf is loosing formatting

Posted: Fri Feb 27, 2015 12:57 pm
by Tracker Supp-Stefan
:)

Re: Creating pdf from emf is loosing formatting

Posted: Sun Apr 05, 2015 1:31 pm
by wisniewskim
Hi i was wondering if this is fixed and released yet. Thanks.

Meera

Re: Creating pdf from emf is loosing formatting

Posted: Mon Apr 06, 2015 4:09 pm
by Will - Tracker Supp
Hi Meera,

Thanks for the post - I'm afraid that build 313 hasn't been released yet, as we're still working on the Editor SDK Documentation. We're looking at later this month, unless something major stops us.

Cheers,