pdfmake:如何创建具有不同方向的多页PDF? [英] pdfmake: How to create multiple page pdf with different orientation?

查看:400
本文介绍了pdfmake:如何创建具有不同方向的多页PDF?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法使用 pdfmake 创建具有不同页面方向的多页PDF?

is there a way to create multiple page pdf with different page orientation using pdfmake?

为了简单起见,我想要这样的事情:

to make it simple, I want something like this :


  • Page 1 ,纵向方向

  • 页面 2 横向展开

  • 页面 3 纵向导向

  • Page 1 with portrait orientation
  • page 2 with landscape orientation
  • page 3 with portrait orientation

我用不同的方法尝试了很多次但总是对所有页面产生影响。

I've tried it so many times with different method but it always effect to all page.



抱歉我的英文


sorry for my terible english

推荐答案

这是老问题,但回答可能有助于他人。

This is and old question, but answering may help others.

如果要更改页面方向,只需在页面的第一个节点指定新值。

If you want to change page orientation you only need specify the new value at the first node of the page.

在这一行之后,我附上了一个简单的代码,您可以直接粘贴到 pdfmake playground 以试用它。

Below this lines I have attached a simple code that you can paste directly at pdfmake playground in order to try it.

祝你好运!

var dd = {
    content: [
        { 
            text: 'Unordered list', 
            style: 'header' 
        },
        {
            ol: [
                'item 1',
                'item 2',
                'item 3',
            ]
        },
        { 
             text: '\n\nUnordered list with longer lines', 
             style: 'header', 
             pageBreak: 'before', 
             pageOrientation: 'landscape' 
        },
        {
            ol: [
                'item 1',
                'Lorem ipsum dolor sit amet, consectetur ..',
                'item 3',
            ]
        },
        { 
            text: '\n\nNested lists', 
            style: 'header', 
            pageBreak: 'before', 
            pageOrientation: 'portrait' 
        },
        {
            ol: [
                'item 1',
                'Lorem ipsum dolor sit amet, consectetur ..',
                {
                    ol: [
                        'subitem 1',
                        'subitem 2',
                        'subitem 3 - Lorem ipsum dolor sit ame...',
                        'subitem 4',
                        'subitem 5',
                    ]
                },
                'item 3\nsecond line of item3',
            ]
        },
    ],
    styles: {
        header: {
            bold: true,
            fontSize: 15
        }
    },
    defaultStyle: {
        fontSize: 12,
    }   
}

这篇关于pdfmake:如何创建具有不同方向的多页PDF?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆