{"id":48670,"date":"2016-05-09T16:00:55","date_gmt":"2016-05-09T16:00:55","guid":{"rendered":"http:\/\/webkul.com\/blog\/?p=48670"},"modified":"2024-02-22T06:30:42","modified_gmt":"2024-02-22T06:30:42","slug":"generate-pdf-string-magento-2-0","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/generate-pdf-string-magento-2-0\/","title":{"rendered":"Generate pdf file from pdf string and image string content in Magento 2"},"content":{"rendered":"\n<p>here we will learn, how to generate pdf file if you have string data of pdf and image.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">public function generatePdf()\n{\n   $objectManager = \\Magento\\Framework\\App\\ObjectManager::getInstance();\n   $labelGenerator = $objectManager-&gt;create(&#039;Magento\\Shipping\\Model\\Shipping\\LabelGenerator&#039;);\n   $labelContent&#091;] = base64_decode((string) $imageString); \/\/you can add more image strings.\n   $outputPdf = $labelGenerator-&gt;combineLabelsPdf($labelContent);\n\n   $fileFactory = $objectManager-&gt;create(&#039;Magento\\Framework\\App\\Response\\Http\\FileFactory&#039;);\n\n   return $fileFactory-&gt;create(\n         &#039;Labels.pdf&#039;,\n          $outputPdf-&gt;render(),\n          \\Magento\\Framework\\App\\Filesystem\\DirectoryList::VAR_DIR,\n          &#039;application\/pdf&#039;\n       );\n}<\/pre>\n\n\n\n<p>By calling this function you can generate pdf file from string content.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>here we will learn, how to generate pdf file if you have string data of pdf and image. By calling this function you can generate pdf file from string content.<\/p>\n","protected":false},"author":69,"featured_media":48470,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[302],"tags":[3104,3102,3103,3105],"class_list":["post-48670","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-magento2","tag-create-pdf-file-from-image-string-content","tag-generate-pdf","tag-generate-pdf-from-string","tag-magento-2-create-pdf-file-from-string"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Generate pdf file from pdf string and image string content in Magento 2 - Webkul Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/webkul.com\/blog\/generate-pdf-string-magento-2-0\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Generate pdf file from pdf string and image string content in Magento 2 - Webkul Blog\" \/>\n<meta property=\"og:description\" content=\"here we will learn, how to generate pdf file if you have string data of pdf and image. By calling this function you can generate pdf file from string content.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/generate-pdf-string-magento-2-0\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:published_time\" content=\"2016-05-09T16:00:55+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-02-22T06:30:42+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/05\/Magneto-Code-Snippet-1-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"825\" \/>\n\t<meta property=\"og:image:height\" content=\"260\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Mahesh Singh\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webkul\" \/>\n<meta name=\"twitter:site\" content=\"@webkul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Mahesh Singh\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/generate-pdf-string-magento-2-0\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/generate-pdf-string-magento-2-0\/\"},\"author\":{\"name\":\"Mahesh Singh\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/53d3b977a0ab5adcf32aef9f97e595bd\"},\"headline\":\"Generate pdf file from pdf string and image string content in Magento 2\",\"datePublished\":\"2016-05-09T16:00:55+00:00\",\"dateModified\":\"2024-02-22T06:30:42+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/generate-pdf-string-magento-2-0\/\"},\"wordCount\":42,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/generate-pdf-string-magento-2-0\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/05\/Magneto-Code-Snippet-1-1.png\",\"keywords\":[\"Create pdf file from image string content\",\"generate pdf\",\"Generate pdf from string\",\"Magento 2 create pdf file from string\"],\"articleSection\":[\"Magento2\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/generate-pdf-string-magento-2-0\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/generate-pdf-string-magento-2-0\/\",\"url\":\"https:\/\/webkul.com\/blog\/generate-pdf-string-magento-2-0\/\",\"name\":\"Generate pdf file from pdf string and image string content in Magento 2 - Webkul Blog\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/generate-pdf-string-magento-2-0\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/generate-pdf-string-magento-2-0\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/05\/Magneto-Code-Snippet-1-1.png\",\"datePublished\":\"2016-05-09T16:00:55+00:00\",\"dateModified\":\"2024-02-22T06:30:42+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/generate-pdf-string-magento-2-0\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/generate-pdf-string-magento-2-0\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/generate-pdf-string-magento-2-0\/#primaryimage\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/05\/Magneto-Code-Snippet-1-1.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/05\/Magneto-Code-Snippet-1-1.png\",\"width\":825,\"height\":260,\"caption\":\"Upload files using magento2 mediastorage module\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/generate-pdf-string-magento-2-0\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Generate pdf file from pdf string and image string content in Magento 2\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webkul.com\/blog\/#website\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"name\":\"Webkul Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webkul.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webkul.com\/blog\/#organization\",\"name\":\"WebKul Software Private Limited\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"width\":380,\"height\":380,\"caption\":\"WebKul Software Private Limited\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webkul\/\",\"https:\/\/x.com\/webkul\",\"https:\/\/www.instagram.com\/webkul\/\",\"https:\/\/www.linkedin.com\/company\/webkul\",\"https:\/\/www.youtube.com\/user\/webkul\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/53d3b977a0ab5adcf32aef9f97e595bd\",\"name\":\"Mahesh Singh\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/f4c013ebf7008223382b8a49203e6d354677e8baff0eca373e6e4266efa762da?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/f4c013ebf7008223382b8a49203e6d354677e8baff0eca373e6e4266efa762da?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Mahesh Singh\"},\"url\":\"https:\/\/webkul.com\/blog\/author\/mahesh721\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Generate pdf file from pdf string and image string content in Magento 2 - Webkul Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/webkul.com\/blog\/generate-pdf-string-magento-2-0\/","og_locale":"en_US","og_type":"article","og_title":"Generate pdf file from pdf string and image string content in Magento 2 - Webkul Blog","og_description":"here we will learn, how to generate pdf file if you have string data of pdf and image. By calling this function you can generate pdf file from string content.","og_url":"https:\/\/webkul.com\/blog\/generate-pdf-string-magento-2-0\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2016-05-09T16:00:55+00:00","article_modified_time":"2024-02-22T06:30:42+00:00","og_image":[{"width":825,"height":260,"url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/05\/Magneto-Code-Snippet-1-1.png","type":"image\/png"}],"author":"Mahesh Singh","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Mahesh Singh","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/generate-pdf-string-magento-2-0\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/generate-pdf-string-magento-2-0\/"},"author":{"name":"Mahesh Singh","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/53d3b977a0ab5adcf32aef9f97e595bd"},"headline":"Generate pdf file from pdf string and image string content in Magento 2","datePublished":"2016-05-09T16:00:55+00:00","dateModified":"2024-02-22T06:30:42+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/generate-pdf-string-magento-2-0\/"},"wordCount":42,"commentCount":0,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"image":{"@id":"https:\/\/webkul.com\/blog\/generate-pdf-string-magento-2-0\/#primaryimage"},"thumbnailUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/05\/Magneto-Code-Snippet-1-1.png","keywords":["Create pdf file from image string content","generate pdf","Generate pdf from string","Magento 2 create pdf file from string"],"articleSection":["Magento2"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/generate-pdf-string-magento-2-0\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/generate-pdf-string-magento-2-0\/","url":"https:\/\/webkul.com\/blog\/generate-pdf-string-magento-2-0\/","name":"Generate pdf file from pdf string and image string content in Magento 2 - Webkul Blog","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/webkul.com\/blog\/generate-pdf-string-magento-2-0\/#primaryimage"},"image":{"@id":"https:\/\/webkul.com\/blog\/generate-pdf-string-magento-2-0\/#primaryimage"},"thumbnailUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/05\/Magneto-Code-Snippet-1-1.png","datePublished":"2016-05-09T16:00:55+00:00","dateModified":"2024-02-22T06:30:42+00:00","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/generate-pdf-string-magento-2-0\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/generate-pdf-string-magento-2-0\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/generate-pdf-string-magento-2-0\/#primaryimage","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/05\/Magneto-Code-Snippet-1-1.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2016\/05\/Magneto-Code-Snippet-1-1.png","width":825,"height":260,"caption":"Upload files using magento2 mediastorage module"},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/generate-pdf-string-magento-2-0\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Generate pdf file from pdf string and image string content in Magento 2"}]},{"@type":"WebSite","@id":"https:\/\/webkul.com\/blog\/#website","url":"https:\/\/webkul.com\/blog\/","name":"Webkul Blog","description":"","publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webkul.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webkul.com\/blog\/#organization","name":"WebKul Software Private Limited","url":"https:\/\/webkul.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","width":380,"height":380,"caption":"WebKul Software Private Limited"},"image":{"@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webkul\/","https:\/\/x.com\/webkul","https:\/\/www.instagram.com\/webkul\/","https:\/\/www.linkedin.com\/company\/webkul","https:\/\/www.youtube.com\/user\/webkul\/"]},{"@type":"Person","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/53d3b977a0ab5adcf32aef9f97e595bd","name":"Mahesh Singh","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/f4c013ebf7008223382b8a49203e6d354677e8baff0eca373e6e4266efa762da?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/f4c013ebf7008223382b8a49203e6d354677e8baff0eca373e6e4266efa762da?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Mahesh Singh"},"url":"https:\/\/webkul.com\/blog\/author\/mahesh721\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/48670","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/users\/69"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=48670"}],"version-history":[{"count":7,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/48670\/revisions"}],"predecessor-version":[{"id":423659,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/48670\/revisions\/423659"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media\/48470"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=48670"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=48670"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=48670"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}