I am trying to convert an emf file to pdf, the converted pdf has 8.5x11" page and emf image scaled down and inserted into this page, but I would like to get the image in pdf in it’s original size, Is it possible ? if yes, How can I do that ?
(or), Alternatively, if I can convert this emf file to PNG in it’s original dimensions that is also fine. Please can some one help on this topic ?
Can you upload the EMF file here for testing?
I could not attach emf file here, I am attaching test png here the problem can be reproduced with the png also. Please check, if you think we might go into a wrong direction with the png file then let me know How can I send an emf for testing.
You can change the file-extension from EMF to PNG or PDF.
Now it can upload. Thanks.
I have only a few .emf files here. I opened Draw, clicked File > Open to navigate to and open the .eml in Draw. Where the .emf was small, I could select and drag out the emf by the corner handle to fit inside the page size. Exporting the larger image to pdf works.
I did notice some variations in appearance of the emf between Draw, Illustrator, MS Office 2010 and Inkscape. You might be better to consider exporting the .emf to .svg for future compatibility, tick the Selection box to export just the object
Thank you, I think, I need to elaborate more what I need to achieve.
I would like to convert emf to PDF/PNG(preferably PDF) using soffice headless convert and I would like to have the original image in the pdf should be in it’s original dimensions but currently if I use a large emf and convert to pdf using headless --convert-to pdf , the pdf page size is always A4/letter ( I think this is based on the locale setting ( Tools->Options->Language Settings->Languages->locale settings->Default-English(USA)) and the image in the pdf page is scaled down and fits in this A4 paper size,Is there any way to get the pdf with original emf dimensions using headless --convert-to pdf ?
Sorry, I have no experience with headless conversion and can’t help with this.
But It looks like, It is not possible with libre office Draw also without changing anything manually(dragging the image). Even if we change manually I don’t think we can match exactly with the original dimensions.
If you set the page size to be larger than the .emf, doesn’t the .emf take its original size? I have only one that is larger than A4 width (23.39 cm) and if I set the page size to A3 it takes only its original width, not the full page. On A4 page it is only as wide as the margins.
Importing a file, we should keep as much of its information as possible. If the (image) file somehow defines its size (not all do), then we should not use some default page size, but take the size from file. Not doing so would be a bug, that needs filing, and fixing.
Note that you still haven’t provided the EMF, as @Hrbrgr suggested (changing the file extension to please the site). That would be needed to see if the file actually defined the size.
You can download the sample emf file from here Files | Adobe Creative Cloud , I have also attached expected pdf here.
Test_Emf_1_Expected.pdf (861.3 KB)
I have already logged the bug 156693 – Convert to pdf with page size same as original input image/page size(real desire is from Emf to pdf)
But I am checking here if there are any config options(which I may not aware) to control the page size as same as input file dimensions.
I changed the file extension from PDF to EMF.
Then in my case these are the values of the EMF, exported from Draw as PDF:
With me:
Version: 7.6.0.3 (X86_64) / LibreOffice Community
Build ID: 69edd8b8ebc41d00b4de3915dc82f8f0fc3b6265
CPU threads: 8; OS: Windows 10.0 Build 19045; UI render: Skia/Raster; VCL: win
Locale: de-DE (de_DE); UI: de-DE
Calc: CL threaded
Take the emf file from here Files | Adobe Creative Cloud and convert to PDF using libre office draw and compare this pdf with the one I have attached as Test_Emf_1_Expected.pdf
Heh!
The file (70.7 MiB) contains this information (first EMF records):
Horizontal-Resolution = 602,5116
Vertical-Resolution = 600,8601
Frame-Width = 33730,21
Frame-Height = 19027,23
Bounds-Width = 8001pix
Bounds-Height = 4501pix
■ 000-EmfHeader: At=0, TotalLength=108Bytes, DataLength=100Bytes
Bounds: Lft=-1, Top=-1, Rgt=8000, Btm=4500
Frame: Lft=-3, Top=-3, Rgt=33723, Btm=19020
Device: Wdt=5100, Hgh=6600
Millimeters: Wdt=215, Hgh=279
Version: Major=1, Minor=0
◙ 001-EmfGdiComment: At=108, TotalLength=44Bytes, DataLength=36Bytes
► EmfPlusCommentIdentifier: EMF+
● 00 EmfPlusCommentType: EmfPlusHeader
Size: RecordSize=28, DataSize=16
Resolution: DpiX=600, DpiY=600
Meta-data: Signature=DBC01, GraphicsVersion=GraphicsVersion1_1
If you look at it, it is clear why you expect what you posted as “attached expected pdf”. That PDF contains a page 956 x 539.3 pt. The original EMF, that has the bounds of 8001 x 4501 px, at ~600 PPI, becomes that pt size.
But the EMF also specifies the device dimensions of 5100 x 6600 px (at 600 PPI, that is 8.5 x 11 in, which matches the millimeter size mentioned there). The “device” in EMF represents the output surface (e.g., paper); while bounds are simply “the smallest rectangle that can be drawn around the image stored in the metafile”. Hence, it is more correct to use the Letter size … but its’ not done correctly, because the bounds are larger than the device, and unlike the device, the bounds are landscape. Additionally, LibreOffice does not use the device dimensions at all, but the default page size - e.g., on my metric locale, I see the imported image on an A4 page.
As I wrote in your bug report, it is a reasonable request. Now we only need someone having energy to do it
Thanks Mike for the detailed explanation, could you please tell me where can I look inthe source code to figure out the fix for this , I know it is difficult for my knowledge but would like to check once.
Also, how did you get the complete emf details which you pasted above ?
Sorry, would need to dig into that, and I can’t invest into this. I can only suggest you to start with building the code, which is itself quite a task; then you can have some mentoring, that TDF provides. I suppose that after that, you would be ready to search that yourself.
I used this tool: Parse, understand and demystify Enhanced Meta Files (EMF) with C# - CodeProject