{"id":584,"date":"2019-11-02T14:35:08","date_gmt":"2019-11-02T05:35:08","guid":{"rendered":"http:\/\/shinke1987.net\/?p=584"},"modified":"2019-11-02T14:36:40","modified_gmt":"2019-11-02T05:36:40","slug":"post-584","status":"publish","type":"post","link":"https:\/\/shinke1987.net\/?p=584","title":{"rendered":"C#\u3067PDFsharp\u3092\u5c11\u3057\u4f7f\u3063\u3066\u307f\u305f\u3002"},"content":{"rendered":"\n<h2 id=\"toc0\" class=\"wp-block-heading\">\u74b0\u5883<\/h2>\n\n\n\n<p>VisualStudio 2017 Pro<br>Windows10<\/p>\n\n\n\n<h2 id=\"toc1\" class=\"wp-block-heading\">PDFsharp\u306b\u3064\u3044\u3066<\/h2>\n\n\n\n<p> PDFsharp\uff1aMIT\u30e9\u30a4\u30bb\u30f3\u30b9\u306eOSS\u3002<br>\u516c\u5f0f\u30b5\u30a4\u30c8\uff1a<a href=\"http:\/\/www.pdfsharp.net\/MainPage.ashx\">http:\/\/www.pdfsharp.net\/MainPage.ashx<\/a><br>\u4f55\u304c\u3067\u304d\u308b\u304b\u3092\u3082\u3063\u3068\u77e5\u308a\u305f\u3044\u306a\u3089\u3001\u516c\u5f0f\u30b5\u30a4\u30c8\u306e\u30b5\u30f3\u30d7\u30eb\u3092\u898b\u308b\u3068\u826f\u3044\u3002<br><\/p>\n\n\n\n<h2 id=\"toc2\" class=\"wp-block-heading\">\u521d\u671f\u8a2d\u5b9a<\/h2>\n\n\n\n<p>\n\nVisualStudio\u306e\u300c\u30c4\u30fc\u30eb\u300d\u2192\u300cNuGet \u30d1\u30c3\u30b1\u30fc\u30b8 \u30de\u30cd\u30fc\u30b8\u30e3\u30fc\u300d<br>\u2192\u300c\u30d1\u30c3\u30b1\u30fc\u30b8 \u30de\u30cd\u30fc\u30b8\u30e3\u30fc \u30b3\u30f3\u30bd\u30fc\u30eb\u300d\u3092\u30af\u30ea\u30c3\u30af\u3002<\/p>\n\n\n\n<p>\u4e0b\u306b\u30d1\u30c3\u30b1\u30fc\u30b8 \u30de\u30cd\u30fc\u30b8\u30e3\u30fc \u30b3\u30f3\u30bd\u30fc\u30eb\u304c\u8868\u793a\u3055\u308c\u308b\u306e\u3067\u3001<br><pre class=\"brush: csharp; title: ; notranslate\" title=\"\">Install-Package PdfSharp -Version 1.50.5147<\/pre><br>\u3068\u5165\u529b\u3057\u3066\u30a8\u30f3\u30bf\u30fc\u30ad\u30fc\u3092\u62bc\u3059\u3002<\/p>\n\n\n\n<p>\u30d0\u30fc\u30b8\u30e7\u30f3\u306f\u4e0b\u8a18\u30b5\u30a4\u30c8\u304b\u3089\u78ba\u8a8d\u3067\u304d\u308b\u3002<br><a href=\"https:\/\/www.nuget.org\/packages\/PdfSharp\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"https:\/\/www.nuget.org\/packages\/PdfSharp\/ (\u65b0\u3057\u3044\u30bf\u30d6\u3067\u958b\u304f)\">https:\/\/www.nuget.org\/packages\/PdfSharp\/<\/a><\/p>\n\n\n\n<p>\u30a8\u30f3\u30bf\u30fc\u30ad\u30fc\u3092\u62bc\u3057\u305f\u5f8c\u3001\u6b63\u5e38\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u307e\u3057\u305f\u3001<br>\u3068\u8868\u793a\u3055\u308c\u308b\u306e\u3092\u78ba\u8a8d\u3059\u308b\u3002<\/p>\n\n\n\n<p>\u30b3\u30f3\u30bd\u30fc\u30eb\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3057\u3001<br>Program.cs\u306b\u6b21\u306e\u901a\u308a\u306b\u5165\u529b\u3057\u3066\u307f\u308b\u3002\n\n<\/p>\n\n\n\n<h2 id=\"toc3\" class=\"wp-block-heading\">\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9<\/h2>\n\n\n\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\nusing System.Diagnostics;\nusing System.IO;\nusing PdfSharp;\nusing PdfSharp.Drawing;\nusing PdfSharp.Pdf;\nusing PdfSharp.Pdf.IO;\n\nnamespace _20191102_PDFTest\n{\n    class Program\n    {\n        static void Main(string&#x5B;] args)\n        {\n            \/\/ PDF\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3092\u4f5c\u6210\u3002\n            PdfDocument document = new PdfDocument();\n            document.Info.Title = &quot;Created with PDFsharp&quot;;\n            document.Info.Author = &quot;\u540d\u524d&quot;;\n\n            \/\/ \u7a7a\u767d\u30da\u30fc\u30b8\u3092\u4f5c\u6210\u3002\n            PdfPage page = document.AddPage();\n\n            \/\/ \u63cf\u753b\u3059\u308b\u305f\u3081\u306bXGraphics\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u53d6\u5f97\u3002\n            XGraphics gfx = XGraphics.FromPdfPage(page);\n\n            \/\/ \u30d5\u30a9\u30f3\u30c8\u3092\u4f5c\u6210\u3002\n            XFont font = new XFont(&quot;Verdana&quot;, 20, XFontStyle.BoldItalic);\n\n            \/\/ \u30c6\u30ad\u30b9\u30c8\u3092\u63cf\u753b\u3002\n            gfx.DrawString(&quot;Hello World!&quot;, font, XBrushes.Black,\n                new XRect(0, 0, page.Width, page.Height),\n                XStringFormats.Center);\n\n            \/\/ \u67a0\u3092\u63cf\u304f\u3002\n            gfx.DrawRectangle(XBrushes.Red, 0, 0, 100, 100);                          \/\/ \u67a0\u5185\u5857\u308a\u6f70\u3057\u3002\n            gfx.DrawRectangle(new XPen(XColors.Blue, 3), 110, 110, 100, 100);         \/\/ \u67a0\u5185\u5857\u308a\u6f70\u3055\u306a\u3044\u3002\n\n            \/\/ \u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3092\u4fdd\u5b58\u3002\n            document.Save(&quot;HelloWorld.pdf&quot;);\n\n            \/\/ \u30d3\u30e5\u30fc\u30a2\u3092\u8d77\u52d5\u3002\n            Process.Start(&quot;HelloWorld.pdf&quot;);\n        }\n    }\n}\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u74b0\u5883 VisualStudio 2017 ProWindows10 PDFsharp\u306b\u3064\u3044\u3066 PDFsharp\uff1aMIT\u30e9\u30a4\u30bb\u30f3\u30b9\u306eOSS\u3002\u516c\u5f0f\u30b5\u30a4\u30c8\uff1ahttp:\/\/www.pdfsharp.net\/MainPage.as [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[35],"tags":[36],"class_list":["post-584","post","type-post","status-publish","format-standard","hentry","category-c-sharp","tag-c-sharp"],"_links":{"self":[{"href":"https:\/\/shinke1987.net\/index.php?rest_route=\/wp\/v2\/posts\/584","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/shinke1987.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/shinke1987.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/shinke1987.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/shinke1987.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=584"}],"version-history":[{"count":18,"href":"https:\/\/shinke1987.net\/index.php?rest_route=\/wp\/v2\/posts\/584\/revisions"}],"predecessor-version":[{"id":602,"href":"https:\/\/shinke1987.net\/index.php?rest_route=\/wp\/v2\/posts\/584\/revisions\/602"}],"wp:attachment":[{"href":"https:\/\/shinke1987.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=584"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/shinke1987.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=584"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/shinke1987.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=584"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}