在wordpress中的白名单主页(Whitelist home page in wordpress)
我正在使用强制登录wordpress插件来限制用户登录之前查看某些页面,但我想查看主页没有登录我想在白名单中添加主页,但它不工作我使用我的自定义主题。可以建议什么插件我应该使用/我应该为此做什么。
function my_forcelogin_whitelist( $whitelist ) { //$whitelist[] = 'http://localhost/wordpress/index.php/home/'; //$whitelist[] = site_url( '/index.php/home/' ); $whitelist[] = 'http://localhost/wordpress/index.php/'; $whitelist[] = site_url( '/index.php/' ); return $whitelist; } add_filter('v_forcelogin_whitelist', 'my_forcelogin_whitelist', 10, 1);
I am using force login wordpress plugin to restrict user to login before viewing certain pages but i want to view home page without login i am trying to add home page in whitelist but its not working i am using my custom theme.Can you suggest what plugin should i use/what should i do for this purpose.
function my_forcelogin_whitelist( $whitelist ) { //$whitelist[] = 'http://localhost/wordpress/index.php/home/'; //$whitelist[] = site_url( '/index.php/home/' ); $whitelist[] = 'http://localhost/wordpress/index.php/'; $whitelist[] = site_url( '/index.php/' ); return $whitelist; } add_filter('v_forcelogin_whitelist', 'my_forcelogin_whitelist', 10, 1);
原文:https://stackoverflow.com/questions/45597626
最满意答案
从1.8.11升级到2.0.0后,我设法通过改变图像添加到PDF的方式来解决问题。
PDPageContentStream contentStream = ...; PDDocument document = ...; InputStream imageStream = this.getClass().getClassLoader().getResourceAsStream("image.jpg"); PDImageXObject image = JPEGFactory.createFromStream(document,imageStream); contentStream.drawImage(image, 50, 700, 250, 67);
关键似乎是使用:
JPEGFactory.createFromStream()
代替:
PDImageXObject.createFromFile()
After upgrading from 1.8.11 to 2.0.0, I've managed to resolve the issue by changing the way the image was added to the PDF.
PDPageContentStream contentStream = ...; PDDocument document = ...; InputStream imageStream = this.getClass().getClassLoader().getResourceAsStream("image.jpg"); PDImageXObject image = JPEGFactory.createFromStream(document,imageStream); contentStream.drawImage(image, 50, 700, 250, 67);
The key seems to be the use of:
JPEGFactory.createFromStream()
instead of:
PDImageXObject.createFromFile()
相关问答
更多-
你犯了两个错误: 保存文档后,您已关闭contentStream而不是之前。 您还没有设置字体。 适用于我的代码(删除了异常处理): PDDocument document; PDPage page; PDPageContentStream contentStream; document = new PDDocument(); page = new PDPage(); document.addPage(page); contentStream = new PDPageContentStream(docum ...
-
从1.8.11升级到2.0.0后,我设法通过改变图像添加到PDF的方式来解决问题。 PDPageContentStream contentStream = ...; PDDocument document = ...; InputStream imageStream = this.getClass().getClassLoader().getResourceAsStream("image.jpg"); PDImageXObject image = JPEGFactory.createFromStream(d ...
-
我能找到一个解决方案,但我仍然不明白使用流时出了什么问题。 详细: 虽然以下代码引发异常( java.io.IOException:错误:文件结束,预计行) : ByteArrayOutputStream out = new ByteArrayOutputStream(); InputStream mainDocStream = new FileInputStream(path...); InputStream additionalDocStream = new FileInputStream(path.. ...
-
使用PDFBox缩放PDF页面(Scaling a PDF page using PDFBox)[2023-07-19]
使用 BufferedImage img = page.convertToImage(BufferedImage.TYPE_INT_RGB, 300); 在PDFBox 1.8。*中,这将以300dpi呈现。 默认(您使用的)是144dpi。 因此,根据您的需要,使用大于或小于144的dpi参数。 use BufferedImage img = page.convertToImage(BufferedImage.TYPE_INT_RGB, 300); in PDFBox 1.8.*, this will ... -
PDFBox图像大小问题(PDFBox image size issues)[2022-03-25]
如果您的意图是PDF上的A4大小的图片,那么我猜您会找到典型A4的实际大小(以像素为单位)。 另外你应该知道你要查看的图片的扩展名,如jpg,gif或bmp ... 从我在你的代码中看到的,图片的尺寸是10 X 700,我认为这是相当小的尺寸。 contentStream.drawImage(img, 10, 700); 而图片的扩展是:jpg InputStream in = new FileInputStream(new File("img.jpg")); 检查这些并返回以获取更多信息。 就这样。 ... -
正如评论中所讨论的:特定字体的PDFont对象应该只构造一次,并且可以在一个PDF的不同页面中重用。 字体应该是子集化的(即只嵌入使用的字形),使用PDType0Font.load() 。 这同样适用于PDXObjectImage对象,例如公司徽标:PDXObjectImage应创建一次,并在一个PDF的不同页面中重用。 不应在不同的PDF中使用PD对象。 As discussed in the comments: PDFont objects of a specific font should be co ...
-
问题是你添加一个新的页面到文档 doc.addPage(new PDPage()); 但是然后为另一个不添加到文档中的新页面创建一个内容流: PDPageContentStream contentStream = new PDPageContentStream(doc, new PDPage(), true, false); 您应该为添加到文档中的页面创建内容流,例如: PDDocument doc = null; doc = new PDDocument(); PDPage page = new PD ...
-
由于没有人回答,我自己在评论中尝试了我的建议。 第一个结果: import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.RenderingHints; import java.awt.image.BufferedImage; import java.io.IOException; import java.lang.reflect.Field; import java.util.H ...
-
如果查看日志记录输出(可能需要在您的环境中激活日志记录)。 你会看到很多像这样的条目(使用PDFBox 1.8.5生成): Jun 16, 2014 8:40:43 AM org.apache.pdfbox.pdmodel.font.PDSimpleFont drawString Warnung: Changing font on
from to the default font Jun 16, 2014 8:40:43 AM org.apache ... -
您只需使用PdfMergeUtility.addSource(InputStream)方法从输入流而不是物理文件添加源。 通过快速浏览一下API,你可以做的就是使用PDDocument.save(OutputStream)方法将文件写入内存中的字节数组中,像这样的应该工作。 static byte[] doIt(String message) { PDDocument doc = new PDDocument(); // add the message ByteArrayOutputStr ...