{"id":8561,"date":"2024-01-19T15:19:55","date_gmt":"2024-01-19T15:19:55","guid":{"rendered":"https:\/\/www.satup.xyz\/index.php\/2024\/01\/19\/dynamically-generating-document-samples-part-two-by-raymond-camden\/"},"modified":"2024-01-19T15:19:55","modified_gmt":"2024-01-19T15:19:55","slug":"dynamically-generating-document-samples-part-two-by-raymond-camden","status":"publish","type":"post","link":"https:\/\/www.satup.xyz\/index.php\/2024\/01\/19\/dynamically-generating-document-samples-part-two-by-raymond-camden\/","title":{"rendered":"Dynamically Generating Document Samples \u2014 Part Two | by Raymond Camden"},"content":{"rendered":"<p><br \/>\n<\/p>\n<div>\n<div>\n<h2 id=\"2d7d\" class=\"pw-subtitle-paragraph ho gq gr be b hp hq hr hs ht hu hv hw hx hy hz ia ib ic id cp dt\">We\u2019ve already looked at ways to generate document samples using Adobe Acrobat Services. But how can we do even better?<\/h2>\n<div class=\"ie if ig ih ii\">\n<div class=\"speechify-ignore ab co\">\n<div class=\"speechify-ignore bg l\">\n<div class=\"ij ik il im in ab\">\n<div>\n<div class=\"ab io\"><a href=\"https:\/\/medium.com\/@cfjedimaster?source=post_page-----215a7796a2f6--------------------------------\" rel=\"noopener follow\"><\/p>\n<div>\n<div class=\"bl\" aria-hidden=\"false\">\n<div class=\"l ip iq bx ir is\">\n<div class=\"l fg\"><img loading=\"lazy\" decoding=\"async\" alt=\"Raymond Camden\" class=\"l fa bx dc dd cw\" src=\"https:\/\/miro.medium.com\/v2\/resize:fill:88:88\/1*ldF-FsLonNyTUOmQ7cIV_g.jpeg\" width=\"44\" height=\"44\" loading=\"lazy\" data-testid=\"authorPhoto\"\/><\/div>\n<\/div>\n<\/div>\n<\/div>\n<p><\/a><a href=\"https:\/\/blog.developer.adobe.com\/?source=post_page-----215a7796a2f6--------------------------------\" rel=\"noopener  ugc nofollow\"><\/p>\n<div class=\"iv ab fg\">\n<div>\n<div class=\"bl\" aria-hidden=\"false\">\n<div class=\"l iw ix bx ir iy\">\n<div class=\"l fg\"><img loading=\"lazy\" decoding=\"async\" alt=\"Adobe Tech Blog\" class=\"l fa bx bq iz cw\" src=\"https:\/\/miro.medium.com\/v2\/resize:fill:48:48\/1*riyFijvwTfGcWNf1guRNtg.png\" width=\"24\" height=\"24\" loading=\"lazy\" data-testid=\"publicationPhoto\"\/><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p><\/a><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<figure class=\"nq nr ns nt nu nv nn no paragraph-image\">\n<div role=\"button\" tabindex=\"0\" class=\"nw nx fg ny bg nz\">\n<div class=\"nn no np\"><picture><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/format:webp\/1*SK6vD9KbTo8IhAIEBpfM6w.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/format:webp\/1*SK6vD9KbTo8IhAIEBpfM6w.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/format:webp\/1*SK6vD9KbTo8IhAIEBpfM6w.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/format:webp\/1*SK6vD9KbTo8IhAIEBpfM6w.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/format:webp\/1*SK6vD9KbTo8IhAIEBpfM6w.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/format:webp\/1*SK6vD9KbTo8IhAIEBpfM6w.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1400\/format:webp\/1*SK6vD9KbTo8IhAIEBpfM6w.png 1400w\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 700px\" type=\"image\/webp\"\/><source data-testid=\"og\" srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/1*SK6vD9KbTo8IhAIEBpfM6w.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/1*SK6vD9KbTo8IhAIEBpfM6w.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/1*SK6vD9KbTo8IhAIEBpfM6w.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/1*SK6vD9KbTo8IhAIEBpfM6w.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/1*SK6vD9KbTo8IhAIEBpfM6w.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/1*SK6vD9KbTo8IhAIEBpfM6w.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1400\/1*SK6vD9KbTo8IhAIEBpfM6w.png 1400w\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 700px\"\/><img fetchpriority=\"high\" alt=\"\" class=\"bg mv oa c\" width=\"700\" height=\"545\" loading=\"eager\" role=\"presentation\"\/><\/picture><\/div>\n<\/div>\n<\/figure>\n<p id=\"8163\" class=\"pw-post-body-paragraph ob oc gr od b hp oe of og hs oh oi oj ok ol om on oo op oq or os ot ou ov ow gk bj\">In our <a class=\"af ox\" rel=\"noopener ugc nofollow\" target=\"_blank\" href=\"https:\/\/blog.developer.adobe.com\/dynamically-generating-document-samples-with-acrobat-services-fad3d4052e20\">previous post<\/a>, we discussed how to use <a class=\"af ox\" href=\"https:\/\/developer.adobe.com\/document-services\/\" rel=\"noopener ugc nofollow\" target=\"_blank\">Adobe Acrobat Services<\/a> to generate PDF \u201csamples\u201d of documents.<\/p>\n<p id=\"ef70\" class=\"pw-post-body-paragraph ob oc gr od b hp oe of og hs oh oi oj ok ol om on oo op oq or os ot ou ov ow gk bj\">So for example, an online bookseller could use our APIs to automate the process of creating a 5-page preview of the book with content prepended in front describing how the file was a sample only.<\/p>\n<p id=\"62f3\" class=\"pw-post-body-paragraph ob oc gr od b hp oe of og hs oh oi oj ok ol om on oo op oq or os ot ou ov ow gk bj\">While that process worked well (and be sure to read that <a class=\"af ox\" rel=\"noopener ugc nofollow\" target=\"_blank\" href=\"https:\/\/blog.developer.adobe.com\/dynamically-generating-document-samples-with-acrobat-services-fad3d4052e20\">post<\/a>!), we can take it a step further and create even better samples. How?<\/p>\n<p id=\"3c1e\" class=\"pw-post-body-paragraph ob oc gr od b hp oe of og hs oh oi oj ok ol om on oo op oq or os ot ou ov ow gk bj\">In our previous example, we used a static PDF with generic text to \u2018prepend\u2019 our samples. While it was kept simple for the demo and could have been embellished, the sample didn\u2019t actually reflect the content of the same in any particular way.<\/p>\n<p id=\"0258\" class=\"pw-post-body-paragraph ob oc gr od b hp oe of og hs oh oi oj ok ol om on oo op oq or os ot ou ov ow gk bj\">We can greatly enhance our workflow by using <em class=\"oy\">dynamic<\/em> content for our prepended document instead. This will be done using the <a class=\"af ox\" href=\"https:\/\/developer.adobe.com\/document-services\/apis\/doc-generation\/\" rel=\"noopener ugc nofollow\" target=\"_blank\">Document Generation API<\/a>.<\/p>\n<p id=\"c455\" class=\"pw-post-body-paragraph ob oc gr od b hp pv of og hs pw oi oj ok px om on oo py oq or os pz ou ov ow gk bj\">The Document Generation API lets you use Microsoft Word to create a \u201ctemplate\u201d.<\/p>\n<p id=\"16f7\" class=\"pw-post-body-paragraph ob oc gr od b hp oe of og hs oh oi oj ok ol om on oo op oq or os ot ou ov ow gk bj\">The template is just a regular Word document with tokens intermixed with the regular content. The Document Generation API then lets you pass that Word doc to our service, along with your custom data, and together the content is merged and a new PDF is created. (You can also create a new Word document as well.)<\/p>\n<p id=\"9b0c\" class=\"pw-post-body-paragraph ob oc gr od b hp oe of og hs oh oi oj ok ol om on oo op oq or os ot ou ov ow gk bj\">If you haven\u2019t had a chance yet to play with this API, check out our excellent <a class=\"af ox\" href=\"https:\/\/developer.adobe.com\/document-services\/docs\/overview\/document-generation-api\/quickstarts\/\" rel=\"noopener ugc nofollow\" target=\"_blank\">quick stats<\/a> for an introduction.<\/p>\n<p id=\"91d9\" class=\"pw-post-body-paragraph ob oc gr od b hp oe of og hs oh oi oj ok ol om on oo op oq or os ot ou ov ow gk bj\">For now though just know we are going to use Word to create a template for our sample creation process. Let\u2019s take a look at that document now.<\/p>\n<figure class=\"nq nr ns nt nu nv nn no paragraph-image\">\n<div role=\"button\" tabindex=\"0\" class=\"nw nx fg ny bg nz\">\n<div class=\"nn no qa\"><picture><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/format:webp\/1*J9tCzohX2P1kFeZaHXw8Sg.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/format:webp\/1*J9tCzohX2P1kFeZaHXw8Sg.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/format:webp\/1*J9tCzohX2P1kFeZaHXw8Sg.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/format:webp\/1*J9tCzohX2P1kFeZaHXw8Sg.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/format:webp\/1*J9tCzohX2P1kFeZaHXw8Sg.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/format:webp\/1*J9tCzohX2P1kFeZaHXw8Sg.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1400\/format:webp\/1*J9tCzohX2P1kFeZaHXw8Sg.png 1400w\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 700px\" type=\"image\/webp\"\/><source data-testid=\"og\" srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/1*J9tCzohX2P1kFeZaHXw8Sg.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/1*J9tCzohX2P1kFeZaHXw8Sg.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/1*J9tCzohX2P1kFeZaHXw8Sg.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/1*J9tCzohX2P1kFeZaHXw8Sg.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/1*J9tCzohX2P1kFeZaHXw8Sg.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/1*J9tCzohX2P1kFeZaHXw8Sg.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1400\/1*J9tCzohX2P1kFeZaHXw8Sg.png 1400w\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 700px\"\/><img loading=\"lazy\" alt=\"Screenshot from MS Word, showing text with some words surrounded by tokens representing our variables.\" class=\"bg mv oa c\" width=\"700\" height=\"244\" loading=\"lazy\"\/><\/picture><\/div>\n<\/div>\n<\/figure>\n<p id=\"2393\" class=\"pw-post-body-paragraph ob oc gr od b hp oe of og hs oh oi oj ok ol om on oo op oq or os ot ou ov ow gk bj\">In the screenshot above, you can see a mix of \u201cregular\u201d Word text along with some words surrounded by curly braces ({{ }}) in the text.<\/p>\n<p id=\"2bad\" class=\"pw-post-body-paragraph ob oc gr od b hp oe of og hs oh oi oj ok ol om on oo op oq or os ot ou ov ow gk bj\">In the first paragraph, the words <code class=\"cw qb qc qd qe b\">title<\/code>, <code class=\"cw qb qc qd qe b\">author<\/code>, and <code class=\"cw qb qc qd qe b\">pageCount<\/code> are all surrounded by curly braces and represent tokens.<\/p>\n<p id=\"d100\" class=\"pw-post-body-paragraph ob oc gr od b hp oe of og hs oh oi oj ok ol om on oo op oq or os ot ou ov ow gk bj\">With the Document Generation API, we can send this Word document along with data for those values, and get a PDF generated with &#8216;real&#8217; values replacing the tokens.<\/p>\n<p id=\"6697\" class=\"pw-post-body-paragraph ob oc gr od b hp oe of og hs oh oi oj ok ol om on oo op oq or os ot ou ov ow gk bj\">Now our sample will actually address the content it&#8217;s sampling, giving details about the document&#8217;s title, author, and number of pages.<\/p>\n<p id=\"3cc6\" class=\"pw-post-body-paragraph ob oc gr od b hp oe of og hs oh oi oj ok ol om on oo op oq or os ot ou ov ow gk bj\">As an aside, this is one of the <em class=\"oy\">simplest<\/em> things you can do with the Document Generation API. Along with simple token replacements, you can have dynamic lists, tables, conditional content, and even dynamic images.<\/p>\n<p id=\"7c9b\" class=\"pw-post-body-paragraph ob oc gr od b hp oe of og hs oh oi oj ok ol om on oo op oq or os ot ou ov ow gk bj\">None of that is required for this particular demo, but keep in mind we\u2019re barely scratching the surface here.<\/p>\n<p id=\"6821\" class=\"pw-post-body-paragraph ob oc gr od b hp pv of og hs pw oi oj ok px om on oo py oq or os pz ou ov ow gk bj\">Your next question may be \u2014 how do we <em class=\"oy\">get<\/em> the title, author, and number of pages of a PDF? We can make use of the <a class=\"af ox\" href=\"https:\/\/developer.adobe.com\/document-services\/docs\/overview\/pdf-services-api\/howtos\/pdf-properties\/\" rel=\"noopener ugc nofollow\" target=\"_blank\">PDF Properties<\/a> API which, as you can probably guess, will return the properties of a PDF document.<\/p>\n<p id=\"36db\" class=\"pw-post-body-paragraph ob oc gr od b hp oe of og hs oh oi oj ok ol om on oo op oq or os ot ou ov ow gk bj\">Here\u2019s an example of the output returned from a PDF:<\/p>\n<figure class=\"nq nr ns nt nu nv\"\/>\n<p id=\"9dcc\" class=\"pw-post-body-paragraph ob oc gr od b hp oe of og hs oh oi oj ok ol om on oo op oq or os ot ou ov ow gk bj\">Note that there is an optional argument, <code class=\"cw qb qc qd qe b\">pageLevel<\/code>, that returns even more information about page content. Another thing to note is that the SDKs return properties in a slightly different format. It&#8217;s the same data, just with different labels essentially.<\/p>\n<p id=\"dc82\" class=\"pw-post-body-paragraph ob oc gr od b hp oe of og hs oh oi oj ok ol om on oo op oq or os ot ou ov ow gk bj\">Looking at the sample above, we can see our three values (Author, Title, page_count) are there, so let\u2019s look at how we can bring this all together.<\/p>\n<p id=\"13bb\" class=\"pw-post-body-paragraph ob oc gr od b hp pv of og hs pw oi oj ok px om on oo py oq or os pz ou ov ow gk bj\">Let\u2019s now turn to the updated workflow that will process our PDFs. If you read the <a class=\"af ox\" rel=\"noopener ugc nofollow\" target=\"_blank\" href=\"https:\/\/blog.developer.adobe.com\/dynamically-generating-document-samples-with-acrobat-services-fad3d4052e20\">previous post<\/a> (and I highly encourage you to do so), you\u2019ll remember there were two scripts.<\/p>\n<p id=\"7237\" class=\"pw-post-body-paragraph ob oc gr od b hp oe of og hs oh oi oj ok ol om on oo op oq or os ot ou ov ow gk bj\">The first one simply figured out what PDFs needed to be processed. It did this by looking at an input directory and seeing which files did <em class=\"oy\">not<\/em> exist in a corresponding output folder.<\/p>\n<p id=\"7cad\" class=\"pw-post-body-paragraph ob oc gr od b hp oe of og hs oh oi oj ok ol om on oo op oq or os ot ou ov ow gk bj\">In this version, the code in this file has changed in one small way. Instead of specifying a file for the PDF to prepend to our samples, we instead point to the Word doc:<\/p>\n<figure class=\"nq nr ns nt nu nv\"\/>\n<p id=\"53f4\" class=\"pw-post-body-paragraph ob oc gr od b hp oe of og hs oh oi oj ok ol om on oo op oq or os ot ou ov ow gk bj\">As that\u2019s the only real change, so let\u2019s get right into the new PDF processing script. We\u2019ll focus on the changes from the previous version.<\/p>\n<p id=\"dec8\" class=\"pw-post-body-paragraph ob oc gr od b hp oe of og hs oh oi oj ok ol om on oo op oq or os ot ou ov ow gk bj\">First, let\u2019s look at the main entry point, <code class=\"cw qb qc qd qe b\">makeSample<\/code>, which is called by the previous script:<\/p>\n<figure class=\"nq nr ns nt nu nv\"\/>\n<p id=\"0804\" class=\"pw-post-body-paragraph ob oc gr od b hp oe of og hs oh oi oj ok ol om on oo op oq or os ot ou ov ow gk bj\">From the top, we begin by getting our access token. We use the credentials generated by Adobe\u2019s developer console and exchange them for the token.<\/p>\n<p id=\"914f\" class=\"pw-post-body-paragraph ob oc gr od b hp oe of og hs oh oi oj ok ol om on oo op oq or os ot ou ov ow gk bj\">Next, we upload the PDF that we\u2019ll be creating a sample from and store it in the <code class=\"cw qb qc qd qe b\">asset<\/code> variable.<\/p>\n<p id=\"c74f\" class=\"pw-post-body-paragraph ob oc gr od b hp oe of og hs oh oi oj ok ol om on oo op oq or os ot ou ov ow gk bj\">Now we need to generate our dynamic PDF that will be prepended. First, the Word doc is uploaded and the result is stored as <code class=\"cw qb qc qd qe b\">prependAsset<\/code>.<\/p>\n<p id=\"365f\" class=\"pw-post-body-paragraph ob oc gr od b hp oe of og hs oh oi oj ok ol om on oo op oq or os ot ou ov ow gk bj\">We need our data for the token. To accomplish that, we use a new function, <code class=\"cw qb qc qd qe b\">makePropertiesJob<\/code>, which wraps a REST API call to the PDF Properties endpoint.<\/p>\n<p id=\"1e2f\" class=\"pw-post-body-paragraph ob oc gr od b hp oe of og hs oh oi oj ok ol om on oo op oq or os ot ou ov ow gk bj\">Here&#8217;s that call:<\/p>\n<figure class=\"nq nr ns nt nu nv\"\/>\n<p id=\"3aeb\" class=\"pw-post-body-paragraph ob oc gr od b hp oe of og hs oh oi oj ok ol om on oo op oq or os ot ou ov ow gk bj\">When this job is done, we then need to copy out the value we care about: author, title, and page count.<\/p>\n<p id=\"a150\" class=\"pw-post-body-paragraph ob oc gr od b hp oe of og hs oh oi oj ok ol om on oo op oq or os ot ou ov ow gk bj\">Note that in our testing, author and title weren\u2019t always available, hence the use of the Elvis operator to handle those cases. The end result is a new, simpler object named <code class=\"cw qb qc qd qe b\">documentInfo<\/code>, that contains the information we want to use in our generated PDF.<\/p>\n<p id=\"e36e\" class=\"pw-post-body-paragraph ob oc gr od b hp oe of og hs oh oi oj ok ol om on oo op oq or os ot ou ov ow gk bj\">You can see this passed to our next new function, <code class=\"cw qb qc qd qe b\">makeDocumentGenerationJob<\/code>. Not surprisingly, this looks very similar to the last function, just with slightly different attributes and a new endpoint:<\/p>\n<figure class=\"nq nr ns nt nu nv\"\/>\n<p id=\"9600\" class=\"pw-post-body-paragraph ob oc gr od b hp oe of og hs oh oi oj ok ol om on oo op oq or os ot ou ov ow gk bj\">And that\u2019s it! The rest of the main function simply uses the <a class=\"af ox\" href=\"https:\/\/developer.adobe.com\/document-services\/docs\/apis\/#tag\/Combine-PDF\" rel=\"noopener ugc nofollow\" target=\"_blank\">Combine PDF<\/a> functionality that we used in the last post.<\/p>\n<p id=\"7f1c\" class=\"pw-post-body-paragraph ob oc gr od b hp oe of og hs oh oi oj ok ol om on oo op oq or os ot ou ov ow gk bj\">Remember, this API not only lets you combine multiple PDFs but also lets you specify a range of pages to combine. We use this to combine our \u2018prepend\u2019 PDF and a slice of the main PDF.<\/p>\n<p id=\"86dc\" class=\"pw-post-body-paragraph ob oc gr od b hp oe of og hs oh oi oj ok ol om on oo op oq or os ot ou ov ow gk bj\">Here\u2019s an example of what that first page would look like:<\/p>\n<figure class=\"nq nr ns nt nu nv nn no paragraph-image\">\n<div role=\"button\" tabindex=\"0\" class=\"nw nx fg ny bg nz\">\n<div class=\"nn no qi\"><picture><source srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/format:webp\/1*RB8z26rsQ4bFtB9v4OkUpw.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/format:webp\/1*RB8z26rsQ4bFtB9v4OkUpw.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/format:webp\/1*RB8z26rsQ4bFtB9v4OkUpw.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/format:webp\/1*RB8z26rsQ4bFtB9v4OkUpw.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/format:webp\/1*RB8z26rsQ4bFtB9v4OkUpw.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/format:webp\/1*RB8z26rsQ4bFtB9v4OkUpw.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1400\/format:webp\/1*RB8z26rsQ4bFtB9v4OkUpw.png 1400w\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 700px\" type=\"image\/webp\"\/><source data-testid=\"og\" srcset=\"https:\/\/miro.medium.com\/v2\/resize:fit:640\/1*RB8z26rsQ4bFtB9v4OkUpw.png 640w, https:\/\/miro.medium.com\/v2\/resize:fit:720\/1*RB8z26rsQ4bFtB9v4OkUpw.png 720w, https:\/\/miro.medium.com\/v2\/resize:fit:750\/1*RB8z26rsQ4bFtB9v4OkUpw.png 750w, https:\/\/miro.medium.com\/v2\/resize:fit:786\/1*RB8z26rsQ4bFtB9v4OkUpw.png 786w, https:\/\/miro.medium.com\/v2\/resize:fit:828\/1*RB8z26rsQ4bFtB9v4OkUpw.png 828w, https:\/\/miro.medium.com\/v2\/resize:fit:1100\/1*RB8z26rsQ4bFtB9v4OkUpw.png 1100w, https:\/\/miro.medium.com\/v2\/resize:fit:1400\/1*RB8z26rsQ4bFtB9v4OkUpw.png 1400w\" sizes=\"(min-resolution: 4dppx) and (max-width: 700px) 50vw, (-webkit-min-device-pixel-ratio: 4) and (max-width: 700px) 50vw, (min-resolution: 3dppx) and (max-width: 700px) 67vw, (-webkit-min-device-pixel-ratio: 3) and (max-width: 700px) 65vw, (min-resolution: 2.5dppx) and (max-width: 700px) 80vw, (-webkit-min-device-pixel-ratio: 2.5) and (max-width: 700px) 80vw, (min-resolution: 2dppx) and (max-width: 700px) 100vw, (-webkit-min-device-pixel-ratio: 2) and (max-width: 700px) 100vw, 700px\"\/><img loading=\"lazy\" alt=\"PDF version of previous screenshot, with tokens replaced with real values.\" class=\"bg mv oa c\" width=\"700\" height=\"181\" loading=\"lazy\"\/><\/picture><\/div>\n<\/div>\n<\/figure>\n<p id=\"3530\" class=\"pw-post-body-paragraph ob oc gr od b hp oe of og hs oh oi oj ok ol om on oo op oq or os ot ou ov ow gk bj\">As an aside, in our use of Document Generation, all of the data came from the result of the PDF Properties API.<\/p>\n<p id=\"15ee\" class=\"pw-post-body-paragraph ob oc gr od b hp oe of og hs oh oi oj ok ol om on oo op oq or os ot ou ov ow gk bj\">In case it wasn\u2019t obvious, we can use <em class=\"oy\">any<\/em> data. So for example, I could have included a token for the URL showing where someone might purchase the full book.<\/p>\n<p id=\"ace1\" class=\"pw-post-body-paragraph ob oc gr od b hp oe of og hs oh oi oj ok ol om on oo op oq or os ot ou ov ow gk bj\">We would do that by adding the token to the Word document, and in our code, adding another key and value to the data passed to the Document Generation API.<\/p>\n<p id=\"6a22\" class=\"pw-post-body-paragraph ob oc gr od b hp pv of og hs pw oi oj ok px om on oo py oq or os pz ou ov ow gk bj\">If you want the complete source of this version, check out the repo at <a class=\"af ox\" href=\"https:\/\/github.com\/cfjedimaster\/document-services-demos\/tree\/main\/article_support\/book_demo\" rel=\"noopener ugc nofollow\" target=\"_blank\">https:\/\/github.com\/cfjedimaster\/document-services-demos\/tree\/main\/article_support\/book_demo<\/a>. This version uses <code class=\"cw qb qc qd qe b\">makeSamplesv2.js<\/code> and <code class=\"cw qb qc qd qe b\">pdfProcessorv2.js<\/code>. Be sure to sign up for your <a class=\"af ox\" href=\"https:\/\/acrobatservices.adobe.com\/dc-integration-creation-app-cdn\/main.html\" rel=\"noopener ugc nofollow\" target=\"_blank\">own credentials<\/a> and let us know what you think!<\/p>\n<\/div>\n<p><br \/>\n<br \/><a href=\"https:\/\/blog.developer.adobe.com\/dynamically-generating-document-samples-part-two-215a7796a2f6?source=rss----9342990108af---4\">Source link <\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>We\u2019ve already looked at ways to generate document samples using Adobe Acrobat Services. But how can we do even better? In our previous post, we discussed how to use Adobe Acrobat Services to generate PDF \u201csamples\u201d of documents. So for example, an online bookseller could use our APIs to automate the process of creating a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":8562,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[19],"tags":[],"class_list":["post-8561","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-graphics-design"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.satup.xyz\/index.php\/wp-json\/wp\/v2\/posts\/8561","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.satup.xyz\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.satup.xyz\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.satup.xyz\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.satup.xyz\/index.php\/wp-json\/wp\/v2\/comments?post=8561"}],"version-history":[{"count":0,"href":"https:\/\/www.satup.xyz\/index.php\/wp-json\/wp\/v2\/posts\/8561\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.satup.xyz\/index.php\/wp-json\/wp\/v2\/media\/8562"}],"wp:attachment":[{"href":"https:\/\/www.satup.xyz\/index.php\/wp-json\/wp\/v2\/media?parent=8561"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.satup.xyz\/index.php\/wp-json\/wp\/v2\/categories?post=8561"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.satup.xyz\/index.php\/wp-json\/wp\/v2\/tags?post=8561"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}