{"id":1459,"date":"2024-09-22T17:46:21","date_gmt":"2024-09-22T09:46:21","guid":{"rendered":"https:\/\/moneystock.net\/wp_e\/?p=1459"},"modified":"2024-09-22T17:46:21","modified_gmt":"2024-09-22T09:46:21","slug":"convert-pdf-to-image-in-c","status":"publish","type":"post","link":"https:\/\/moneystock.net\/wp_e\/2024\/09\/22\/convert-pdf-to-image-in-c\/","title":{"rendered":"Convert PDF to Image in C#"},"content":{"rendered":"<p>The simplest way to convert PDF to image as of 2024 is using PDFtoImage libary like below. This libary works for dotnet 8.0 as well.<\/p>\n<p>example: Read pdf file and save page 1 (index 0) to jpg file.<\/p>\n<pre class=\"lang-cs s-code-block\"><code class=\"hljs language-csharp\" data-highlighted=\"yes\"><span class=\"hljs-keyword\">using<\/span> PDFtoImage;\r\n<span class=\"hljs-keyword\">using<\/span> <span class=\"hljs-keyword\">var<\/span> pdfStream = File.OpenRead(<span class=\"hljs-string\">@\"Sample.pdf\"<\/span>);\r\nConversion.SaveJpeg(<span class=\"hljs-string\">\"image-fileStream.jpg\"<\/span>, pdfStream, <span class=\"hljs-number\">0<\/span>, options: <span class=\"hljs-keyword\">new<\/span>(Dpi: <span class=\"hljs-number\">300<\/span>, Width:<span class=\"hljs-number\">1024<\/span>, Height:<span class=\"hljs-literal\">null<\/span>, WithAspectRatio:<span class=\"hljs-literal\">true<\/span>));\r\n<\/code><\/pre>\n<p>You can file more detail in\u00a0<a href=\"https:\/\/github.com\/sungaila\/PDFtoImage\" rel=\"nofollow noreferrer\">https:\/\/github.com\/sungaila\/PDFtoImage<\/a>, which is MIT license.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The simplest way to convert PDF to image as of 2024 is using PDFtoImage libary like below. This libary works for dotnet 8.0 as well. example: Read pdf file and save page 1 (index 0) to jpg file. using PDFtoImage; using var pdfStream = File.OpenRead(@&#8221;Sample.pdf&#8221;); Conversion.SaveJpeg(&#8220;image-fileStream.jpg&#8221;, pdfStream, 0, options: new(Dpi: 300, Width:1024, Height:null, WithAspectRatio:true)); You&hellip; <a class=\"more-link\" href=\"https:\/\/moneystock.net\/wp_e\/2024\/09\/22\/convert-pdf-to-image-in-c\/\">Continue reading <span class=\"screen-reader-text\">Convert PDF to Image in C#<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[548],"tags":[700,702],"class_list":["post-1459","post","type-post","status-publish","format-standard","hentry","category-c","tag-pdf","tag-pdf-conversion","entry"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/moneystock.net\/wp_e\/wp-json\/wp\/v2\/posts\/1459","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/moneystock.net\/wp_e\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/moneystock.net\/wp_e\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/moneystock.net\/wp_e\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/moneystock.net\/wp_e\/wp-json\/wp\/v2\/comments?post=1459"}],"version-history":[{"count":1,"href":"https:\/\/moneystock.net\/wp_e\/wp-json\/wp\/v2\/posts\/1459\/revisions"}],"predecessor-version":[{"id":1460,"href":"https:\/\/moneystock.net\/wp_e\/wp-json\/wp\/v2\/posts\/1459\/revisions\/1460"}],"wp:attachment":[{"href":"https:\/\/moneystock.net\/wp_e\/wp-json\/wp\/v2\/media?parent=1459"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/moneystock.net\/wp_e\/wp-json\/wp\/v2\/categories?post=1459"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/moneystock.net\/wp_e\/wp-json\/wp\/v2\/tags?post=1459"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}