最近我决定学习如何使用log4j2记录器.我下载了所需的jar文件,创建了库,xml配置文件,并尝试使用它.不幸的是我在控制台(Eclipse)中得到了这个声明:
ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.
Run Code Online (Sandbox Code Playgroud)
这是我的测试类代码:
package log4j.test;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class Log4jTest
{
static final Logger logger = LogManager.getLogger(Logger.class.getName());
public static void main(String[] args) {
logger.trace("trace");
logger.debug("debug");
logger.info("info");
logger.warn("warn");
logger.error("error");
logger.fatal("fatal");
}
}
Run Code Online (Sandbox Code Playgroud)
和我的xml配置文件:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration package="log4j.test"
status="WARN">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
</Appenders>
<Loggers>
<Logger name="log4j.test.Log4jTest" level="trace">
<AppenderRef ref="Console"/>
</Logger>
<Root level="trace">
<AppenderRef ref="Console"/>
</Root> …Run Code Online (Sandbox Code Playgroud) 我有一个Web服务,在其响应中返回PDF文件内容.我想在用户点击链接时将其下载为pdf文件.我在UI中编写的javascript代码如下:
$http.get('http://MyPdfFileAPIstreamURl').then(function(response){
var blob=new File([response],'myBill.pdf',{type: "text/pdf"});
var link=document.createElement('a');
link.href=window.URL.createObjectURL(blob);
link.download="myBill.pdf";
link.click();
});
Run Code Online (Sandbox Code Playgroud)
'response'包含来自'MyPdfFileAPIstreamURl'的servlet输出流的PDF字节数组.并且流也未加密.
因此,当我点击链接时,PDF文件成功下载大小约为200KB.但是当我打开这个文件时,它会打开空白页面.下载的pdf文件的起始内容位于图像中.
我无法理解这里有什么问题.救命 !
这是下载的pdf文件的起始内容:
您好我使用PDF sharp将用户输入打印到模板文档中的位置.
数据(字段)从用户(网页)收集并使用抽绳方法写在文档上的适当位置.
目前我通过反复试验找到每个模板中每个模板化字段的像素位置.如果有一种方法可以确定pdf页面中每个字段的像素位置,那将会容易得多.
任何建议都会有所帮助.
谢谢
当我尝试使用pdfBox绘制png图像时,页面保持空白.有没有办法用pdfBox插入png图像?
public void createPDFFromImage( String inputFile, String image, String outputFile )
throws IOException, COSVisitorException
{
// the document
PDDocument doc = null;
try
{
doc = PDDocument.load( inputFile );
//we will add the image to the first page.
PDPage page = (PDPage)doc.getDocumentCatalog().getAllPages().get( 0 );
PDXObjectImage ximage = null;
if( image.toLowerCase().endsWith( ".jpg" ) )
{
ximage = new PDJpeg(doc, new FileInputStream( image ) );
}
else if (image.toLowerCase().endsWith(".tif") || image.toLowerCase().endsWith(".tiff"))
{
ximage = new PDCcitt(doc, new RandomAccessFile(new File(image),"r"));
}
else
{ …Run Code Online (Sandbox Code Playgroud) 在cygwin下的Windows7-64上编译gcc时出现以下错误.
./../zlib/libz.a(libz_a-gzlib.o):gzlib.c:(.text+0x646): undefined reference to `_wopen'
./../zlib/libz.a(libz_a-gzlib.o):gzlib.c:(.text+0x646): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `_wopen'
collect2: error: ld returned 1 exit status
make[3]: *** [../.././gcc/fortran/Make-lang.in:97: f951.exe] Error 1
Run Code Online (Sandbox Code Playgroud)
什么是wopen?
gcc-6或gcc-5不会发生这种情况.
谢谢.
该gaussian_kde函数scipy.stats具有如下功能:evaluate即可以返回一个输入点的PDF的值。我试图用来gaussian_kde估计逆 CDF。动机是生成一些输入数据的蒙特卡罗实现,其统计分布使用 KDE 进行数值估计。是否有绑定gaussian_kde到此目的的方法?
下面的例子展示了在高斯分布的情况下这应该如何工作。首先,我展示了如何进行 PDF 计算以设置我想要实现的特定 API:
import numpy as np
from scipy.stats import norm, gaussian_kde
npts_kde = int(5e3)
n = np.random.normal(loc=0, scale=1, size=npts_kde)
kde = gaussian_kde(n)
npts_sample = int(1e3)
x = np.linspace(-3, 3, npts_sample)
kde_pdf = kde.evaluate(x)
norm_pdf = norm.pdf(x)
Run Code Online (Sandbox Code Playgroud)
是否有类似的简单方法来计算逆 CDF?该norm函数有一个非常方便的isf函数,可以做到这一点:
cdf_value = np.sort(np.random.rand(npts_sample))
cdf_inv = norm.isf(1 - cdf_value)
Run Code Online (Sandbox Code Playgroud)
是否存在这样的函数kde_gaussian?或者从已经实现的方法构造这样的函数是否很简单?
我正在使用 pdfbox 在 pdf 文件中添加一行。但我添加的文字是相反的。
File file = new File(filePath);
PDDocument document = PDDocument.load(file);
PDPage page = document.getPage(0);
PDPageContentStream contentStream = new PDPageContentStream(document, page,PDPageContentStream.AppendMode.APPEND,true);
int stampFontSize = grailsApplication.config.pdfStamp.stampFontSize ? grailsApplication.config.pdfStamp.stampFontSize : 20
contentStream.beginText();
contentStream.setFont(PDType1Font.TIMES_ROMAN, stampFontSize);
int leftOffset = grailsApplication.config.pdfStamp.leftOffset ? grailsApplication.config.pdfStamp.leftOffset : 10
int bottomOffset = grailsApplication.config.pdfStamp.bottomOffset ? grailsApplication.config.pdfStamp.bottomOffset : 20
contentStream.moveTextPositionByAmount(grailsApplication.config.xMove,grailsApplication.config.yMove)
contentStream.newLineAtOffset(leftOffset, bottomOffset)
String text = "i have added this line...!!!!";
contentStream.showText(text);
contentStream.endText();
contentStream.close();
document.save(new File(filePath));
document.close();
byte[] pdfData;
pdfData = Files.readAllBytes(file.toPath());
return pdfData;
Run Code Online (Sandbox Code Playgroud)
我尝试使用 moveTextPositionByAmount 方法,但这似乎对文本没有任何影响。为什么我的文字颠倒了,我如何将其设置为正确的方向。

我尝试使用numpy.random.normal 文档中的示例绘制归一化直方图。为此,我生成了正态分布的随机样本。
mu_true = 0
sigma_true = 0.1
s = np.random.normal(mu_true, sigma_true, 2000)
Run Code Online (Sandbox Code Playgroud)
然后我将正态分布拟合到数据并计算 pdf。
mu, sigma = stats.norm.fit(s)
points = np.linspace(stats.norm.ppf(0.01,loc=mu,scale=sigma),
stats.norm.ppf(0.9999,loc=mu,scale=sigma),100)
pdf = stats.norm.pdf(points,loc=mu,scale=sigma)
Run Code Online (Sandbox Code Playgroud)
显示拟合的 pdf 和数据直方图。
plt.hist(s, 30, density=True);
plt.plot(points, pdf, color='r')
plt.show()
Run Code Online (Sandbox Code Playgroud)
我使用density=True,但很明显,pdf 和直方图没有标准化。
有什么建议可以绘制真正归一化的直方图和 pdf?
Seaborn distplot 也没有解决问题。
import seaborn as sns
ax = sns.distplot(s)
Run Code Online (Sandbox Code Playgroud)
我正在为前端使用 Javascript 制作一个 Web 应用程序,这就是它的工作原理:
我启动应用程序,它通过我的浏览器打开一个网页。
它显示从我的目录中获得的 PDF 页面。
我可以选择单击图章并在 pdf 中拖动和移动并放置在我想要的任何位置。
完成后,我可以单击“保存”,它会自动将 pdf 文件保存在我的目录中。
我可以打开文件夹中的 pdf 文件以查看更新的 PDF 以及添加的图章。
问题是当我打开PDF文件查看时,定位与Web浏览器中图章的定位不相同。
window.dragMoveListener = dragMoveListener;
interact('.signer-box')
.draggable({
onmove: dragMoveListener,
inertia: true,
autoScroll: true,
restrict: {
elementRect: {top: 0, left: 0, bottom: 1, right: 1}
}
})
.resizable({
onmove: resizeMoveListener,
inertia: true,
edges: {left: true, right: true, bottom: true, top: true}
})
function dragMoveListener(event) {
var target = event.target;
var x = (parseFloat(target.getAttribute('data-x')) || 0) + event.dx;
var y = (parseFloat(target.getAttribute('data-y')) || …Run Code Online (Sandbox Code Playgroud)