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

The font kaiu.tff(標楷體) broken while convert pdf to png. #95

Open
k9215105 opened this issue Nov 26, 2021 · 5 comments
Open

The font kaiu.tff(標楷體) broken while convert pdf to png. #95

k9215105 opened this issue Nov 26, 2021 · 5 comments

Comments

@k9215105
Copy link

I am using RasterizerSample1 to convert a pdf file to png.
The pdf file contains chinese word with font 標楷體(kaiu.tff), which will broken in output file.
pdf
image
png
image

@rainmakerho
Copy link

rainmakerho commented Nov 29, 2021

Hi @k9215105 ,
You can use GhostscriptProcessor from ProcessorSample1.

// call pdf2Png();
static void ghostscript_Processing(object sender, GhostscriptProcessorProcessingEventArgs e)
{
	Console.WriteLine(e.CurrentPage.ToString() + " / " + e.TotalPages.ToString());
}

private static void pdf2Png()
{
	string inputFile = @"c:\temp\abc.pdf";
	string outputFile = @"c:\temp\abc-page-%03d.png";

	int pageFrom = 1;
	int pageTo = 50;

	using (GhostscriptProcessor ghostscript = new GhostscriptProcessor())
	{
		ghostscript.Processing += new GhostscriptProcessorProcessingEventHandler(ghostscript_Processing);

		List<string> switches = new List<string>();
		switches.Add("-empty");
		switches.Add("-dSAFER");
		switches.Add("-dBATCH");
		switches.Add("-dNOPAUSE");
		switches.Add("-dNOPROMPT");
		switches.Add("-dFirstPage=" + pageFrom.ToString());
		switches.Add("-dLastPage=" + pageTo.ToString());
		switches.Add("-sDEVICE=png16m");
		switches.Add("-r96");
		switches.Add("-dTextAlphaBits=4");
		switches.Add("-dGraphicsAlphaBits=4");
		switches.Add(@"-sOutputFile=" + outputFile);
		switches.Add(@"-f");
		switches.Add(inputFile);
		ghostscript.Process(switches.ToArray());
	}
}

@k9215105
Copy link
Author

k9215105 commented Dec 1, 2021

It works, thanks for that.

@rainmakerho
Copy link

Hi @k9215105 �,
Could you give us more information about "doesn't work" ?

@k9215105
Copy link
Author

k9215105 commented Dec 1, 2021

Sorry, it was a mistake, it works now, thanks

@k9215105
Copy link
Author

k9215105 commented Feb 21, 2022 via email

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