世博打印不打印自定义html

问题描述

环境: “ react-native-web”:“〜0.11.7”, “ expo-print”:“〜9.0.1”, “ expo”:“〜38.0.8”

预期行为:打印带有“ html”的pdf

    const htmlContent = `
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <Meta charset="UTF-8">
        <Meta name="viewport" content="width=device-width,initial-scale=1.0">
        <title>Pdf Content</title>
        <style>
            body {
                font-size: 16px;
                color: rgb(255,196,0);
            }            h1 {
                text-align: center;
            }
        </style>
    </head>
    <body>
        <h1>Hello,Unica Exames!</h1>
    </body>
    </html>
`;

async function createPDF(html) {
    console.log(html);
    try {
        const { uri } = await Print.printToFileAsync({ html });
        console.log(uri);
        return uri;
    } catch (err) {
        console.error(err);
    }
};

export const PrescriptionPage  = ({ navigation }) => {
    return(
        <View style={{flex: 1}}>
            <SafeAreaView style={{ flex: 1,width: null,height: null }}>
                <imagebackground source={backgroundImage} style={styles.backgroundContainer}>
                    <TouchableOpacity style={styles.sideOptionsButton} onPress={() => createPDF(htmlContent)}>
                        <Ionicons name='ios-menu' size={28} color='#ffffff' />
                    </TouchableOpacity>
                    <Text style={styles.logoTextStyle}>PrescriptionPage</Text>
                </imagebackground>
            </SafeAreaView>
        </View>
    );
};

发生了什么:该函数正在打印“ PrescriptionPage”的内容

在日志中显示错误:TypeError:_await $ Print $ printToF未定义

enter image description here

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)