Hello,
I am writing a program that converts a word to a pdf in c#.
The problem now is that when a metaproperty is empty it will show the DisplayName of the property when converting to pdf.
Here is how it looks in word:
And in the converted pdf it will look the same.
Is there maybe a way to remove a meta property if its empty?
(I know the way to check if a meta property is empty https://help.syncfusion.com/file-formats/docio/working-with-word-document#working-with-content-type-properties )
For people that dont know what i mean with metaproperties there are also called Quick Parts:
Use Quick Parts and AutoText in Word and Outlook (microsoft.com)
MyCode: static void Main(string[] args) { FileStream fileStream = new FileStream( - Pastebin.com
Best Regards
Nils
Hi Nils,
From the given details, we have found that your requirement is to remove the placeholder text if the meta
property is empty.
In Microsoft Word application, if the meta property value is empty means, it displays
the placeholder text. This is the default behaviour. So, it is not feasible to remove the placeholder
text if the meta property is empty using the API of DocIO library.
Currently we are checking the feasibility to provide any workaround solution to
achieve your requirement is to remove the placeholder text if the meta property
is empty while converting Word document to PDF. We will share the further
details about this on or before 23rd September 2022.
Regards,
Suriya
Balamurugan.
Hello,
thank you for the quick answer.
My first approach was to just set the meta property value when empty to " " with spaces.
This works for some meta property types, but I think this isn't the best solution to fix this problem.
Also, this workaround doesn't work to meta properties of the type Date. And my word has Date type properties.
Another though was to change the Displayname/placeholder but this doesn't work because metaproperty.Displayname is get only. And even if this would have worked it will probably show "[ ]".
I added a word file to test the problem.
Thank you for helping me with this problem.
Best regards,
Nils
Hi Nils,
Thank you for your update.
The meta property is displayed as a content control in the Word document.
To achieve your requirement, as a workaround, we have suggested you to iterate
through the Word document elements and get the content control. Then ensure
whether the content control is mapped with meta property and its value is empty
means delete the content control from the Word document.
We have prepared the sample application to achieve your requirement and it can
be downloaded from the below attachment.
Note:
1. Please find the input template Word document in the “Data” folder of the
attached sample application.
2. Your word file attachment in the previous
update is an empty folder. So, we unable to use it in this workaround sample
application.
In this sample, we have done the following things.
1. Open the template Word document.
2. Iterate through Word document element
to get content control.
3. Ensure whether the content control is
mapped with meta property and its value is empty means delete the content
control from the Word document.
4. Convert Word document to PDF.
Please refer our UG documentation link to know more about content control in Word
document,
https://help.syncfusion.com/file-formats/docio/working-with-content-controls
Regards,
Suriya
Balamurugan.
Hi Suriya Balamurugan,
when i was trying out the solution alot more i found out that syncfusion can't detect some metaproperty inside of a Office table.
I though its an issue on my side but when i debuged through the wordfile i found out that syncfusion wont detect it as a metaproperty.
At the attachment you will find a docx to test the problem. Also in regards to my other forum thread: link
it seams like sometimes the date format also wont convert correctly. As you can see in my mockdata example i put a date field in it but for some reason it works on this file. If nessasary i can provide another mock file to test that problem too but i think something gets messed up on the pdf convertion of tables an metaproerties.
It would be great if you could provide a fix for that issue.
Best regards
Nils
Attachment: Test4Mock_f90452ed.zip
edit: about the date format problem talked above. I found out that it has something to do with how the metaproperty saves the date and in which format. It looks like syncfusion doesn't know what the ATOM, RFC 3339 or W3C format is.
Here:
EndContract format works
ValidFrom doesnt
Filename: docfile/customXml/item1.xml
<documentManagement>
<EndContract xmlns="6aa3f7a0-5246-4ff6-b3f0-af2bc0f7a6a1">2022-10-14T00:00:00</DtcEndContract>
<ValidFrom xmlns="6aa3f7a0-5246-4ff6-b3f0-af2bc0f7a6a1">2022-10-13T07:00:00+00:00</DtcValidFrom>
</documentManagement>
Hi Nils,
On analyzing the given input Word document, we have found that there is a
CellContentControl. Currently DocIO provides preservation support alone for
RowContentControl and CellContentControl and it doesn’t provide any API to
extract and modify RowContentControl and CellContentControl. We have considered
this scenario as a content control enhancement work and already logged this as
a feature request in our database. We don’t have any immediate plans to
implement this feature. We will update you once this feature has been
implemented.
The status of this feature can be tracked through below feedback link:
https://www.syncfusion.com/feedback/3119/support-for-cell-row-and-group-content-controls
As a workaround, we suggest you to insert the InlineContentControl as a child
entity of the paragraph of the cell in the table or BlockContentControl as a
child entity of the cell in the table in the input Word document and then you
can retrieve the InlineContentControl or BlockContentControl inside the cell to
remove the empty meta property using our previous solution. We have modified
the given input Word document and it can be downloaded from the below link:
https://www.syncfusion.com/downloads/support/directtrac/general/doc/Test4Mock_Modified404966935
Regarding: Other forum thread link
- sometimes the date format also wont convert correctly
We have tried to
reproduce the reported problem using the given details, but we unable to
reproduce the mentioned issue at our end.
We suspect that the problem might be due to the contents in the input Word
document which used at your end. So, could you please provide us the input
Word document from your end, which will be helpful to reproduce the exact
issue at our end. Thereby we will analyze further and provide you the
appropriate solution at the earliest.
Note: If you have any confidential data in your Word document, please
replace with some dummy data and provide us the same. We just need your
document to recreate the problem you face.
Please share the requested details about this date format issue in this
corresponding forum thread: link
for better follow up.
Regards,
Suriya Balamurugan.