Skip to main content
March 6, 2024
Question

PDF Tool - Covert image to PDF- the image size is not resized and right part is chopped off

  • March 6, 2024
  • 3 replies
  • 1 view

{

{
  'type!{urn:appian:ps:pdftools}PdfContent'(
    page: 1,
    xPercent: 10,
    yPercent: 95,
    angle: 0,
    sections: {
      'type!{urn:appian:ps:pdftools}PdfSection'(
        components: 'type!{urn:appian:ps:pdftools}PdfImage'(
          scale: .2,
          document: todocument(ri!imageCreated)
        )
      ),
    }
  ),
  'type!{urn:appian:ps:pdftools}PdfContent'(
    page: 1,
    xPercent: 50,
    yPercent: 10,
    angle: 0,
    sections: {
      'type!{urn:appian:ps:pdftools}PdfSection'(
        style: 'type!{urn:appian:ps:pdftools}PdfStyle'(
          fontSize: 9
        ),
        components: {
          'type!{urn:appian:ps:pdftools}PdfText'(
            value: concat(
              ri!Nm,
              ", FEI#",
              ri!Id,
            )
          ),
        }
      ),
      'type!{urn:appian:ps:pdftools}PdfSection'(
        style: null,
        components: {
          'type!{urn:appian:ps:pdftools}PdfText'(
            value: concat(
              a!forEach(
                items: index(ri!Dates,"date",null),
                expression: if(
                  fv!isLast,
                  fv!item,
                  fv!item & ", "
                )
              ),
              " ",
              ri!teamInitials,
            )
          ),
        }
      ),
      'type!{urn:appian:ps:pdftools}PdfSection'(
        style: null,
        components: {
          'type!{urn:appian:ps:pdftools}PdfText'(
            value: concat(
              if(
                a!isNullOrEmpty(ri!Number),
                {},
                { "Exhibit ", ri!Number, " - " }
              ),
              "Page ",
              ri!imageCounts,
              " of ",
              ri!pageCount
            )
          ),
        }
      ),
    }
  ),
}

3 replies

mikes0011
Brainy
March 6, 2024

I don't know that this smart service promises any sort of pre-scaling of images that will be added to PDFs (and, maybe it does and you need to continue tweaking the parameters you pass to find the "right fit").

Otherwise I'd suggest you check out the "resize image" functionality in the Appian Image Utilities plug-in, to handle out-size images prior to PDF conversion.  I struggled for a while to figure out how to tell an image's size programmatically, but eventually I stumbled on the "Get File Metadata" plug-in which makes it possible.

ajays0012Author
March 6, 2024

Can you please help me with some example. thank you

mikes0011
Brainy
March 6, 2024

i'm not really sure what example you want.  i'd recommend you try various troubleshooting tips to see what the behavior of the resulting PDF is, including:

  • try it on images of different original resolutions (ranging between slightly smaller and much smaller)
  • adjusting parameters of the "pdf content" - notably the "scale" of the "pdf image", to see what it does when its value is changed
  • adjusting the number of "PDF Sections" and their respective settings, to see if that has any impact on the image you're trying to embed.