Creating pdf from emf is loosing formatting

This Forum is for the use of Software Developers requiring help and assistance for Tracker Software's PDF-Tools SDK of Library DLL functions(only) - Please use the PDF-XChange Drivers API SDK Forum for assistance with all PDF Print Driver related topics or PDF-XChange Viewer SDK if appropriate.

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Tracker Supp-Stefan

Post Reply
wisniewskim
User
Posts: 8
Joined: Tue Feb 24, 2015 2:14 pm

Creating pdf from emf is loosing formatting

Post 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;
		}
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17818
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Creating pdf from emf is loosing formatting

Post 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
wisniewskim
User
Posts: 8
Joined: Tue Feb 24, 2015 2:14 pm

Re: Creating pdf from emf is loosing formatting

Post 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.
Attachments
FCD3817(3).zip
Here is the emf file in a zip.
(2.43 KiB) Downloaded 231 times
wisniewskim
User
Posts: 8
Joined: Tue Feb 24, 2015 2:14 pm

Re: Creating pdf from emf is loosing formatting

Post 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.
Attachments
FCD8617(9).zip
(86.88 KiB) Downloaded 231 times
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17818
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Creating pdf from emf is loosing formatting

Post 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
wisniewskim
User
Posts: 8
Joined: Tue Feb 24, 2015 2:14 pm

Re: Creating pdf from emf is loosing formatting

Post 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
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17818
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Creating pdf from emf is loosing formatting

Post by Tracker Supp-Stefan »

Thanks wisniewskim,

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

Regards,
Stefan
wisniewskim
User
Posts: 8
Joined: Tue Feb 24, 2015 2:14 pm

Re: Creating pdf from emf is loosing formatting

Post by wisniewskim »

thanks.
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17818
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Creating pdf from emf is loosing formatting

Post 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
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17818
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Creating pdf from emf is loosing formatting

Post 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
wisniewskim
User
Posts: 8
Joined: Tue Feb 24, 2015 2:14 pm

Re: Creating pdf from emf is loosing formatting

Post 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
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17818
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Creating pdf from emf is loosing formatting

Post 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
wisniewskim
User
Posts: 8
Joined: Tue Feb 24, 2015 2:14 pm

Re: Creating pdf from emf is loosing formatting

Post by wisniewskim »

sounds good. thanks.
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17818
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Creating pdf from emf is loosing formatting

Post by Tracker Supp-Stefan »

:)
wisniewskim
User
Posts: 8
Joined: Tue Feb 24, 2015 2:14 pm

Re: Creating pdf from emf is loosing formatting

Post by wisniewskim »

Hi i was wondering if this is fixed and released yet. Thanks.

Meera
User avatar
Will - Tracker Supp
Site Admin
Posts: 6815
Joined: Mon Oct 15, 2012 9:21 pm
Location: London, UK
Contact:

Re: Creating pdf from emf is loosing formatting

Post 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,
If posting files to this forum, you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded.
Thank you.

Best regards

Will Travaglini
Tracker Support (Europe)
Tracker Software Products Ltd.
http://www.tracker-software.com
Post Reply