Saving a Word document as PDF/A from the Word Object Model
-
17 martie 2011 15:10
Hi
Word 2010 has support for saving docx-files as pdf (and pdf/a). Saving as PDF from code using the object model is as simple as:
_currentDocument.SaveAs2(FileName:=path, FileFormat:=Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatPDF)
..but how do you specify that you want the pdf/a option? When doing it in the Word GUI you have to click an "Options" button after selecting the PDF-format in the dropdown list in the Save As dialog. Clicking that button shows a form where you can specify the pdf/a format. Is there any way to do the same thing from code?
Best regards
Anders Granåker
Toate mesajele
-
21 martie 2011 06:55Moderator
Hi a_granaker,
Thanks for posting in the MSDN Forum.
Would you please clarify where you want to call the SaveAs2 method? If you call this method in an Office automatic project, you’re able to create a combo box and fill it with File save format enumeration. If you call it in a VSTO add-in project’s ribbon button click event, you are able to create a winform window and create a combo box and fill it with File Save format enumeration or create a dropdown control in the ribbon and fill it with File save format enumeration.
If I have misunderstood anything, please free to let me know.
Have a good day,
Tom
Tom Xu [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.

- Marcat ca răspuns de Tom_Xu_WXModerator 28 martie 2011 09:41
-
30 martie 2011 09:32
Hi
I have the same target, I need to save a doc as PDF/A, in this case from a VSTO document level customization. So what is the simplest way to set the "ISO 19005-1 compliant (PDF/A)" option on when calling the SaveAs method with wdFormatPDF from C# code?
Br Ari Hakaste
-
5 aprilie 2012 07:00
Hi
I wrote a VBscript with a SaveAs method, but would like to set the "ISO 19005-1 compliant (PDF/A)" option. Does anyone know how to force PDF/A option?
Regards,
David
-
3 iunie 2012 17:07
Hi,
For future reference: There simply is no PDF/A-option with the Document.SaveAs() method.
All you can do with this method is to pass a WdExportFormat parameter, and that's all. In order to convert a Word document to a PDF/A compatible PDF file, you will want to use instead the method Document.ExportAsFixedFormat().
And here is how you would do it from C# (using Microsoft.Office.Interop.Word.dll):document.ExportAsFixedFormat(OutputFileName: pdfFileName, ExportFormat: WdExportFormat.wdExportFormatPDF, OpenAfterExport: true, UseISO19005_1: true);
Hope this helps
Marcel