EVOPDF を使用して HTML -> PDF 生成ファイルにいくつかの属性を設定しようとしています。
PdfDocumentInfo プロパティを設定するのはかなり簡単に思えます。ドキュメントで指定されているとおり: http://www.evopdf.com/help/azure-html-to-pdf/html/T_EvoPdf_HtmlToPdfClient_PdfDocumentInfo.htm
ただし、Adobe Acrobat Reader で [ファイル] -> [プロパティ] を表示すると、空のボックスが表示されます。また、Hex エディターもデータを見つけられません。
http://www.evopdf.com/download.aspxからダウンロードした「EvoHtmlToPdfDemo_VS2013」v6.4 ソリューションを試し ましたが、ソリューション全体に PdfDocumentInfo が見つかりません。そのため、ドキュメント プロパティの設定方法を示すデモ コードはありません。
以下の私のコードを参照してください
var converter = new HtmlToPdfConverter();
converter.ConversionDelay = 0;
converter.ClipHtmlView = false;
var paperSize = PaperSizeToSizeF(pPaperSize);
var pdfPageOrientation = (pIsLandscape) ? PdfPageOrientation.Landscape : PdfPageOrientation.Portrait;
converter.PdfDocumentOptions.PdfPageOrientation = pdfPageOrientation;
converter.PdfDocumentOptions.PdfStandardSubset = PdfStandardSubset.Pdf_A_1b;
//IMPORTANT FOR COMPLIANCE
converter.PdfDocumentInfo.AuthorName = "Mike de Klerk";
converter.PdfDocumentInfo.Title = "PDF/A-1b Test";
converter.PdfDocumentInfo.Subject = "Testing generation of PDF/A-1b compliant file by EVOPDF library.";
converter.PdfDocumentInfo.Keywords = "HTML, PDF, Converter, PDF/A-1b. compliance";
converter.PdfDocumentInfo.CreatedDate = DateTime.Now;
編集:
オブジェクトを使用するとき、EvoPdf.Document
私はそれを成し遂げることができます。EvoPdf.HtmlToPdfConverter
しかし、オブジェクトを使用してそれを行うことはできません。ただし、ほとんどのドキュメントではHtmlToPdfConverter
. EvoPdf.Document
オブジェクトの使用法については、以下のコードを参照してください。
// Create the PDF document where to add the HTML documents
var pdfDocument = new Document();
// Set license key received after purchase to use the converter in licensed mode
// Leave it not set to use the converter in demo mode
pdfDocument.LicenseKey = LicenseKey;
pdfDocument.DocumentInformation.Author = "Mike de Klerk";
pdfDocument.DocumentInformation.Title = "PDF/A-1b Test";
pdfDocument.DocumentInformation.Subject = "Testing generation of PDF/A-1b compliant file by EVOPDF library.";
pdfDocument.DocumentInformation.Keywords = "HTML, PDF, Converter, PDF/A-1b. compliance";
pdfDocument.DocumentInformation.CreationDate = DateTime.Now;
編集2:
オブジェクトがありHtmlToPdfConverter.PdfDocumentOptions.DocumentObject.DocumentInformation
ます。ただし、DocumentObject
変換前は null です。ドキュメントによると
変換中にコンバーターによって初期化された内部 Document オブジェクトへの参照
DocumentObject
変換後に確かに存在し、変換後にDocumentInformation
プロパティが設定されていないことを確認できます。
編集3:
また、DocumentInformation
変換前/変換後のイベントを設定しても機能しないようです。
converter.PrepareRenderPdfPageEvent += (eventParams) =>
{
converter.PdfDocumentOptions.DocumentObject.DocumentInformation.Author = "Mike de Klerk";
converter.PdfDocumentOptions.DocumentObject.DocumentInformation.Title = "PDF/A-1b Test";
converter.PdfDocumentOptions.DocumentObject.DocumentInformation.Subject = "Testing generation of PDF/A-1b compliant file by EVOPDF library.";
converter.PdfDocumentOptions.DocumentObject.DocumentInformation.Keywords = "HTML, PDF, Converter, PDF/A-1b. compliance";
converter.PdfDocumentOptions.DocumentObject.DocumentInformation.CreationDate = DateTime.Now;
};
converter.AfterRenderPdfPageEvent += (eventParams) =>
{
eventParams.Page.Document.DocumentInformation.Author = "Mike de Klerk";
eventParams.Page.Document.DocumentInformation.Title = "PDF/A-1b Test";
eventParams.Page.Document.DocumentInformation.Subject = "Testing generation of PDF/A-1b compliant file by EVOPDF library.";
eventParams.Page.Document.DocumentInformation.Keywords = "HTML, PDF, Converter, PDF/A-1b. compliance";
eventParams.Page.Document.DocumentInformation.CreationDate = DateTime.Now;
};
converter.ConvertHtmlFileToStream(pContentHtmlFile, pOutputStream);
編集4:
Document
最初にオブジェクトに変換し、次に設定し、出力ストリームにDocumentInformation
書き込む場合でも機能しません。Document
ここで可能な回避策が不足していると感じています...
var documentObject = converter.ConvertHtmlFileToPdfDocumentObject(pContentHtmlFile);
documentObject.DocumentInformation.Author = "Mike de Klerk";
documentObject.DocumentInformation.Title = "PDF/A-1b Test";
documentObject.DocumentInformation.Subject = "Testing generation of PDF/A-1b compliant file by EVOPDF library.";
documentObject.DocumentInformation.Keywords = "HTML, PDF, Converter, PDF/A-1b. compliance";
documentObject.DocumentInformation.CreationDate = DateTime.Now;
documentObject.Save(pOutputStream);
編集5:
documentObject.DocumentInformation.Author = "Value";
を行うと、セッターがあり、実際に設定されていると想定しました。しかし、そうではありません。したがって、これらの値をどこに設定しようとしているかは問題ではありません。彼らはただ記憶されていません。これはバグに違いありません。EvoPdf.DocumentInfo
とEvoPdf.PdfDocumentInfo
クラスさえあるのはなぜですか?1 つは を使用しAuthorName
、もう 1 つは を使用しAuthor
ます。そして、これらの違いの詳細。