我在 iText 7 中有一个 java 程序,它接收 JSON 数据并生成一个 PDF 文档(带有页眉和页脚),它可以很好地处理clientData
注释中变量中的数据,但是当在没有注释clientData
中使用变量时,我得到了这个错误java.lang.NullPointerException
,在构建页眉和页脚(在这一行Rectangle pageSize = document.getPdfDocument().getPage(i).getPageSize();
)时出现错误,但不知道哪些数据为空,因为JSON数据和PDF的结构是一样的,我做错了什么?
这是所有的代码:
import com.itextpdf.kernel.pdf.PdfDocument;
import com.itextpdf.kernel.pdf.PdfPage;
import com.itextpdf.kernel.pdf.PdfReader;
import com.itextpdf.kernel.pdf.PdfWriter;
import com.itextpdf.kernel.pdf.canvas.PdfCanvas;
import com.itextpdf.kernel.pdf.extgstate.PdfExtGState;
import com.itextpdf.layout.Document;
import com.itextpdf.layout.element.Table;
import com.itextpdf.layout.element.Text;
import com.itextpdf.io.image.ImageData;
import com.itextpdf.io.image.ImageDataFactory;
import com.itextpdf.kernel.colors.Color;
import com.itextpdf.kernel.colors.DeviceRgb;
import com.itextpdf.kernel.font.PdfFont;
import com.itextpdf.kernel.font.PdfFontFactory;
import com.itextpdf.kernel.geom.Rectangle;
import com.itextpdf.layout.element.Cell;
import com.itextpdf.layout.element.Image;
import com.itextpdf.layout.element.List;
import com.itextpdf.layout.element.ListItem;
import com.itextpdf.layout.element.Paragraph;
import com.itextpdf.layout.property.TextAlignment;
import com.itextpdf.layout.property.VerticalAlignment;
import java.io.File;
import java.io.IOException;
import java.text.NumberFormat;
import java.util.Locale;
import org.json.JSONArray;
import org.json.JSONObject; …
Run Code Online (Sandbox Code Playgroud) 在 extjs 应用程序中,我有一个读取 json 文件的树面板,在树面板中我有一个执行操作的复选框,另外我将选中的元素保存在选项卡面板的网格面板中...
\n\n我想删除之前使用复选框的 checkchange 事件保存的商店的任何元素...
\n\n我有这个代码
\n\n风景:
\n\nExt.define(\'app.view.ViewTablaContenido\', {\nextend: \'Ext.window.Window\',\nid: \'viewTablaContenido\',\nshadow: false, \nalias: \'widget.tablaContenido\', \n\ninitComponent: function() {\n .......\n\n var tree = Ext.create(\'Ext.tree.Panel\', {\n title: \'\',\n id: "arbolTabla", \n width: anchoTOC,\n height: altoTOC, \n reserveScrollbar: true,\n loadMask: true,\n useArrows: true,\n rootVisible: false,\n store: \'capa\',\n allowDeselect : true,\n border : true,\n animate: true,\n columns: [{\n xtype: \'treecolumn\',\n text: \'Capa\',\n flex: 5,\n sortable: true,\n dataIndex: \'titulo\'\n },{\n text: \'Metadato\',\n flex: 2,\n dataIndex: \'metadato\',\n renderer: addUrl\n }]\n …
Run Code Online (Sandbox Code Playgroud) 我有一个使用 Spring Boot 构建的 REST API 项目,我想记录我的所有端点。我已经实现了 swagger 来做到这一点并且成功了,但是最近我的项目不再运行了,配置与创建项目时的配置相同并且 Swagger 可以工作。
尝试运行项目时出现此错误:
WARN 17868 --- [ restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerException
....
ERROR 17868 --- [ restartedMain] o.s.boot.SpringApplication : Application run failed
org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerException
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
这是我的项目配置:
主要的
package com.red.api;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication
@EnableScheduling
@PropertySource(value = …
Run Code Online (Sandbox Code Playgroud) 我需要从我的谷歌驱动器下载一个文件,在使用 python 进行一些测试后,我从驱动器下载了数据,就像谷歌文档所说的那样(https://developers.google.com/drive/api/v3/quickstart/python), (https://developers.google.com/drive/api/v3/manage-downloads#downloading_a_file),但我不知道如何将此“数据”保存在文件中。
我怎样才能做到这一点?
这是我的代码
from __future__ import print_function
import pickle
import os.path
import io
from googleapiclient.discovery import build
from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request
from googleapiclient.http import MediaIoBaseDownload
SCOPES = ['https://www.googleapis.com/auth/drive']
creds = None
if os.path.exists('token.pickle'):
with open('token.pickle', 'rb') as token:
creds = pickle.load(token)
if not creds or not creds.valid:
if creds and creds.expired and creds.refresh_token:
creds.refresh(Request())
else:
flow = InstalledAppFlow.from_client_secrets_file('credentials.json', SCOPES)
creds = flow.run_local_server(port=0)
# Save the …
Run Code Online (Sandbox Code Playgroud) java ×2
extjs ×1
extjs5 ×1
itext7 ×1
javascript ×1
python ×1
python-3.x ×1
rest ×1
spring-boot ×1
swagger-2.0 ×1
swagger-ui ×1