Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PagesApp not working #1

Open
thmarx opened this issue Mar 23, 2023 · 7 comments
Open

PagesApp not working #1

thmarx opened this issue Mar 23, 2023 · 7 comments

Comments

@thmarx
Copy link

thmarx commented Mar 23, 2023

Hi,

I have looked at the demos and there seems to be problems with the PagesApp. Texts are not output to the PDF.

@mimidesunya
Copy link
Owner

mimidesunya commented Mar 25, 2023

PagesApp does not embed fonts in PDF, so some viewers may not be able to see the text.
For example, the following program embeds fonts:

public class PagesApp {
	public static void main(String[] args) throws Exception {
		try (PDFWriter pdf = new PDFWriterImpl(new FileRandomBuilder(new File("out/pages.pdf")))) {
			pdf.getParams().setVersion(Version.V_PDFA1B);
			
			FontFace fontFace = new FontFace();
			fontFace.src = new FileSource(new File("/usr/share/fonts/truetype/noto/NotoMono-Regular.ttf"));
			fontFace.fontFamily = FontFamilyList.SERIF;
			pdf.getFontManager().addFontFace(fontFace);
			
			try (PDFGraphics2D g2d = new PDFGraphics2D(pdf.nextPage(PDFUtils.mmToPt(PDFUtils.PAPER_A4_WIDTH_MM),
					PDFUtils.mmToPt(PDFUtils.PAPER_A4_HEIGHT_MM)))) {
				g2d.setFont(new Font(Font.SERIF, Font.PLAIN, 38));
				g2d.drawString("Page 1", 10, 100);
			}
			try (PDFGraphics2D g2d = new PDFGraphics2D(pdf.nextPage(PDFUtils.mmToPt(PDFUtils.PAPER_A4_WIDTH_MM),
					PDFUtils.mmToPt(PDFUtils.PAPER_A4_HEIGHT_MM)))) {
				g2d.setFont(new Font(Font.SERIF, Font.PLAIN, 38));
				g2d.drawString("Page 2", 10, 100);
			}
		}
	}
}

@thmarx
Copy link
Author

thmarx commented Mar 27, 2023

Sorry, but that example also doesn't work. At least with both released versions (1.1.0 and 1.2.0), it's not possible to produce a correct pdf.
I tried the DrawApp example, and the created pdf is also not correct. The pages are just empty.
If I open the pdfs with the Acrobat Reader an error message pops up, but without any meaningful details.

I upload both pdfs, maybe it helps analyzing the problem.

@thmarx
Copy link
Author

thmarx commented Mar 27, 2023

@mimidesunya
Copy link
Owner

mimidesunya commented Mar 28, 2023

Sorry, I cannot reproduce the problem.
The attached project works fine with gradle run.

pdfg2dtest.zip

@thmarx
Copy link
Author

thmarx commented Mar 28, 2023

Crazy, your project produces an empty PDF on my system.
Maybe an issue for Windows systems, or some encoding stuff?

I tested with jdk 17 and 19.

@mimidesunya
Copy link
Owner

I just tested with JDK17 on Windows and could not reproduce the problem.
Since I cannot reproduce the issue, I'm unable to respond.

@thmarx
Copy link
Author

thmarx commented Apr 12, 2023

That is a pity. But if you can't reproduce the problem, there's probably nothing you can do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants