我一直在尝试使用pdf在Unity3D中创建sharpPDF图像。hello world测试进行得很好,但无论我做什么,我都不能让图像正常工作。使用ddImage函数会使pdf阅读器崩溃,而使用newAddImage似乎什么也做不了。不幸的是,谷歌一点帮助都没有,所以我希望这里有人能帮我!
我确实研究了一个不同的库,但是pdfsharp就是不起作用,在编译器上给出了大量的错误,iTextSharp太昂贵了。
API在这里http://www.francescogallorini.com/2011/02/unity-sharp-pdf/
我的代码是:
//byte[] image;
//image = File.ReadAllBytes("Assets/Sprites/128x128 player ship trial.png");
pdfDocument myDoc = new sharpPDF.pdfDocument("Awesome Space Station", "Al Wyvern");
pdfPage myPage = myDoc.addPage(500,500);
myPage.newAddImage("Assets/Sprites/128x128 player ship trial.png", 10, 10);
//myPage.addImage(image, 0,0,256,256);
myPage.addText("Hello World", 128, 128, predefinedFont.csCourier, 20);
myDoc.createPDF("Awesome Space Station.pdf");
myPage = null;
myDoc = null;感谢您所能给予的任何帮助
发布于 2018-08-14 04:57:28
// in your poco
public string HeaderImage { get; set; } =
Path.GetDirectoryName(Path.GetDirectoryName(
System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName()
.CodeBase))) + "\\assets\\your_logo.png";
// then in your function
myDoc.addImageReference(HeaderImage.Replace("file:\\", string.Empty), "Logo");
pdfPage.addImage(myDoc.getImageReference("Logo"), 13, 720, 60, 60);https://stackoverflow.com/questions/36046887
复制相似问题