<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>wkhtmltopdf arşivleri - Yunus Emre Araç</title>
	<atom:link href="https://www.yunusemrearac.com/tag/wkhtmltopdf/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.yunusemrearac.com/tag/wkhtmltopdf/</link>
	<description>SharePoint Consultant &#124; Microsoft 365 &#124; SharePoint Server &#38; Online</description>
	<lastBuildDate>Wed, 11 Dec 2019 15:07:25 +0000</lastBuildDate>
	<language>tr</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.2</generator>

<image>
	<url>https://www.yunusemrearac.com/wp-content/uploads/2014/11/MetroUI_VisualStudio_2012-545c8860_site_icon-32x32.png</url>
	<title>wkhtmltopdf arşivleri - Yunus Emre Araç</title>
	<link>https://www.yunusemrearac.com/tag/wkhtmltopdf/</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">67294213</site>	<item>
		<title>SharePoint WebPart ile Html Formatındaki Yazıyı PDF Formatına Dönüştürerek Kaydetmek</title>
		<link>https://www.yunusemrearac.com/2019/05/28/sharepoint-webpart-ile-html-formatindaki-yaziyi-pdf-formatina-donusturerek-kaydetmek/</link>
					<comments>https://www.yunusemrearac.com/2019/05/28/sharepoint-webpart-ile-html-formatindaki-yaziyi-pdf-formatina-donusturerek-kaydetmek/#respond</comments>
		
		<dc:creator><![CDATA[yunusemrearac]]></dc:creator>
		<pubDate>Tue, 28 May 2019 13:56:05 +0000</pubDate>
				<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[GeneratePdf]]></category>
		<category><![CDATA[HtmlToPdf]]></category>
		<category><![CDATA[IIS]]></category>
		<category><![CDATA[Internet Information Services]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[NReco]]></category>
		<category><![CDATA[NReco.PdfGenerator]]></category>
		<category><![CDATA[NReco.PdfGenerator.HtmlToPdfConverter]]></category>
		<category><![CDATA[NuGet Packages]]></category>
		<category><![CDATA[PDF]]></category>
		<category><![CDATA[RunWithElevatedPrivileges]]></category>
		<category><![CDATA[VirtualDirectories]]></category>
		<category><![CDATA[wkhtmltopdf]]></category>
		<category><![CDATA[wkhtmltopdf.exe]]></category>
		<guid isPermaLink="false">http://yunusemrearac.com/?p=1945</guid>

					<description><![CDATA[<p>Merhaba arkadaşlar bugün sizlere sharepoint ortamında girilen bir içeriği ya da html türünde bir yazıyı PDF formatına dönüştürerek o uzantı da nasıl kaydedeceğimizden bahsedeceğim. NOT:&#8230;</p>
<p>The post <a href="https://www.yunusemrearac.com/2019/05/28/sharepoint-webpart-ile-html-formatindaki-yaziyi-pdf-formatina-donusturerek-kaydetmek/">SharePoint WebPart ile Html Formatındaki Yazıyı PDF Formatına Dönüştürerek Kaydetmek</a> appeared first on <a href="https://www.yunusemrearac.com">Yunus Emre Araç</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Merhaba arkadaşlar bugün sizlere sharepoint ortamında girilen bir içeriği ya da html türünde bir yazıyı PDF formatına dönüştürerek o uzantı da nasıl kaydedeceğimizden bahsedeceğim.</p>
<p><strong>NOT:</strong> Bu yöntem ile dosya kodun çalıştığı sunucu da verilen konuma indirilmektedir. Eğer dosyayı son kullanıcı tarafında indirilebilir olması isteniyorsa <a href="http://yunusemrearac.com/2019/12/11/sharepoint-webpart-ile-html-formatindaki-yaziyi-pdf-formatina-donusturerek-tarayici-uzerinden-indirmek/" target="_blank" rel="noopener noreferrer"><strong>SharePoint WebPart ile Html Formatındaki Yazıyı PDF Formatına Dönüştürerek Tarayıcı Üzerinden İndirmek</strong></a> yazımı inceleyebilir.</p>
<p>İlk olarak projemizi oluşturuyoruz.</p>
<p>Projeye sağ tıklayarak <strong>&#8220;Manage NuGet Packages&#8230;&#8221;</strong> diyerek nuget paketlerinin yönetim ekranını açıyoruz. Burada arama kısmında <strong>&#8220;NReco.PdfGenerator&#8221;</strong> yazarak aratıyoruz ve çıkan nuget paketini kuruyoruz.</p>
<p><a href="http://yunusemrearac.com/wp-content/uploads/2019/05/1.png"><img fetchpriority="high" decoding="async" class="size-full wp-image-1946 aligncenter" src="https://yunusemrearac.com/wp-content/uploads/2019/05/1.png" alt="" width="1497" height="614" srcset="https://www.yunusemrearac.com/wp-content/uploads/2019/05/1.png 1497w, https://www.yunusemrearac.com/wp-content/uploads/2019/05/1-300x123.png 300w, https://www.yunusemrearac.com/wp-content/uploads/2019/05/1-768x315.png 768w, https://www.yunusemrearac.com/wp-content/uploads/2019/05/1-1024x420.png 1024w" sizes="(max-width: 1497px) 100vw, 1497px" /></a></p>
<p>Bu kurulumdan sonra aşağıdaki proje linkinde yer alan proje içerisindeki <strong>&#8220;App_Data&#8221;</strong> klasörünü alarak IIS te <strong>&#8220;VirtualDirectories&#8221;</strong>  altındaki site klasörünün içine kopyalıyoruz.</p>
<p><a href="http://yunusemrearac.com/wp-content/uploads/2019/05/2.png"><img decoding="async" class="size-full wp-image-1947 aligncenter" src="https://yunusemrearac.com/wp-content/uploads/2019/05/2.png" alt="" width="1920" height="1048" srcset="https://www.yunusemrearac.com/wp-content/uploads/2019/05/2.png 1920w, https://www.yunusemrearac.com/wp-content/uploads/2019/05/2-300x164.png 300w, https://www.yunusemrearac.com/wp-content/uploads/2019/05/2-768x419.png 768w, https://www.yunusemrearac.com/wp-content/uploads/2019/05/2-1024x559.png 1024w" sizes="(max-width: 1920px) 100vw, 1920px" /></a></p>
<p>Ya da bu konuma giderek <strong>&#8220;App_Data&#8221;</strong> klasörü oluşturarak içine de <strong>&#8220;wkhtmltopdf&#8221;</strong> adında bir klasör oluşturup sadece <strong>&#8220;wkhtmltopdf.exe&#8221;</strong> programını bu klasörün içerisine ekleyebilirsiniz. Geriye kalan Dll dosyalarını ilk çalışmada otamatik indirebilmesi ve hata vermeden çalışması için <strong>&#8220;App_Data&#8221;</strong> klasörüne tam yetki vermeniz gerekmektedir. Eğer Dll dosyaları yüklendi ise ve bulunuyorsa klasörde sadece yetki okuması olması da yeterki olacaktır.</p>
<p><a href="http://yunusemrearac.com/wp-content/uploads/2019/05/3.png"><img decoding="async" class="size-full wp-image-1948 aligncenter" src="https://yunusemrearac.com/wp-content/uploads/2019/05/3.png" alt="" width="1026" height="650" srcset="https://www.yunusemrearac.com/wp-content/uploads/2019/05/3.png 1026w, https://www.yunusemrearac.com/wp-content/uploads/2019/05/3-300x190.png 300w, https://www.yunusemrearac.com/wp-content/uploads/2019/05/3-768x487.png 768w, https://www.yunusemrearac.com/wp-content/uploads/2019/05/3-1024x649.png 1024w" sizes="(max-width: 1026px) 100vw, 1026px" /></a></p>
<p>Daha sonra webpartımızın ascx tarafına geliyoruz. Burada kullanıcı arayüzünden almak istediğiniz kısımları oluşturabilirsiniz. Ben kullanıcıdan pdf dosyasının adını ve pdf içine eklenecek içeriği almak istedim.</p><pre class="urvanov-syntax-highlighter-plain-tag">Save File Name : &lt;asp:TextBox ID="tbFileName" runat="server"&gt;&lt;/asp:TextBox&gt; &lt;br /&gt;
Html Content : &lt;asp:TextBox ID="tbPdfContent" runat="server" TextMode="MultiLine" Rows="6"&gt;&lt;/asp:TextBox&gt; &lt;br /&gt;
&lt;asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" /&gt;</pre><p>Bu kısımda sadece dosya adı ve içeriği aldıktan sonra kaydet butonu ile dosyamızı oluşturacağız. Bu taraf tamamlandıktan sonra code behind tarafında yazılacak kod kısmına geçiyoruz.</p><pre class="urvanov-syntax-highlighter-plain-tag">protected void btnSave_Click(object sender, EventArgs e)
{
    SPSecurity.RunWithElevatedPrivileges(delegate ()
    {
        string htmlStart = "&lt;html&gt;&lt;head&gt;&lt;meta http-equiv='content-type' content='text/html; charset=UTF-8'&gt;&lt;/head&gt;&lt;body&gt;";
        string htmlContent = tbPdfContent.Text;
        string htmlFinish = "&lt;/body&gt;&lt;/html&gt;";

        string htmlPath = @"C:\pdf\";
        string htmlName = (string.IsNullOrEmpty(tbFileName.Text) ? "yunusemrearac" : tbFileName.Text) + ".pdf";

        string htmlSavePath = htmlPath + htmlName;
        string html = htmlStart + htmlContent + htmlFinish;

        var htmlToPdf = new NReco.PdfGenerator.HtmlToPdfConverter();
        htmlToPdf.GeneratePdf(html, "", htmlSavePath);
    });
}</pre><p>Burada butona basıldığında tetikleme işlemi olacağı için kodumuzu botun click event içine yazıyoruz. Yukarıdaki kodu açıklayacak olursak.</p>
<ul>
<li>Sharepoint tarafında kullanıcının IIS tarafına attığımız exe dosyasını kullanması ve pdf dosyamızı kaydedebilmesi için sistemin <strong>RunWithElevatedPrivileges</strong> olarak çalışması gerekmektedir.</li>
<li><strong>htmlStart</strong> değişkenimizde pdf verimizde kullanacağımız head taglarını ekledik. Ben sadece türkçe karakter desteği olması için UTF-8 meta tagını ekledim.</li>
<li><strong>htmlContent</strong> değişkenine ise pdf te yer almasını istediğimiz içerik gelmesi gerekmektedir. Bu kısımda ben içeriği kullanıcıdan aldığım için field değer atamasını bu değişkenimize yaptık.</li>
<li><strong>hmlFinish</strong> değişkeni ise htmlStart değişkeninde açtığımız tagların kapanması ve sonradan eklenmek istenen tagların yer alacağı değişkenimiz olacaktır.</li>
<li><strong>htmlPath</strong> değişkenine ise oluşturulacak olan pdf dosyasının nereye kaydedileceğini tanımladığımız path bilgisinin olduğu değişken değerimiz. Burada verilecek konum exe dosyasının çalışacağı sunucu da olması gereken bir konum olması gerekmektedir.</li>
<li><strong>htmlName</strong> değişkeni ise pdf dosyamızın ismini belirleyeceğimiz değişkendir.  Bu değeri de ben son kullanıcıdan almaktayım ama boş girme ihtimaline karşı eğer boş değer gelirse kendim bir isim ataması da yapmış oldum. Burada gelecek ismin sonuna <strong>&#8220;.pdf&#8221;</strong> şeklinde dosya uzantısını eklemeyi unutmayın.</li>
<li><strong>htmlSavePath</strong> değişkeni pdf dosyamızın kaydedileceği lokasyon ve dosya isminin birleştiği değişkendir.</li>
<li><strong>html</strong> değişkeni ise htmlStart, htmlContent ve htmlFinish değişkenlerinin birleştiği değişkenimizdir.</li>
<li>Bütün bu tanımlamalarımızı yaptıktan sonra <strong>&#8220;new NReco.PdfGenerator.HtmlToPdfConverter()&#8221; </strong>şeklinde türettiğimiz ve <strong>&#8220;NReco.PdfGenerator.HtmlToPdfConverter&#8221;</strong> tipinde <strong>&#8220;htmlToPdf&#8221;</strong> adında bir değişken tanımlıyoruz.</li>
<li>Bu değişkenimizde yer alan <strong>&#8220;GeneratePdf&#8221;</strong> metodumuza html ve kayıt konumunu yollayarak kodumuzu tamamlıyoruz.</li>
</ul>
<p><a href="http://yunusemrearac.com/wp-content/uploads/2019/05/4.png"><img decoding="async" class="size-full wp-image-1949 aligncenter" src="https://yunusemrearac.com/wp-content/uploads/2019/05/4.png" alt="" width="899" height="531" srcset="https://www.yunusemrearac.com/wp-content/uploads/2019/05/4.png 899w, https://www.yunusemrearac.com/wp-content/uploads/2019/05/4-300x177.png 300w, https://www.yunusemrearac.com/wp-content/uploads/2019/05/4-768x454.png 768w" sizes="(max-width: 899px) 100vw, 899px" /></a></p>
<p>Bahsedilen adımları sorunsuz uyguladığınız zaman yukarıdaki gibi bir ekran gelecektir. Ben örnek bir data girişi yaparak <strong>&#8220;Save&#8221;</strong> butonuna basıyoruz.</p>
<p><a href="http://yunusemrearac.com/wp-content/uploads/2019/05/5.png"><img decoding="async" class="size-full wp-image-1950 aligncenter" src="https://yunusemrearac.com/wp-content/uploads/2019/05/5.png" alt="" width="1025" height="650" srcset="https://www.yunusemrearac.com/wp-content/uploads/2019/05/5.png 1025w, https://www.yunusemrearac.com/wp-content/uploads/2019/05/5-300x190.png 300w, https://www.yunusemrearac.com/wp-content/uploads/2019/05/5-768x487.png 768w, https://www.yunusemrearac.com/wp-content/uploads/2019/05/5-1024x649.png 1024w" sizes="(max-width: 1025px) 100vw, 1025px" /></a></p>
<p>Kod kısmında verdiğimiz konuma gittiğimizde belirlediğimiz dosya adında bir pdf oluştuğunu görmekteyiz.</p>
<p><a href="http://yunusemrearac.com/wp-content/uploads/2019/05/6.png"><img decoding="async" class="size-full wp-image-1951 aligncenter" src="https://yunusemrearac.com/wp-content/uploads/2019/05/6.png" alt="" width="1441" height="767" srcset="https://www.yunusemrearac.com/wp-content/uploads/2019/05/6.png 1441w, https://www.yunusemrearac.com/wp-content/uploads/2019/05/6-300x160.png 300w, https://www.yunusemrearac.com/wp-content/uploads/2019/05/6-768x409.png 768w, https://www.yunusemrearac.com/wp-content/uploads/2019/05/6-1024x545.png 1024w" sizes="(max-width: 1441px) 100vw, 1441px" /></a></p>
<p>Dosyamızı da açtığımız zaman yukarıdaki gibi istediğimiz şekilde pdf dosyamızın oluştuğunu görmekteyiz.</p>
<p>Örnek projenin tamamını ve kullanıcağınız exe dosyası ve dll leri aşağıdaki github adresinden alabilirsiniz.</p>
<p><a href="https://github.com/yunusemrearac/SharePointHtmlConvertToPdf" target="_blank" rel="noopener noreferrer"><img decoding="async" class="alignnone wp-image-1789 size-medium" src="https://yunusemrearac.com/wp-content/uploads/2018/10/Github-source-code-downloa-300x120.png" alt="" width="300" height="120" srcset="https://www.yunusemrearac.com/wp-content/uploads/2018/10/Github-source-code-downloa-300x120.png 300w, https://www.yunusemrearac.com/wp-content/uploads/2018/10/Github-source-code-downloa-768x306.png 768w, https://www.yunusemrearac.com/wp-content/uploads/2018/10/Github-source-code-downloa-1024x408.png 1024w, https://www.yunusemrearac.com/wp-content/uploads/2018/10/Github-source-code-downloa.png 1254w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p>The post <a href="https://www.yunusemrearac.com/2019/05/28/sharepoint-webpart-ile-html-formatindaki-yaziyi-pdf-formatina-donusturerek-kaydetmek/">SharePoint WebPart ile Html Formatındaki Yazıyı PDF Formatına Dönüştürerek Kaydetmek</a> appeared first on <a href="https://www.yunusemrearac.com">Yunus Emre Araç</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.yunusemrearac.com/2019/05/28/sharepoint-webpart-ile-html-formatindaki-yaziyi-pdf-formatina-donusturerek-kaydetmek/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1945</post-id>	</item>
	</channel>
</rss>
